StringInput represents an input provided as a string.
Usage:
$input = new StringInput('foo --bar="foobar"');
- Full name:
\Symfony\Component\Console\Input\StringInput
- Parent class:
\Symfony\Component\Console\Input\ArgvInput
Constant | Visibility | Type | Value |
---|---|---|---|
REGEX_STRING |
public | '([^\\s]+?)(?:\s | |
REGEX_UNQUOTED_STRING |
public | '([^\\s\\\\]+?)' | |
REGEX_QUOTED_STRING |
public | '(?:"([^"\\\\](?:\\.[^"\\\\])*)" |
public __construct(string $input): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$input |
string | A string representing the parameters from the CLI |
Tokenizes a string.
private tokenize(string $input): array
Parameters:
Parameter | Type | Description |
---|---|---|
$input |
string |
public __construct(\Symfony\Component\Console\Input\InputDefinition $definition = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$definition |
\Symfony\Component\Console\Input\InputDefinition |
protected setTokens(array $tokens): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$tokens |
array |
Processes command line arguments.
protected parse(): mixed
- This method is abstract.
protected parseToken(string $token, bool $parseOptions): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$token |
string | |
$parseOptions |
bool |
Parses a short option.
private parseShortOption(string $token): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$token |
string |
Parses a short option set.
private parseShortOptionSet(string $name): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string |
Parses a long option.
private parseLongOption(string $token): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$token |
string |
Parses an argument.
private parseArgument(string $token): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$token |
string |
Adds a short option value.
private addShortOption(string $shortcut, mixed $value): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$shortcut |
string | |
$value |
mixed |
Adds a long option value.
private addLongOption(string $name, mixed $value): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string | |
$value |
mixed |
{@inheritdoc}
public getFirstArgument(): mixed
{@inheritdoc}
public hasParameterOption(mixed $values, bool $onlyParams = false): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$values |
mixed | |
$onlyParams |
bool |
{@inheritdoc}
public getParameterOption(mixed $values, mixed $default = false, bool $onlyParams = false): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$values |
mixed | |
$default |
mixed | |
$onlyParams |
bool |
Returns a stringified representation of the args passed to the command.
public __toString(): string
Binds the current Input instance with the given arguments and options.
public bind(\Symfony\Component\Console\Input\InputDefinition $definition): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$definition |
\Symfony\Component\Console\Input\InputDefinition |
Validates the input.
public validate(): mixed
Is this input means interactive?
public isInteractive(): bool
Sets the input interactivity.
public setInteractive(bool $interactive): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$interactive |
bool |
Returns all the given arguments merged with the default values.
public getArguments(): (string|bool|int|float|array|null)[]
Returns the argument value for a given argument name.
public getArgument(string $name): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string |
Sets an argument value by name.
public setArgument(string $name, mixed $value): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string | |
$value |
mixed | The argument value |
Returns true if an InputArgument object exists by name or position.
public hasArgument(string $name): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string |
Returns all the given options merged with the default values.
public getOptions(): (string|bool|int|float|array|null)[]
Returns the option value for a given option name.
public getOption(string $name): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string |
Sets an option value by name.
public setOption(string $name, mixed $value): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string | |
$value |
mixed | The option value |
Returns true if an InputOption object exists by name.
public hasOption(string $name): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string |
Escapes a token through escapeshellarg if it contains unsafe chars.
public escapeToken(string $token): string
Parameters:
Parameter | Type | Description |
---|---|---|
$token |
string |
Sets the input stream to read from when interacting with the user.
public setStream(mixed $stream): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$stream |
mixed | The input stream |
Returns the input stream.
public getStream(): resource|null