Got PHP Warning with Operand
Created by: ycgambo
Input:
server:add
Output:
Operand port is required
----------------------------------------
Usage: server:add [options] <port> [<port>...]
Create server named as prefix_port on each port. The default prefix is `server`, you can change it with -n or --name option.
Options:
-n, --name [<arg>] the name prefix of server.
-p, --password <arg> the password to use
--process [<arg>] process number.
Warning:
PHP Warning: count(): Parameter must be an array or an object that implements Countable in xx/vendor/ulrichsg/getopt-php/src/GetOpt.php on line 192
The code:
$getopt = new GetOpt();
$getopt->setHelp(new CustomGetOptHelp());
$getopt->addCommands(array(
Command::create('server:add', '')
->setShortDescription('Add server on one or more port')
->setDescription('Create server named as prefix_port on each port. '
. 'The default prefix is `server`, you can change it with -n or --name option.')
->addOperands(array(
Operand::create('port', Operand::MULTIPLE + Operand::REQUIRED)
))
->addOptions(array(
Option::create('n', 'name', GetOpt::OPTIONAL_ARGUMENT)
->setDescription('the name prefix of server.')
->setDefaultValue('server'),
Option::create('p', 'password', GetOpt::REQUIRED_ARGUMENT)
->setDescription('the password to use'),
Option::create(null, 'process', GetOpt::OPTIONAL_ARGUMENT)
->setDescription('process number.')
->setDefaultValue(4),
)),
Command::create('server:del', ''),
));