ArgvInput represents an input coming from the CLI arguments.
Usage:
$input = new ArgvInput();
By default, the $_SERVER['argv']
array is used for the input values.
This can be overridden by explicitly passing the input values in the constructor:
$input = new ArgvInput($_SERVER['argv']);
If you pass it yourself, don't forget that the first element of the array is the name of the running application.
When passing an argument to the constructor, be sure that it respects
the same rules as the argv one. It's almost always better to use the
StringInput
when you want to provide your own input.
- author Fabien Potencier
- see http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html
- see http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html#tag_12_02
Methods |
public __construct(?array $argv = NULL, ?Symfony
|
public __toString() : string Returns a stringified representation of the args passed to the command. |
public getFirstArgument() : ?string |
public getParameterOption(array|string $values, array|string|int|float|bool|?null $default = false, bool $onlyParams = false) : ?mixed |
public getRawTokens(bool $strip = false) : array Returns un-parsed and not validated tokens.
|
public hasParameterOption(array|string $values, bool $onlyParams = false) : bool |
Properties |
Methods |
protected parse() : void |
protected parseToken(string $token, bool $parseOptions) : bool |
protected setTokens(array $tokens) : void
|
Properties |
private array $parsed |
private array $tokens
|
Methods |
private addLongOption(string $name, ?mixed $value) : void Adds a long option value.
|
private addShortOption(string $shortcut, ?mixed $value) : void Adds a short option value.
|
private parseArgument(string $token) : void Parses an argument.
|
private parseLongOption(string $token) : void Parses a long option. |
private parseShortOption(string $token) : void Parses a short option. |
private parseShortOptionSet(string $name) : void Parses a short option set.
|