FundingCommand

Class
extends BaseCommand
Final: Yes

Synchronizes funding metadata between composer.json and .github/FUNDING.yml.

Attributes
#[AsCommand]
$name : 'funding'
$description : 'Synchronizes funding metadata between composer.json and .github/FUNDING.yml.'
$help : 'This command merges supported funding entries across composer.json and .github/FUNDING.yml while preserving unsupported providers.'

Table of Contents

Interfaces

LoggerAwareCommandInterface

Defines the logger contract consumed by reusable command result helpers.

Properties

Methods

__construct()

Creates a new FundingCommand instance.

 : mixed
addJsonOption()

Adds the standard JSON output options to the current command.

 : static
configure()

Configures command options.

 : void
execute()

Synchronizes funding metadata across Composer and GitHub files.

 : int
isJsonOutput()

Determines whether JSON output was requested.

 : bool
isPrettyJsonOutput()

Determines whether pretty JSON output was requested.

 : bool
failure()

Logs a failed command result and returns the failure exit code.

 : int
handleComposerFile()

Handles composer.json synchronization reporting and writes.

 : int
handleFundingFile()

Handles .github/FUNDING.yml synchronization reporting and writes.

 : int
normalizeComposerFile()

Normalizes a composer manifest after funding metadata changes.

 : int
notice()

Logs an informational command message at notice level.

 : void
shouldWriteManagedFile()

Prompts whether a managed file should be written.

 : bool
success()

Logs a successful command result and returns the success exit code.

 : int
Properties
Methods

__construct()

Public

Creates a new FundingCommand instance.

public __construct(FilesystemInterface  $filesystem, ComposerFundingCodec  $composerFundingCodec, FundingYamlCodec  $fundingYamlCodec, FundingProfileMerger  $fundingProfileMerger, FileDiffer  $fileDiffer, ProcessBuilderInterface  $processBuilder, ProcessQueueInterface  $processQueue, LoggerInterface  $logger) : mixed
Parameters
$filesystem : FilesystemInterface

Description

the filesystem used to read and write funding metadata files

$composerFundingCodec : ComposerFundingCodec

Description

the codec used to parse and render Composer funding metadata

$fundingYamlCodec : FundingYamlCodec

Description

the codec used to parse and render GitHub funding YAML metadata

$fundingProfileMerger : FundingProfileMerger

Description

the merger used to synchronize normalized funding profiles

$fileDiffer : FileDiffer

Description

the differ used to summarize managed-file drift

$processBuilder : ProcessBuilderInterface

Description

the process builder used to normalize composer.json after updates

$processQueue : ProcessQueueInterface

Description

the process queue used to execute composer normalize

$logger : LoggerInterface

Description

the output-aware logger

addJsonOption()

Protected

Adds the standard JSON output options to the current command.

protected addJsonOption() : static
Return values
static

configure()

Protected

Configures command options.

protected configure() : void

execute()

Protected

Synchronizes funding metadata across Composer and GitHub files.

protected execute(InputInterface  $input, OutputInterface  $output) : int
Parameters
$input : InputInterface

Description

the command input

$output : OutputInterface

Description

the command output

Return values
int

Description

the command status code

isJsonOutput()

Protected

Determines whether JSON output was requested.

protected isJsonOutput(InputInterface  $input) : bool

Description

The pretty-json flag SHALL imply JSON output.

Parameters
$input : InputInterface
Return values
bool

isPrettyJsonOutput()

Protected

Determines whether pretty JSON output was requested.

protected isPrettyJsonOutput(InputInterface  $input) : bool
Parameters
$input : InputInterface
Return values
bool

failure()

Private

Logs a failed command result and returns the failure exit code.

private failure( string  $message, InputInterface  $input[, array<string, mixed>  $context = []][, string|null  $file = null][, int|null  $line = null]) : int
Parameters
$message : string

Description

the failure message

$input : InputInterface

Description

the originating command input

$context : array<string, mixed> = []

Description

optional extra log context

$file : string|null = null

Description

the related file path when known

$line : int|null = null

Description

the related line when known

Return values
int

handleComposerFile()

Private

Handles composer.json synchronization reporting and writes.

private handleComposerFile( string  $composerFile, string  $composerContents, string  $updatedComposerContents, bool  $dryRun, bool  $check, bool  $interactive, InputInterface  $input, OutputInterface  $output) : int
Parameters
$composerFile : string
$composerContents : string
$updatedComposerContents : string
$dryRun : bool
$check : bool
$interactive : bool
$input : InputInterface
$output : OutputInterface
Return values
int

Description

the command status code

handleFundingFile()

Private

Handles .github/FUNDING.yml synchronization reporting and writes.

private handleFundingFile( string  $fundingFile, string|null  $currentFundingContents, string|null  $updatedFundingContents, bool  $dryRun, bool  $check, bool  $interactive, InputInterface  $input, OutputInterface  $output) : int
Parameters
$fundingFile : string
$currentFundingContents : string|null
$updatedFundingContents : string|null
$dryRun : bool
$check : bool
$interactive : bool
$input : InputInterface
$output : OutputInterface
Return values
int

Description

the command status code

normalizeComposerFile()

Private

Normalizes a composer manifest after funding metadata changes.

private normalizeComposerFile( string  $composerFile, OutputInterface  $output) : int
Parameters
$composerFile : string

Description

the composer manifest path

$output : OutputInterface

Description

the command output

Return values
int

Description

the normalization status code

notice()

Private

Logs an informational command message at notice level.

private notice( string  $message, InputInterface  $input[, array<string, mixed>  $context = []]) : void
Parameters
$message : string

Description

the notice message

$input : InputInterface

Description

the originating command input

$context : array<string, mixed> = []

Description

optional extra log context

shouldWriteManagedFile()

Private

Prompts whether a managed file should be written.

private shouldWriteManagedFile( string  $targetFile) : bool
Parameters
$targetFile : string
Return values
bool

Description

true when the write SHOULD proceed

success()

Private

Logs a successful command result and returns the success exit code.

private success( string  $message, InputInterface  $input[, array<string, mixed>  $context = []][, string  $logLevel = LogLevel::INFO]) : int
Parameters
$message : string

Description

the success message

$input : InputInterface

Description

the originating command input

$context : array<string, mixed> = []

Description

optional extra log context

$logLevel : string = LogLevel::INFO

Description

the PSR-3 log level used for the successful result

Return values
int