Argument
in package
FinalYes
Represents a console command <argument> definition.
Can be used in the parameters of the invoke method.
#[AsCommand(name: 'app:user:created')
class CreateUserCommand {
public function __invoke(
#[Argument(description: "The username of the user")] string $userId,
IOutput $output,
): ExitCode {
// ...
return ExitCode::Success;
}
}
Or on methods parameters:
class UserCommands {
#[AsCommand('app:user:create')]
public function create(
#[Argument(description: "The username of the user")] string $userId,
IOutput $output,
): ExitCode {
// ...
return ExitCode::Success;
}
#[AsCommand('app:user:delete')]
public function delete(
#[Argument(description: "The username of the user")] string $userId,
IOutput $output,
): ExitCode {
// ...
return ExitCode::Success;
}
}
Tags
Attributes
- #[Attribute]
- \Attribute::TARGET_PARAMETER
- #[Consumable]
- $since: '35.0.0'
Table of Contents
Properties
- $description : string
- $name : string
- $suggestedValues : array<string|int, mixed>|Closure
Methods
- __construct() : mixed
- If unset, the `name` value will be inferred from the parameter definition.
Properties
$description
public
string
$description
= ''
$name
public
string
$name
= ''
$suggestedValues
public
array<string|int, mixed>|Closure
$suggestedValues
= []
Methods
__construct()
If unset, the `name` value will be inferred from the parameter definition.
public
__construct([string $description = '' ][, string $name = '' ][, array<string|int, mixed>|Closure $suggestedValues = [] ]) : mixed
Parameters
- $description : string = ''
-
The description of the argument, displayed with the help page
- $name : string = ''
-
The name of the argument
- $suggestedValues : array<string|int, mixed>|Closure = []
-
An array or a closure that provides suggested values for the argument.