public function addArgument(Argument $argument)
    {
        $name = $argument->getName();

        if ($this->hasArgument($name)) {
            throw CannotAddArgumentException::existsAlready($name);
        }

        if ($this->hasMultiValuedArgument()) {
            throw CannotAddArgumentException::cannotAddAfterMultiValued();
        }

        if ($argument->isRequired() && $this->hasOptionalArgument()) {
            throw CannotAddArgumentException::cannotAddRequiredAfterOptional();
        }

        if ($argument->isMultiValued()) {
            $this->hasMultiValuedArg = true;
        }

        if ($argument->isOptional()) {
            $this->hasOptionalArg = true;
        }

        $this->arguments[$name] = $argument;

        return $this;
    }
public function addArgument(Argument $argument)
    {
        $name = $argument->getName();

        if ($this->hasArgument($name)) {
            throw CannotAddArgumentException::existsAlready($name);
        }

        if ($this->hasMultiValuedArgument()) {
            throw CannotAddArgumentException::cannotAddAfterMultiValued();
        }

        if ($argument->isRequired() && $this->hasOptionalArgument()) {
            throw CannotAddArgumentException::cannotAddRequiredAfterOptional();
        }

        if ($argument->isMultiValued()) {
            $this->hasMultiValuedArg = true;
        }

        if ($argument->isOptional()) {
            $this->hasOptionalArg = true;
        }

        $this->arguments[$name] = $argument;

        return $this;
    }
public function addArgument ( Argument $ argument ) { $ name = $ argument -> getName ( ) ; if ( $ this -> hasArgument ( $ name ) ) { throw CannotAddArgumentException :: existsAlready ( $ name ) ; } if ( $ this -> hasMultiValuedArgument ( ) ) { throw CannotAddArgumentException :: cannotAddAfterMultiValued ( ) ; } if ( $ argument -> isRequired ( ) && $ this -> hasOptionalArgument ( ) ) { throw CannotAddArgumentException :: cannotAddRequiredAfterOptional ( ) ; } if ( $ argument -> isMultiValued ( ) ) { $ this -> hasMultiValuedArg = true ; } if ( $ argument -> isOptional ( ) ) { $ this -> hasOptionalArg = true ; } $ this -> arguments [ $ name ] = $ argument ; return $ this ; }
Adds an argument at the end of the argument list.

The existing arguments stored in the builder are preserved.

You cannot add arguments after adding a multi-valued argument. If you do
so, this method throws an exception.

Adding required arguments after optional arguments is not supported.
Also in this case an exception is thrown.

@param Argument $argument The argument to add.

@return static The current instance.

@throws CannotAddArgumentException If the argument cannot be added.
Adds an argument at the end of the argument list .