Symfony\Component\DependencyInjection\DefinitionDecorator::getArgument PHP Method

getArgument() public method

If replaceArgument() has been used to replace an argument, this method will return the replacement value.
public getArgument ( integer $index ) : mixed
$index integer
return mixed The argument value
    public function getArgument($index)
    {
        if (array_key_exists('index_'.$index, $this->arguments)) {
            return $this->arguments['index_'.$index];
        }

        $lastIndex = count(array_filter(array_keys($this->arguments), 'is_int')) - 1;

        if ($index < 0 || $index > $lastIndex) {
            throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, $lastIndex));
        }

        return $this->arguments[$index];
    }

Usage Example

 /**
  * @expectedException \OutOfBoundsException
  */
 public function testGetArgumentShouldCheckBounds()
 {
     $def = new DefinitionDecorator('foo');
     $def->setArguments(array(0 => 'foo'));
     $def->replaceArgument(0, 'foo');
     $def->getArgument(1);
 }
All Usage Examples Of Symfony\Component\DependencyInjection\DefinitionDecorator::getArgument