/** * Parses an allocation expression. * * <code> * function foo() * { * // ------------- * new bar\Baz(); * // ------------- * * // --------- * new Foo(); * // --------- * } * </code> * * @return \PDepend\Source\AST\ASTAllocationExpression * @since 0.9.6 */ private function parseAllocationExpression() { $this->tokenStack->push(); $token = $this->consumeToken(Tokens::T_NEW); $allocation = $this->builder->buildAstAllocationExpression($token->image); $allocation = $this->parseExpressionTypeReference($allocation, true); if ($this->isNextTokenArguments()) { $allocation->addChild($this->parseArguments()); } return $this->setNodePositionsAndReturn($allocation); }