Skip to content

Latest commit

 

History

History
799 lines (299 loc) · 7.68 KB

File metadata and controls

799 lines (299 loc) · 7.68 KB

StringInput

StringInput represents an input provided as a string.

Usage:

$input = new StringInput('foo --bar="foobar"');

Constants

Constant Visibility Type Value
REGEX_STRING public '([^\\s]+?)(?:\s
REGEX_UNQUOTED_STRING public '([^\\s\\\\]+?)'
REGEX_QUOTED_STRING public '(?:"([^"\\\\](?:\\.[^"\\\\])*)"

Methods

__construct

public __construct(string $input): mixed

Parameters:

Parameter Type Description
$input string A string representing the parameters from the CLI

tokenize

Tokenizes a string.

private tokenize(string $input): array

Parameters:

Parameter Type Description
$input string

Inherited methods

__construct

public __construct(\Symfony\Component\Console\Input\InputDefinition $definition = null): mixed

Parameters:

Parameter Type Description
$definition \Symfony\Component\Console\Input\InputDefinition

setTokens

protected setTokens(array $tokens): mixed

Parameters:

Parameter Type Description
$tokens array

parse

Processes command line arguments.

protected parse(): mixed
  • This method is abstract.

parseToken

protected parseToken(string $token, bool $parseOptions): bool

Parameters:

Parameter Type Description
$token string
$parseOptions bool

parseShortOption

Parses a short option.

private parseShortOption(string $token): mixed

Parameters:

Parameter Type Description
$token string

parseShortOptionSet

Parses a short option set.

private parseShortOptionSet(string $name): mixed

Parameters:

Parameter Type Description
$name string

parseLongOption

Parses a long option.

private parseLongOption(string $token): mixed

Parameters:

Parameter Type Description
$token string

parseArgument

Parses an argument.

private parseArgument(string $token): mixed

Parameters:

Parameter Type Description
$token string

addShortOption

Adds a short option value.

private addShortOption(string $shortcut, mixed $value): mixed

Parameters:

Parameter Type Description
$shortcut string
$value mixed

addLongOption

Adds a long option value.

private addLongOption(string $name, mixed $value): mixed

Parameters:

Parameter Type Description
$name string
$value mixed

getFirstArgument

{@inheritdoc}

public getFirstArgument(): mixed

hasParameterOption

{@inheritdoc}

public hasParameterOption(mixed $values, bool $onlyParams = false): mixed

Parameters:

Parameter Type Description
$values mixed
$onlyParams bool

getParameterOption

{@inheritdoc}

public getParameterOption(mixed $values, mixed $default = false, bool $onlyParams = false): mixed

Parameters:

Parameter Type Description
$values mixed
$default mixed
$onlyParams bool

__toString

Returns a stringified representation of the args passed to the command.

public __toString(): string

bind

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

validate

Validates the input.

public validate(): mixed

isInteractive

Is this input means interactive?

public isInteractive(): bool

setInteractive

Sets the input interactivity.

public setInteractive(bool $interactive): mixed

Parameters:

Parameter Type Description
$interactive bool

getArguments

Returns all the given arguments merged with the default values.

public getArguments(): (string|bool|int|float|array|null)[]

getArgument

Returns the argument value for a given argument name.

public getArgument(string $name): mixed

Parameters:

Parameter Type Description
$name string

setArgument

Sets an argument value by name.

public setArgument(string $name, mixed $value): mixed

Parameters:

Parameter Type Description
$name string
$value mixed The argument value

hasArgument

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

public hasArgument(string $name): bool

Parameters:

Parameter Type Description
$name string

getOptions

Returns all the given options merged with the default values.

public getOptions(): (string|bool|int|float|array|null)[]

getOption

Returns the option value for a given option name.

public getOption(string $name): mixed

Parameters:

Parameter Type Description
$name string

setOption

Sets an option value by name.

public setOption(string $name, mixed $value): mixed

Parameters:

Parameter Type Description
$name string
$value mixed The option value

hasOption

Returns true if an InputOption object exists by name.

public hasOption(string $name): bool

Parameters:

Parameter Type Description
$name string

escapeToken

Escapes a token through escapeshellarg if it contains unsafe chars.

public escapeToken(string $token): string

Parameters:

Parameter Type Description
$token string

setStream

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

getStream

Returns the input stream.

public getStream(): resource|null