/** * Insert argument before argument at index. * * @param LexicalVariableNode $variable * The lexical variable to insert. * @param int $index * Position to insert argument at. * @throws \OutOfBoundsException * Index out of bounds. * * @return $this */ public function insertLexicalVariable(LexicalVariableNode $variable, $index) { if ($index < 0) { throw new \OutOfBoundsException('index out of bounds'); } if (!$this->hasLexicalVariables() && $index !== 0) { throw new \OutOfBoundsException('index out of bounds'); } $this->createLexicalVariables(); $this->lexicalVariables->insertItem($variable, $index); }
/** * Insert parameter before parameter at index. * * @param ParameterNode $parameter * @param int $index * @throws \OutOfBoundsException * Index out of bounds. * @return $this */ public function insertParameter(ParameterNode $parameter, $index) { $this->parameters->insertItem($parameter, $index); return $this; }