Copied!

A InputDefinition represents a set of valid command line arguments and options.

Usage:

$definition = new InputDefinition([ new InputArgument('name', InputArgument::REQUIRED), new InputOption('foo', 'f', InputOption::VALUE_REQUIRED), ]);

CloneableInstantiable
Methods
public __construct(array $definition = [])
 
  • param array $definition An array of InputArgument and InputOption instance
public addArgument(Symfony\Component\Console\Input\InputArgument $argument) : void
 
  • throws \LogicException When incorrect argument is given
public addArguments(?array $arguments = []) : void
 

Adds an array of InputArgument objects.

  • param \InputArgument[] $arguments An array of InputArgument objects
public addOption(Symfony\Component\Console\Input\InputOption $option) : void
 
  • throws \LogicException When option given already exist
public addOptions(array $options = []) : void
 

Adds an array of InputOption objects.

  • param \InputOption[] $options An array of InputOption objects
public getArgument(string|int $name) : Symfony\Component\Console\Input\InputArgument
 

Returns an InputArgument by name or by position.

  • throws \InvalidArgumentException When argument given doesn't exist
public getArgumentCount() : int
 

Returns the number of InputArguments.

public getArgumentDefaults() : array
 
  • return (string|bool|int|float|array|null)[]
public getArgumentRequiredCount() : int
 

Returns the number of required InputArguments.

public getArguments() : array
 

Gets the array of InputArgument objects.

  • return \InputArgument[]
public getOption(string $name) : Symfony\Component\Console\Input\InputOption
 

Returns an InputOption by name.

  • throws \InvalidArgumentException When option given doesn't exist
public getOptionDefaults() : array
 
  • return (string|bool|int|float|array|null)[]
public getOptionForShortcut(string $shortcut) : Symfony\Component\Console\Input\InputOption
 

Gets an InputOption by shortcut.

public getOptions() : array
 

Gets the array of InputOption objects.

  • return \InputOption[]
public getSynopsis(bool $short = false) : string
 

Gets the synopsis.

public hasArgument(string|int $name) : bool
 

Returns true if an InputArgument object exists by name or position.

public hasNegation(string $name) : bool
 

Returns true if an InputOption object exists by negated name.

public hasOption(string $name) : bool
 

Returns true if an InputOption object exists by name.

This method can't be used to check if the user included the option when executing the command (use getOption() instead).

public hasShortcut(string $name) : bool
 

Returns true if an InputOption object exists by shortcut.

public negationToName(string $negation) : string
 

Returns the InputOption name given a negation.

  • throws \InvalidArgumentException When option given does not exist
  • internal
public setArguments(array $arguments = []) : void
 

Sets the InputArgument objects.

  • param \InputArgument[] $arguments An array of InputArgument objects
public setDefinition(array $definition) : void
 

Sets the definition of the input.

public setOptions(array $options = []) : void
 

Sets the InputOption objects.

  • param \InputOption[] $options An array of InputOption objects
public shortcutToName(string $shortcut) : string
 

Returns the InputOption name given a shortcut.

  • throws \InvalidArgumentException When option given does not exist
  • internal
Properties
private array $arguments = []
private ?Symfony\Component\Console\Input\InputArgument $lastArrayArgument = NULL
private ?Symfony\Component\Console\Input\InputArgument $lastOptionalArgument = NULL
private array $negations = []
private array $options = []
private int $requiredCount = 0
private array $shortcuts = []
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration