UpdateComposerJsonCommand

Class
extends BaseCommand
Final: Yes

Updates composer.json with the Fast Forward dev-tools integration metadata.

Attributes
#[AsCommand]
$name : 'update-composer-json'
$description : 'Updates composer.json with Fast Forward dev-tools scripts and metadata.'
$help : 'This command adds or updates composer.json scripts and GrumPHP extra configuration required by dev-tools.'

Table of Contents

Interfaces

LoggerAwareCommandInterface

Defines the logger contract consumed by reusable command result helpers.

Properties

Methods

__construct()

Creates a new UpdateComposerJsonCommand instance.

 : mixed
addJsonOption()

Adds the standard JSON output options to the current command.

 : static
configure()

Configures the composer file option.

 : void
execute()

Updates composer.json when the target file exists.

 : 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
notice()

Logs an informational command message at notice level.

 : void
scripts()

Returns the Composer scripts managed by this command.

 : array<string, string>
shouldUpdateComposerJson()

Prompts whether composer.json should be updated.

 : bool
success()

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

 : int
Properties
Methods

__construct()

Public

Creates a new UpdateComposerJsonCommand instance.

public __construct(ComposerJsonInterface  $composer, FilesystemInterface  $filesystem, FileLocatorInterface  $fileLocator, FileDiffer  $fileDiffer, LoggerInterface  $logger) : mixed
Parameters
$composer : ComposerJsonInterface

Description

the composer.json metadata accessor

$filesystem : FilesystemInterface

Description

the filesystem used to read and write composer.json

$fileLocator : FileLocatorInterface

Description

the locator used to resolve packaged configuration files

$fileDiffer : FileDiffer
$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

execute()

Protected

Updates composer.json when the target file exists.

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

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

scripts()

Private

Returns the Composer scripts managed by this command.

private scripts() : array<string, string>
Return values
array<string, string>

Description

the script name to command map

shouldUpdateComposerJson()

Private

Prompts whether composer.json should be updated.

private shouldUpdateComposerJson( string  $file) : bool
Parameters
$file : string

Description

the composer.json path that would be updated

Return values
bool

Description

true when the update 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