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),

]);

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

Adds an array of InputArgument objects.

public addOption ( Symfony\Component\Console\Input\InputOption $option )
 
  • throws LogicException When option given already exist
public addOptions ( array $options = [ ] )
 

Adds 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.

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.

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 = [ ] )
 

Sets the InputArgument objects.

public setDefinition ( array $definition )
 

Sets the definition of the input.

public setOptions ( array $options = [ ] )
 

Sets the 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
private Symfony\Component\Console\Input\InputArgument $lastOptionalArgument
private array $negations
private array $options
private int $requiredCount
private array $shortcuts
© 2022 Bruce Wells
Search Namespaces \ Classes
Configuration