think\console\input\Definition::addArgument PHP Method

addArgument() public method

添加一个参数
public addArgument ( Argument $argument )
$argument Argument 参数
    public function addArgument(Argument $argument)
    {
        if (isset($this->arguments[$argument->getName()])) {
            throw new \LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName()));
        }
        if ($this->hasAnArrayArgument) {
            throw new \LogicException('Cannot add an argument after an array argument.');
        }
        if ($argument->isRequired() && $this->hasOptional) {
            throw new \LogicException('Cannot add a required argument after an optional one.');
        }
        if ($argument->isArray()) {
            $this->hasAnArrayArgument = true;
        }
        if ($argument->isRequired()) {
            ++$this->requiredCount;
        } else {
            $this->hasOptional = true;
        }
        $this->arguments[$argument->getName()] = $argument;
    }