ShowCommand
extends BaseCommand
in package
Base class for Composer commands
Tags
Table of Contents
- $colors : mixed
- $defaultName : string|null
- $versionParser : VersionParser
- $aliases : mixed
- $application : mixed
- $applicationDefinitionMerged : mixed
- $applicationDefinitionMergedWithArgs : mixed
- $code : mixed
- $composer : Composer|null
- $definition : mixed
- $description : mixed
- $help : mixed
- $helperSet : mixed
- $hidden : mixed
- $ignoreValidationErrors : mixed
- $io : IOInterface
- $name : mixed
- $pool : Pool
- $processTitle : mixed
- $synopsis : mixed
- $usages : mixed
- __construct() : mixed
- addArgument() : $this
- Adds an argument.
- addOption() : $this
- Adds an option.
- addUsage() : $this
- Add a command usage example.
- getAliases() : array<string|int, mixed>
- Returns the aliases for the command.
- getApplication() : Application|null
- Gets the application instance for this command.
- getComposer() : Composer
- getDefaultName() : string|null
- getDefinition() : InputDefinition
- Gets the InputDefinition attached to this Command.
- getDescription() : string
- Returns the description for the command.
- getHelp() : string
- Returns the help for the command.
- getHelper() : mixed
- Gets a helper instance by name.
- getHelperSet() : HelperSet|null
- Gets the helper set.
- getIO() : IOInterface
- getName() : string|null
- Returns the command name.
- getNativeDefinition() : InputDefinition
- Gets the InputDefinition to be used to create representations of this Command.
- getProcessedHelp() : string
- Returns the processed help for the command replacing the %command.name% and %command.full_name% patterns with the real values dynamically.
- getSynopsis() : string
- Returns the synopsis for the command.
- getUsages() : array<string|int, mixed>
- Returns alternative usages of the command.
- ignoreValidationErrors() : mixed
- Ignores validation errors.
- isEnabled() : bool
- Checks whether the command is enabled or not in the current environment.
- isHidden() : bool
- isProxyCommand() : bool
- Whether or not this command is meant to call another command.
- mergeApplicationDefinition() : mixed
- Merges the application definition with the command definition.
- resetComposer() : mixed
- Removes the cached composer instance
- run() : int
- Runs the command.
- setAliases() : $this
- Sets the aliases for the command.
- setApplication() : mixed
- setCode() : $this
- Sets the code to execute when running this command.
- setComposer() : mixed
- setDefinition() : $this
- Sets an array of argument and option instances.
- setDescription() : $this
- Sets the description for the command.
- setHelp() : $this
- Sets the help for the command.
- setHelperSet() : mixed
- setHidden() : Command
- setIO() : mixed
- setName() : $this
- Sets the name of the command.
- setProcessTitle() : $this
- Sets the process title of the command.
- addTree() : array<string|int, mixed>
- Display a package tree
- configure() : mixed
- displayPackageTree() : mixed
- Display the tree
- displayTree() : mixed
- Display a package tree
- execute() : mixed
- generatePackageTree() : array<string|int, mixed>
- Generate the package tree
- getPackage() : array<string|int, mixed>
- finds a package by name and version if provided
- getPreferredInstallOptions() : array<string|int, bool>
- Returns preferSource and preferDist values based on the configuration.
- getRootRequires() : mixed
- getVersionStyle() : mixed
- initialize() : mixed
- Initializes the command after the input has been bound and before the input is validated.
- initStyles() : mixed
- Init styles for tree
- interact() : mixed
- Interacts with the user.
- printLicenses() : mixed
- Prints the licenses of a package with metadata
- printLinks() : mixed
- print link objects
- printMeta() : mixed
- Prints package metadata.
- printPackageInfo() : mixed
- Prints package info.
- printPackageInfoAsJson() : mixed
- Prints package info in JSON format.
- printVersions() : mixed
- Prints all available versions of this package and highlights the installed one if any.
- appendAutoload() : mixed
- appendLicenses() : mixed
- appendLink() : mixed
- appendLinks() : mixed
- appendVersions() : mixed
- findLatestPackage() : PackageInterface|null
- Given a package, this finds the latest package matching it
- getPool() : mixed
- getUpdateStatus() : mixed
- updateStatusToVersionStyle() : mixed
- validateName() : mixed
- Validates a command name.
- writeTreeLine() : mixed
Properties
$colors
protected
mixed
$colors
$defaultName
protected
static string|null
$defaultName
The default command name
$versionParser
protected
VersionParser
$versionParser
$aliases
private
mixed
$aliases
= []
$application
private
mixed
$application
$applicationDefinitionMerged
private
mixed
$applicationDefinitionMerged
= false
$applicationDefinitionMergedWithArgs
private
mixed
$applicationDefinitionMergedWithArgs
= false
$code
private
mixed
$code
$composer
private
Composer|null
$composer
$definition
private
mixed
$definition
$description
private
mixed
$description
= ''
$help
private
mixed
$help
= ''
$helperSet
private
mixed
$helperSet
$hidden
private
mixed
$hidden
= false
$ignoreValidationErrors
private
mixed
$ignoreValidationErrors
= false
$io
private
IOInterface
$io
$name
private
mixed
$name
$pool
private
Pool
$pool
$processTitle
private
mixed
$processTitle
$synopsis
private
mixed
$synopsis
= []
$usages
private
mixed
$usages
= []
Methods
__construct()
public
__construct([string|null $name = null ]) : mixed
Parameters
- $name : string|null = null
-
The name of the command; passing null means it must be set in configure()
Tags
Return values
mixed —addArgument()
Adds an argument.
public
addArgument(string $name[, int|null $mode = null ][, string $description = '' ][, string|array<string|int, string>|null $default = null ]) : $this
Parameters
- $name : string
-
The argument name
- $mode : int|null = null
-
The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
- $description : string = ''
-
A description text
- $default : string|array<string|int, string>|null = null
-
The default value (for InputArgument::OPTIONAL mode only)
Tags
Return values
$this —addOption()
Adds an option.
public
addOption(string $name[, string|array<string|int, mixed>|null $shortcut = null ][, int|null $mode = null ][, string $description = '' ][, string|array<string|int, string>|int|bool|null $default = null ]) : $this
Parameters
- $name : string
-
The option name
- $shortcut : string|array<string|int, mixed>|null = null
-
The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
- $mode : int|null = null
-
The option mode: One of the InputOption::VALUE_* constants
- $description : string = ''
-
A description text
- $default : string|array<string|int, string>|int|bool|null = null
-
The default value (must be null for InputOption::VALUE_NONE)
Tags
Return values
$this —addUsage()
Add a command usage example.
public
addUsage(string $usage) : $this
Parameters
- $usage : string
-
The usage, it'll be prefixed with the command name
Return values
$this —getAliases()
Returns the aliases for the command.
public
getAliases() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of aliases for the command
getApplication()
Gets the application instance for this command.
public
getApplication() : Application|null
Return values
Application|null —An Application instance
getComposer()
public
getComposer([bool $required = true ][, bool|null $disablePlugins = null ]) : Composer
Parameters
- $required : bool = true
- $disablePlugins : bool|null = null
Tags
Return values
Composer —getDefaultName()
public
static getDefaultName() : string|null
Return values
string|null —The default command name or null when no default name is set
getDefinition()
Gets the InputDefinition attached to this Command.
public
getDefinition() : InputDefinition
Return values
InputDefinition —An InputDefinition instance
getDescription()
Returns the description for the command.
public
getDescription() : string
Return values
string —The description for the command
getHelp()
Returns the help for the command.
public
getHelp() : string
Return values
string —The help for the command
getHelper()
Gets a helper instance by name.
public
getHelper(string $name) : mixed
Parameters
- $name : string
-
The helper name
Tags
Return values
mixed —The helper value
getHelperSet()
Gets the helper set.
public
getHelperSet() : HelperSet|null
Return values
HelperSet|null —A HelperSet instance
getIO()
public
getIO() : IOInterface
Return values
IOInterface —getName()
Returns the command name.
public
getName() : string|null
Return values
string|null —getNativeDefinition()
Gets the InputDefinition to be used to create representations of this Command.
public
getNativeDefinition() : InputDefinition
Can be overridden to provide the original command representation when it would otherwise be changed by merging with the application InputDefinition.
This method is not part of public API and should not be used directly.
Return values
InputDefinition —An InputDefinition instance
getProcessedHelp()
Returns the processed help for the command replacing the %command.name% and %command.full_name% patterns with the real values dynamically.
public
getProcessedHelp() : string
Return values
string —The processed help for the command
getSynopsis()
Returns the synopsis for the command.
public
getSynopsis([bool $short = false ]) : string
Parameters
- $short : bool = false
-
Whether to show the short version of the synopsis (with options folded) or not
Return values
string —The synopsis
getUsages()
Returns alternative usages of the command.
public
getUsages() : array<string|int, mixed>
Return values
array<string|int, mixed> —ignoreValidationErrors()
Ignores validation errors.
public
ignoreValidationErrors() : mixed
This is mainly useful for the help command.
Return values
mixed —isEnabled()
Checks whether the command is enabled or not in the current environment.
public
isEnabled() : bool
Override this to check for x or y and return false if the command can not run properly under the current conditions.
Return values
bool —isHidden()
public
isHidden() : bool
Return values
bool —whether the command should be publicly shown or not
isProxyCommand()
Whether or not this command is meant to call another command.
public
isProxyCommand() : bool
This is mainly needed to avoid duplicated warnings messages.
Return values
bool —mergeApplicationDefinition()
Merges the application definition with the command definition.
public
mergeApplicationDefinition([bool $mergeArgs = true ]) : mixed
This method is not part of public API and should not be used directly.
Parameters
- $mergeArgs : bool = true
-
Whether to merge or not the Application definition arguments to Command definition arguments
Return values
mixed —resetComposer()
Removes the cached composer instance
public
resetComposer() : mixed
Return values
mixed —run()
Runs the command.
public
run(InputInterface $input, OutputInterface $output) : int
The code to execute is either defined directly with the setCode() method or by overriding the execute() method in a sub-class.
Parameters
- $input : InputInterface
- $output : OutputInterface
Tags
Return values
int —The command exit code
setAliases()
Sets the aliases for the command.
public
setAliases(array<string|int, string> $aliases) : $this
Parameters
- $aliases : array<string|int, string>
-
An array of aliases for the command
Tags
Return values
$this —setApplication()
public
setApplication([Application $application = null ]) : mixed
Parameters
- $application : Application = null
Return values
mixed —setCode()
Sets the code to execute when running this command.
public
setCode(callable $code) : $this
If this method is used, it overrides the code defined in the execute() method.
Parameters
- $code : callable
-
A callable(InputInterface $input, OutputInterface $output)
Tags
Return values
$this —setComposer()
public
setComposer(Composer $composer) : mixed
Parameters
- $composer : Composer
Return values
mixed —setDefinition()
Sets an array of argument and option instances.
public
setDefinition(array<string|int, mixed>|InputDefinition $definition) : $this
Parameters
- $definition : array<string|int, mixed>|InputDefinition
-
An array of argument and option instances or a definition instance
Return values
$this —setDescription()
Sets the description for the command.
public
setDescription(string $description) : $this
Parameters
- $description : string
-
The description for the command
Return values
$this —setHelp()
Sets the help for the command.
public
setHelp(string $help) : $this
Parameters
- $help : string
-
The help for the command
Return values
$this —setHelperSet()
public
setHelperSet(HelperSet $helperSet) : mixed
Parameters
- $helperSet : HelperSet
Return values
mixed —setHidden()
public
setHidden(bool $hidden) : Command
Parameters
- $hidden : bool
-
Whether or not the command should be hidden from the list of commands
Return values
Command —The current instance
setIO()
public
setIO(IOInterface $io) : mixed
Parameters
- $io : IOInterface
Return values
mixed —setName()
Sets the name of the command.
public
setName(string $name) : $this
This method can set both the namespace and the name if you separate them by a colon (:)
$command->setName('foo:bar');
Parameters
- $name : string
-
The command name
Tags
Return values
$this —setProcessTitle()
Sets the process title of the command.
public
setProcessTitle(string $title) : $this
This feature should be used only when creating a long process command, like a daemon.
Parameters
- $title : string
-
The process title
Return values
$this —addTree()
Display a package tree
protected
addTree(string $name, PackageInterface|string $package, RepositoryInterface $installedRepo, RepositoryInterface $distantRepos, array<string|int, mixed> $packagesInTree) : array<string|int, mixed>
Parameters
- $name : string
- $package : PackageInterface|string
- $installedRepo : RepositoryInterface
- $distantRepos : RepositoryInterface
- $packagesInTree : array<string|int, mixed>
Return values
array<string|int, mixed> —configure()
protected
configure() : mixed
Return values
mixed —displayPackageTree()
Display the tree
protected
displayPackageTree(array<string|int, mixed> $arrayTree) : mixed
Parameters
- $arrayTree : array<string|int, mixed>
Return values
mixed —displayTree()
Display a package tree
protected
displayTree(PackageInterface|string $package, array<string|int, mixed> $packagesInTree[, string $previousTreeBar = '├' ][, int $level = 1 ]) : mixed
Parameters
- $package : PackageInterface|string
- $packagesInTree : array<string|int, mixed>
- $previousTreeBar : string = '├'
- $level : int = 1
Return values
mixed —execute()
protected
execute(InputInterface $input, OutputInterface $output) : mixed
Parameters
- $input : InputInterface
- $output : OutputInterface
Return values
mixed —generatePackageTree()
Generate the package tree
protected
generatePackageTree(PackageInterface $package, RepositoryInterface $installedRepo, RepositoryInterface $distantRepos) : array<string|int, mixed>
Parameters
- $package : PackageInterface
- $installedRepo : RepositoryInterface
- $distantRepos : RepositoryInterface
Return values
array<string|int, mixed> —getPackage()
finds a package by name and version if provided
protected
getPackage(RepositoryInterface $installedRepo, RepositoryInterface $repos, string $name[, ConstraintInterface|string $version = null ]) : array<string|int, mixed>
Parameters
- $installedRepo : RepositoryInterface
- $repos : RepositoryInterface
- $name : string
- $version : ConstraintInterface|string = null
Tags
Return values
array<string|int, mixed> —array(CompletePackageInterface, array of versions)
getPreferredInstallOptions()
Returns preferSource and preferDist values based on the configuration.
protected
getPreferredInstallOptions(Config $config, InputInterface $input[, bool $keepVcsRequiresPreferSource = false ]) : array<string|int, bool>
Parameters
- $config : Config
- $input : InputInterface
- $keepVcsRequiresPreferSource : bool = false
Return values
array<string|int, bool> —An array composed of the preferSource and preferDist values
getRootRequires()
protected
getRootRequires() : mixed
Return values
mixed —getVersionStyle()
protected
getVersionStyle(PackageInterface $latestPackage, PackageInterface $package) : mixed
Parameters
- $latestPackage : PackageInterface
- $package : PackageInterface
Return values
mixed —initialize()
Initializes the command after the input has been bound and before the input is validated.
protected
initialize(InputInterface $input, OutputInterface $output) : mixed
This is mainly useful when a lot of commands extends one main command where some things need to be initialized based on the input arguments and options.
Parameters
- $input : InputInterface
- $output : OutputInterface
Tags
Return values
mixed —initStyles()
Init styles for tree
protected
initStyles(OutputInterface $output) : mixed
Parameters
- $output : OutputInterface
Return values
mixed —interact()
Interacts with the user.
protected
interact(InputInterface $input, OutputInterface $output) : mixed
This method is executed before the InputDefinition is validated. This means that this is the only place where the command can interactively ask for values of missing required arguments.
Parameters
- $input : InputInterface
- $output : OutputInterface
Return values
mixed —printLicenses()
Prints the licenses of a package with metadata
protected
printLicenses(CompletePackageInterface $package) : mixed
Parameters
- $package : CompletePackageInterface
Return values
mixed —printLinks()
print link objects
protected
printLinks(CompletePackageInterface $package, string $linkType[, string $title = null ]) : mixed
Parameters
- $package : CompletePackageInterface
- $linkType : string
- $title : string = null
Return values
mixed —printMeta()
Prints package metadata.
protected
printMeta(CompletePackageInterface $package, array<string|int, mixed> $versions, RepositoryInterface $installedRepo[, PackageInterface|null $latestPackage = null ]) : mixed
Parameters
- $package : CompletePackageInterface
- $versions : array<string|int, mixed>
- $installedRepo : RepositoryInterface
- $latestPackage : PackageInterface|null = null
Return values
mixed —printPackageInfo()
Prints package info.
protected
printPackageInfo(CompletePackageInterface $package, array<string|int, mixed> $versions, RepositoryInterface $installedRepo[, PackageInterface|null $latestPackage = null ]) : mixed
Parameters
- $package : CompletePackageInterface
- $versions : array<string|int, mixed>
- $installedRepo : RepositoryInterface
- $latestPackage : PackageInterface|null = null
Return values
mixed —printPackageInfoAsJson()
Prints package info in JSON format.
protected
printPackageInfoAsJson(CompletePackageInterface $package, array<string|int, mixed> $versions, RepositoryInterface $installedRepo[, PackageInterface|null $latestPackage = null ]) : mixed
Parameters
- $package : CompletePackageInterface
- $versions : array<string|int, mixed>
- $installedRepo : RepositoryInterface
- $latestPackage : PackageInterface|null = null
Return values
mixed —printVersions()
Prints all available versions of this package and highlights the installed one if any.
protected
printVersions(CompletePackageInterface $package, array<string|int, mixed> $versions, RepositoryInterface $installedRepo) : mixed
Parameters
- $package : CompletePackageInterface
- $versions : array<string|int, mixed>
- $installedRepo : RepositoryInterface
Return values
mixed —appendAutoload()
private
appendAutoload(mixed $json, CompletePackageInterface $package) : mixed
Parameters
- $json : mixed
- $package : CompletePackageInterface
Return values
mixed —appendLicenses()
private
appendLicenses(mixed $json, CompletePackageInterface $package) : mixed
Parameters
- $json : mixed
- $package : CompletePackageInterface
Return values
mixed —appendLink()
private
appendLink(mixed $json, CompletePackageInterface $package, mixed $linkType) : mixed
Parameters
- $json : mixed
- $package : CompletePackageInterface
- $linkType : mixed
Return values
mixed —appendLinks()
private
appendLinks(mixed $json, CompletePackageInterface $package) : mixed
Parameters
- $json : mixed
- $package : CompletePackageInterface
Return values
mixed —appendVersions()
private
appendVersions(mixed $json, array<string|int, mixed> $versions) : mixed
Parameters
- $json : mixed
- $versions : array<string|int, mixed>
Return values
mixed —findLatestPackage()
Given a package, this finds the latest package matching it
private
findLatestPackage(PackageInterface $package, Composer $composer, string $phpVersion[, bool $minorOnly = false ]) : PackageInterface|null
Parameters
- $package : PackageInterface
- $composer : Composer
- $phpVersion : string
- $minorOnly : bool = false
Return values
PackageInterface|null —getPool()
private
getPool(Composer $composer) : mixed
Parameters
- $composer : Composer
Return values
mixed —getUpdateStatus()
private
getUpdateStatus(PackageInterface $latestPackage, PackageInterface $package) : mixed
Parameters
- $latestPackage : PackageInterface
- $package : PackageInterface
Return values
mixed —updateStatusToVersionStyle()
private
updateStatusToVersionStyle(mixed $updateStatus) : mixed
Parameters
- $updateStatus : mixed
Return values
mixed —validateName()
Validates a command name.
private
validateName(string $name) : mixed
It must be non-empty and parts can optionally be separated by ":".
Parameters
- $name : string
Tags
Return values
mixed —writeTreeLine()
private
writeTreeLine(mixed $line) : mixed
Parameters
- $line : mixed