Validates YAML files syntax and outputs encountered errors.
- Full name:
\Symfony\Component\Yaml\Command\LintCommand
- Parent class:
\Symfony\Component\Console\Command\Command
private $parser
private ?string $format
private bool $displayCorrectFiles
private ?\Closure $directoryIteratorProvider
private ?\Closure $isReadableProvider
public __construct(string $name = null, callable $directoryIteratorProvider = null, callable $isReadableProvider = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string | The name of the command; passing null means it must be set in configure() |
$directoryIteratorProvider |
callable | |
$isReadableProvider |
callable |
Configures the current command.
protected configure(): mixed
Executes the current command.
protected execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output): int
This method is not abstract because you can use this class as a concrete class. In this case, instead of defining the execute() method, you set the code to execute by passing a Closure to the setCode() method.
Parameters:
Parameter | Type | Description |
---|---|---|
$input |
\Symfony\Component\Console\Input\InputInterface | |
$output |
\Symfony\Component\Console\Output\OutputInterface |
Return Value:
0 if everything went fine, or an exit code
private validate(string $content, int $flags, string $file = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$content |
string | |
$flags |
int | |
$file |
string |
private display(\Symfony\Component\Console\Style\SymfonyStyle $io, array $files): int
Parameters:
Parameter | Type | Description |
---|---|---|
$io |
\Symfony\Component\Console\Style\SymfonyStyle | |
$files |
array |
private displayTxt(\Symfony\Component\Console\Style\SymfonyStyle $io, array $filesInfo, bool $errorAsGithubAnnotations = false): int
Parameters:
Parameter | Type | Description |
---|---|---|
$io |
\Symfony\Component\Console\Style\SymfonyStyle | |
$filesInfo |
array | |
$errorAsGithubAnnotations |
bool |
private displayJson(\Symfony\Component\Console\Style\SymfonyStyle $io, array $filesInfo): int
Parameters:
Parameter | Type | Description |
---|---|---|
$io |
\Symfony\Component\Console\Style\SymfonyStyle | |
$filesInfo |
array |
private getFiles(string $fileOrDirectory): iterable
Parameters:
Parameter | Type | Description |
---|---|---|
$fileOrDirectory |
string |
private getParser(): \Symfony\Component\Yaml\Parser
private getDirectoryIterator(string $directory): iterable
Parameters:
Parameter | Type | Description |
---|---|---|
$directory |
string |
private isReadable(string $fileOrDirectory): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$fileOrDirectory |
string |
Adds suggestions to $suggestions for the current completion input (e.g. option or argument).
public complete(\Symfony\Component\Console\Completion\CompletionInput $input, \Symfony\Component\Console\Completion\CompletionSuggestions $suggestions): void
Parameters:
Parameter | Type | Description |
---|---|---|
$input |
\Symfony\Component\Console\Completion\CompletionInput | |
$suggestions |
\Symfony\Component\Console\Completion\CompletionSuggestions |
public static getDefaultName(): string|null
- This method is static.
public static getDefaultDescription(): ?string
- This method is static.
public __construct(string|null $name = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string|null | The name of the command; passing null means it must be set in configure() |
Ignores validation errors.
public ignoreValidationErrors(): mixed
This is mainly useful for the help command.
public setApplication(\Symfony\Component\Console\Application $application = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$application |
\Symfony\Component\Console\Application |
public setHelperSet(\Symfony\Component\Console\Helper\HelperSet $helperSet): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$helperSet |
\Symfony\Component\Console\Helper\HelperSet |
Gets the helper set.
public getHelperSet(): \Symfony\Component\Console\Helper\HelperSet|null
Gets the application instance for this command.
public getApplication(): \Symfony\Component\Console\Application|null
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 cannot run properly under the current conditions.
Configures the current command.
protected configure(): mixed
Executes the current command.
protected execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output): int
This method is not abstract because you can use this class as a concrete class. In this case, instead of defining the execute() method, you set the code to execute by passing a Closure to the setCode() method.
Parameters:
Parameter | Type | Description |
---|---|---|
$input |
\Symfony\Component\Console\Input\InputInterface | |
$output |
\Symfony\Component\Console\Output\OutputInterface |
Return Value:
0 if everything went fine, or an exit code
See Also:
- \Symfony\Component\Console\Command\setCode() -
Interacts with the user.
protected interact(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\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:
Parameter | Type | Description |
---|---|---|
$input |
\Symfony\Component\Console\Input\InputInterface | |
$output |
\Symfony\Component\Console\Output\OutputInterface |
Initializes the command after the input has been bound and before the input is validated.
protected initialize(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\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:
Parameter | Type | Description |
---|---|---|
$input |
\Symfony\Component\Console\Input\InputInterface | |
$output |
\Symfony\Component\Console\Output\OutputInterface |
See Also:
- \Symfony\Component\Console\Input\InputInterface::bind() - * \Symfony\Component\Console\Input\InputInterface::validate() -
Runs the command.
public run(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\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:
Parameter | Type | Description |
---|---|---|
$input |
\Symfony\Component\Console\Input\InputInterface | |
$output |
\Symfony\Component\Console\Output\OutputInterface |
Return Value:
The command exit code
See Also:
- \Symfony\Component\Console\Command\setCode() - * \Symfony\Component\Console\Command\execute() -
Adds suggestions to $suggestions for the current completion input (e.g. option or argument).
public complete(\Symfony\Component\Console\Completion\CompletionInput $input, \Symfony\Component\Console\Completion\CompletionSuggestions $suggestions): void
Parameters:
Parameter | Type | Description |
---|---|---|
$input |
\Symfony\Component\Console\Completion\CompletionInput | |
$suggestions |
\Symfony\Component\Console\Completion\CompletionSuggestions |
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:
Parameter | Type | Description |
---|---|---|
$code |
callable | A callable(InputInterface $input, OutputInterface $output) |
See Also:
- \Symfony\Component\Console\Command\execute() -
Sets an array of argument and option instances.
public setDefinition(array|\Symfony\Component\Console\Input\InputDefinition $definition): $this
Parameters:
Parameter | Type | Description |
---|---|---|
$definition |
array|\Symfony\Component\Console\Input\InputDefinition | An array of argument and option instances or a definition instance |
Gets the InputDefinition attached to this Command.
public getDefinition(): \Symfony\Component\Console\Input\InputDefinition
Gets the InputDefinition to be used to create representations of this Command.
public getNativeDefinition(): \Symfony\Component\Console\Input\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.
Adds an argument.
public addArgument(string $name, int|null $mode = null, string $description = '', mixed $default = null): $this
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string | |
$mode |
int|null | The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL |
$description |
string | |
$default |
mixed | The default value (for InputArgument::OPTIONAL mode only) |
Adds an option.
public addOption(string $name, string|array|null $shortcut = null, int|null $mode = null, string $description = '', mixed $default = null): $this
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string | |
$shortcut |
string|array|null | The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts |
$mode |
int|null | The option mode: One of the InputOption::VALUE_* constants |
$description |
string | |
$default |
mixed | The default value (must be null for InputOption::VALUE_NONE) |
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:
Parameter | Type | Description |
---|---|---|
$name |
string |
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:
Parameter | Type | Description |
---|---|---|
$title |
string |
Returns the command name.
public getName(): string|null
setHidden
public setHidden(bool $hidden): $this
Parameters:
Parameter | Type | Description |
---|---|---|
$hidden |
bool | Whether or not the command should be hidden from the list of commands The default value will be true in Symfony 6.0 |
isHidden
public isHidden(): bool
Return Value:
whether the command should be publicly shown or not
Sets the description for the command.
public setDescription(string $description): $this
Parameters:
Parameter | Type | Description |
---|---|---|
$description |
string |
Returns the description for the command.
public getDescription(): string
Sets the help for the command.
public setHelp(string $help): $this
Parameters:
Parameter | Type | Description |
---|---|---|
$help |
string |
Returns the help for the command.
public getHelp(): string
Returns the processed help for the command replacing the %command.name% and %command.full_name% patterns with the real values dynamically.
public getProcessedHelp(): string
Sets the aliases for the command.
public setAliases(string[] $aliases): $this
Parameters:
Parameter | Type | Description |
---|---|---|
$aliases |
string[] | An array of aliases for the command |
Returns the aliases for the command.
public getAliases(): array
Returns the synopsis for the command.
public getSynopsis(bool $short = false): string
Parameters:
Parameter | Type | Description |
---|---|---|
$short |
bool | Whether to show the short version of the synopsis (with options folded) or not |
Add a command usage example, it'll be prefixed with the command name.
public addUsage(string $usage): $this
Parameters:
Parameter | Type | Description |
---|---|---|
$usage |
string |
Returns alternative usages of the command.
public getUsages(): array
Gets a helper instance by name.
public getHelper(string $name): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string |
Validates a command name.
private validateName(string $name): mixed
It must be non-empty and parts can optionally be separated by ":".
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string |