/** * Creates the command option. * * @param string $longName The long option name. * @param string|null $shortName The short option name. * @param string[] $aliases A list of alias names. * @param int $flags A bitwise combination of the option flag * constants. * @param string $description A human-readable description of the option. * * @throws InvalidValueException If the default value is invalid. */ public function __construct($longName, $shortName = null, array $aliases = array(), $flags = 0, $description = null) { parent::__construct($longName, $shortName, $flags, $description); foreach ($aliases as $key => $alias) { $alias = $this->removeDashPrefix($alias); if (1 === strlen($alias)) { $this->assertShortAliasValid($alias); $this->shortAliases[] = $alias; } else { $this->assertLongAliasValid($alias); $this->longAliases[] = $alias; } } }
/** * Creates a new option. * * @param string $longName The long option name. * @param string|null $shortName The short option name. * @param int $flags A bitwise combination of the option flag * constants. * @param string $description A human-readable description of the option. * @param mixed $defaultValue The default value (must be null for * {@link VALUE_REQUIRED} or * {@link VALUE_NONE}). * @param string $valueName The name of the value to be used in * usage examples of the option. * * @throws InvalidValueException If the default value is invalid. */ public function __construct($longName, $shortName = null, $flags = 0, $description = null, $defaultValue = null, $valueName = '...') { Assert::string($valueName, 'The option value name must be a string. Got: %s'); Assert::notEmpty($valueName, 'The option value name must not be empty.'); $this->assertFlagsValid($flags); $this->addDefaultFlags($flags); parent::__construct($longName, $shortName, $flags, $description); $this->valueName = $valueName; if ($this->acceptsValue() || null !== $defaultValue) { $this->setDefaultValue($defaultValue); } }