InputOption
in package
Represents a command line option.
Tags
Table of Contents
Constants
- VALUE_IS_ARRAY = 8
- The option accepts multiple values (e.g. --dir=/foo --dir=/bar).
- VALUE_NEGATABLE = 16
- The option may have either positive or negative value (e.g. --ansi or --no-ansi).
- VALUE_NONE = 1
- Do not accept input for the option (e.g. --yell). This is the default behavior of options.
- VALUE_OPTIONAL = 4
- The option may or may not have a value (e.g. --yell or --yell=loud).
- VALUE_REQUIRED = 2
- A value must be passed when the option is used (e.g. --iterations=5 or -i5).
Properties
- $default : string|int|bool|array<string|int, mixed>|null|float
- $description : string
- $mode : int
- $name : string
- $shortcut : string|array<string|int, mixed>|null
- $suggestedValues : array<string|int, mixed>|Closure
Methods
- __construct() : mixed
- acceptValue() : bool
- Returns true if the option accepts a value.
- complete() : void
- Adds suggestions to $suggestions for the current completion input.
- equals() : bool
- Checks whether the given option equals this one.
- getDefault() : string|bool|int|float|array<string|int, mixed>|null
- Returns the default value.
- getDescription() : string
- Returns the description text.
- getName() : string
- Returns the option name.
- getShortcut() : string|null
- Returns the option shortcut.
- hasCompletion() : bool
- isArray() : bool
- Returns true if the option can take multiple values.
- isNegatable() : bool
- isValueOptional() : bool
- Returns true if the option takes an optional value.
- isValueRequired() : bool
- Returns true if the option requires a value.
- setDefault() : void
Constants
VALUE_IS_ARRAY
The option accepts multiple values (e.g. --dir=/foo --dir=/bar).
public
mixed
VALUE_IS_ARRAY
= 8
VALUE_NEGATABLE
The option may have either positive or negative value (e.g. --ansi or --no-ansi).
public
mixed
VALUE_NEGATABLE
= 16
VALUE_NONE
Do not accept input for the option (e.g. --yell). This is the default behavior of options.
public
mixed
VALUE_NONE
= 1
VALUE_OPTIONAL
The option may or may not have a value (e.g. --yell or --yell=loud).
public
mixed
VALUE_OPTIONAL
= 4
VALUE_REQUIRED
A value must be passed when the option is used (e.g. --iterations=5 or -i5).
public
mixed
VALUE_REQUIRED
= 2
Properties
$default
private
string|int|bool|array<string|int, mixed>|null|float
$default
$description
private
string
$description
$mode
private
int
$mode
$name
private
string
$name
$shortcut
private
string|array<string|int, mixed>|null
$shortcut
$suggestedValues
private
array<string|int, mixed>|Closure
$suggestedValues
Methods
__construct()
public
__construct(string $name[, string|array<string|int, mixed>|null $shortcut = null ][, int|null $mode = null ][, string $description = '' ][, string|bool|int|float|array<string|int, mixed>|null $default = null ][, array<string|int, mixed>|callable(CompletionInput, CompletionSuggestions): array<int, string|Suggestion> $suggestedValues = [] ]) : mixed
Parameters
- $name : string
- $shortcut : string|array<string|int, mixed>|null = null
-
The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
- $mode : int|null = null
-
The option mode: One of the VALUE_* constants
- $description : string = ''
- $default : string|bool|int|float|array<string|int, mixed>|null = null
-
The default value (must be null for self::VALUE_NONE)
- $suggestedValues : array<string|int, mixed>|callable(CompletionInput, CompletionSuggestions): array<int, string|Suggestion> = []
-
The values used for input completion
Tags
acceptValue()
Returns true if the option accepts a value.
public
acceptValue() : bool
Return values
bool —true if value mode is not self::VALUE_NONE, false otherwise
complete()
Adds suggestions to $suggestions for the current completion input.
public
complete(CompletionInput $input, CompletionSuggestions $suggestions) : void
Parameters
- $input : CompletionInput
- $suggestions : CompletionSuggestions
Tags
equals()
Checks whether the given option equals this one.
public
equals(self $option) : bool
Parameters
- $option : self
Return values
boolgetDefault()
Returns the default value.
public
getDefault() : string|bool|int|float|array<string|int, mixed>|null
Return values
string|bool|int|float|array<string|int, mixed>|nullgetDescription()
Returns the description text.
public
getDescription() : string
Return values
stringgetName()
Returns the option name.
public
getName() : string
Return values
stringgetShortcut()
Returns the option shortcut.
public
getShortcut() : string|null
Return values
string|nullhasCompletion()
public
hasCompletion() : bool
Return values
boolisArray()
Returns true if the option can take multiple values.
public
isArray() : bool
Return values
bool —true if mode is self::VALUE_IS_ARRAY, false otherwise
isNegatable()
public
isNegatable() : bool
Return values
boolisValueOptional()
Returns true if the option takes an optional value.
public
isValueOptional() : bool
Return values
bool —true if value mode is self::VALUE_OPTIONAL, false otherwise
isValueRequired()
Returns true if the option requires a value.
public
isValueRequired() : bool
Return values
bool —true if value mode is self::VALUE_REQUIRED, false otherwise
setDefault()
public
setDefault([string|bool|int|float|array<string|int, mixed>|null $default = null ]) : void
Parameters
- $default : string|bool|int|float|array<string|int, mixed>|null = null