Copied!

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
CloneableInstantiable
Methods
public __construct(?array $argv = NULL, ?Symfony\Component\Console\Input\InputDefinition $definition = NULL)
 
  • param list<string>|null $argv
public __toString() : string
 

Returns a stringified representation of the args passed to the command.

public Symfony\Component\Console\Input\Input::bind(Symfony\Component\Console\Input\InputDefinition $definition) : void
public Symfony\Component\Console\Input\Input::escapeToken(string $token) : string
 

Escapes a token through escapeshellarg if it contains unsafe chars.

public Symfony\Component\Console\Input\Input::getArgument(string $name) : ?mixed
public Symfony\Component\Console\Input\Input::getArguments() : array
public getFirstArgument() : ?string
public Symfony\Component\Console\Input\Input::getOption(string $name) : ?mixed
public Symfony\Component\Console\Input\Input::getOptions() : array
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.

  • param bool $strip Whether to return the raw parameters (false) or the values after the command name (true)
  • return list<string>
public Symfony\Component\Console\Input\Input::getStream()
 
  • return resource
public Symfony\Component\Console\Input\Input::hasArgument(string $name) : bool
public Symfony\Component\Console\Input\Input::hasOption(string $name) : bool
public hasParameterOption(array|string $values, bool $onlyParams = false) : bool
public Symfony\Component\Console\Input\Input::isInteractive() : bool
public Symfony\Component\Console\Input\Input::setArgument(string $name, ?mixed $value) : void
public Symfony\Component\Console\Input\Input::setInteractive(bool $interactive) : void
public Symfony\Component\Console\Input\Input::setOption(string $name, ?mixed $value) : void
public Symfony\Component\Console\Input\Input::setStream( $stream) : void
 
  • param resource $stream
public Symfony\Component\Console\Input\Input::validate() : void
Properties
protected array Symfony\Component\Console\Input\Input::$arguments = []
protected Symfony\Component\Console\Input\InputDefinition Symfony\Component\Console\Input\Input::$definition
protected bool Symfony\Component\Console\Input\Input::$interactive = true
protected array Symfony\Component\Console\Input\Input::$options = []
protected Symfony\Component\Console\Input\Input::$stream = NULL
 
  • var resource
Methods
protected parse() : void
protected parseToken(string $token, bool $parseOptions) : bool
protected setTokens(array $tokens) : void
 
  • param list<string> $tokens
Properties
private array $parsed
private array $tokens
 
  • var list<string>
Methods
private addLongOption(string $name, ?mixed $value) : void
 

Adds a long option value.

  • throws \RuntimeException When option given doesn't exist
private addShortOption(string $shortcut, ?mixed $value) : void
 

Adds a short option value.

  • throws \RuntimeException When option given doesn't exist
private parseArgument(string $token) : void
 

Parses an argument.

  • throws \RuntimeException When too many arguments are given
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.

  • throws \RuntimeException When option given doesn't exist
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration