Copied!

Represents a command line option.

CloneableInstantiable
Constants
public Symfony\Component\Console\Input\InputOption::VALUE_IS_ARRAY = 8
 

The option accepts multiple values (e.g. --dir=/foo --dir=/bar).

public Symfony\Component\Console\Input\InputOption::VALUE_NEGATABLE = 16
 

The option allows passing a negated variant (e.g. --ansi or --no-ansi).

public Symfony\Component\Console\Input\InputOption::VALUE_NONE = 1
 

Do not accept input for the option (e.g. --yell). This is the default behavior of options.

public Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL = 4
 

The option may or may not have a value (e.g. --yell or --yell=loud).

public Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED = 2
 

A value must be passed when the option is used (e.g. --iterations=5 or -i5).

Methods
public __construct(string $name, array|string|?null $shortcut = NULL, ?int $mode = NULL, string $description = '', array|string|int|float|bool|?null $default = NULL, Closure|array $suggestedValues = [])
 
  • param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
  • param string|bool|int|float|array|null $default The default value (must be null for self::VALUE_NONE)
  • param array|callable $suggestedValues The values used for input completion
  • throws \InvalidArgumentException If option mode is invalid or incompatible
public acceptValue() : bool
 

Returns true if the option accepts a value.

  • return bool true if value mode is not self::VALUE_NONE, false otherwise
public complete(Symfony\Component\Console\Completion\CompletionInput $input, Symfony\Component\Console\Completion\CompletionSuggestions $suggestions) : void
 

Supplies suggestions when command resolves possible completion options for input.

  • see \Command::complete()
public equals(self $option) : bool
 

Checks whether the given option equals this one.

public getDefault() : array|string|int|float|bool|?null
 

Returns the default value.

public getDescription() : string
 

Returns the description text.

public getName() : string
 

Returns the option name.

public getShortcut() : ?string
 

Returns the option shortcut.

public hasCompletion() : bool
 

Returns true if the option has values for input completion.

public isArray() : bool
 

Returns true if the option can take multiple values.

  • return bool true if mode is self::VALUE_IS_ARRAY, false otherwise
public isNegatable() : bool
 

Returns true if the option allows passing a negated variant.

  • return bool true if mode is self::VALUE_NEGATABLE, false otherwise
public isValueOptional() : bool
 

Returns true if the option takes an optional value.

  • return bool true if value mode is self::VALUE_OPTIONAL, false otherwise
public isValueRequired() : bool
 

Returns true if the option requires a value.

  • return bool true if value mode is self::VALUE_REQUIRED, false otherwise
public setDefault(array|string|int|float|bool|?null $default) : void
 

Sets the default value.

Properties
private array|string|int|float|bool|?null $default
private string $description
private int $mode
private string $name
private ?string $shortcut
private Closure|array $suggestedValues
© 2025 Bruce Wells
Search Namespaces \ Classes
Configuration