PHP 클래스 Webmozart\Console\Api\Args\Format\Argument
Args arguments are passed after the command name and its options. In the
example below, "localhost" is the argument to the "server -d" command.
$ console server -d localhost
Arguments can be either optional or required. By default, all arguments are
optional, but you can explicitly make an argument optional or required by
passing one of the flags {@link OPTIONAL} and {@link REQUIRED} to the
constructor:
php
$argument = new Argument('server', Argument::REQUIRED);
Arguments can also be multi-valued. Multi-valued arguments can be passed any
number of times:
$ console server -d localhost google.com
To create a multi-valued argument, pass the flag {@link MULTI_VALUED} to the
constructor:
php
$argument = new Argument('server', Argument::MULTI_VALUED);
You can combine the {@link MULTI_VALUED} flag with either {@link OPTIONAL}
or {@link REQUIRED} using the bitwise operator "|":
php
$argument = new Argument('server', Argument::REQUIRED | Argument::MULTI_VALUED);
파일 보기
프로젝트 열기: webmozart/console
1 사용 예제들
공개 메소드들
비공개 메소드들
메소드 상세
public __construct ( string $name, integer $flags, string $description = null, mixed $defaultValue = null ) |
$name |
string |
The argument name |
$flags |
integer |
A bitwise combination of the flag constants. |
$description |
string |
A human-readable description of the argument. |
$defaultValue |
mixed |
The default value of the argument (must be
null for the flag {@link self::REQUIRED}). |
Returns the default value of the argument.
Returns the description text.
Returns the name of the argument.
Returns whether the argument accepts multiple values.
Returns whether the argument is optional.
Returns whether the argument is required.
Pass one of the flags {@link STRING}, {@link BOOLEAN}, {@link INTEGER}
and {@link FLOAT} to the constructor to configure the result of this
method. You can optionally combine the flags with {@link NULLABLE} to
support the conversion of "null" to null.
If the argument is required, this method throws an exception.
If the option is multi-valued, the passed value must be an array or
null.