Documentation

CodeArgument extends InputArgument
in package

An input argument for code.

A CodeArgument must be the final argument of the command. Once all options and other arguments are used, any remaining input until the end of the string is considered part of a single CodeArgument, regardless of spaces, quoting, escaping, etc.

This means commands can support crazy input like

parse function() { return "wheee\n"; }

... without having to put the code in a quoted string and escape everything.

Table of Contents

IS_ARRAY  = 4
OPTIONAL  = 2
REQUIRED  = 1
$default  : mixed
$description  : mixed
$mode  : mixed
$name  : mixed
__construct()  : mixed
Constructor.
getDefault()  : string|array<string|int, string>|null
Returns the default value.
getDescription()  : string
Returns the description text.
getName()  : string
Returns the argument name.
isArray()  : bool
Returns true if the argument can take multiple values.
isRequired()  : bool
Returns true if the argument is required.
setDefault()  : mixed
Sets the default value.

Constants

Properties

Methods

__construct()

Constructor.

public __construct(string $name[, int $mode = null ][, string $description = '' ][, mixed $default = null ]) : mixed
Parameters
$name : string

The argument name

$mode : int = null

The argument mode: self::REQUIRED or self::OPTIONAL

$description : string = ''

A description text

$default : mixed = null

The default value (for self::OPTIONAL mode only)

Tags
throws
InvalidArgumentException

When argument mode is not valid

Return values
mixed

getDefault()

Returns the default value.

public getDefault() : string|array<string|int, string>|null
Return values
string|array<string|int, string>|null

The default value

getDescription()

Returns the description text.

public getDescription() : string
Return values
string

The description text

getName()

Returns the argument name.

public getName() : string
Return values
string

The argument name

isArray()

Returns true if the argument can take multiple values.

public isArray() : bool
Return values
bool

true if mode is self::IS_ARRAY, false otherwise

isRequired()

Returns true if the argument is required.

public isRequired() : bool
Return values
bool

true if parameter mode is self::REQUIRED, false otherwise

setDefault()

Sets the default value.

public setDefault([string|array<string|int, string>|null $default = null ]) : mixed
Parameters
$default : string|array<string|int, string>|null = null

The default value

Tags
throws
LogicException

When incorrect default value is given

Return values
mixed

Search results