/** * This method parses a compound variable like: * * <code> * // ---------------- * return ${'Foo' . 'Bar'}; * // ---------------- * </code> * * @param PHP_Depend_Token $token The dollar token. * * @return PHP_Depend_Code_ASTCompoundVariable * @since 0.10.0 */ private function _parseCompoundVariable(PHP_Depend_Token $token) { return $this->_parseBraceExpression($this->builder->buildASTCompoundVariable($token->image), $this->consumeToken(self::T_CURLY_BRACE_OPEN), self::T_CURLY_BRACE_CLOSE); }
/** * This method implements a decision point between compound-variables and * variable-variable. It expects that the next token in the token-stream is * of type <b>T_DOLLAR</b> and removes it from the stream. Then this method * peeks the next available token when it is of type <b>T_CURLY_BRACE_OPEN</b> * this is compound variable, otherwise it can be a variable-variable or a * compound-variable. * * @return PHP_Depend_Code_ASTNode * @throws PHP_Depend_Parser_Exception When an error occured during the * parsing process. * @throws PHP_Depend_Parser_UnexpectedTokenException When the actual token * is not a valid variable token. * @since 0.9.6 */ private function _parseCompoundVariableOrVariableVariable() { $this->_tokenStack->push(); // Read the dollar token $token = $this->_consumeToken(self::T_DOLLAR); $this->_consumeComments(); // Get next token type $tokenType = $this->_tokenizer->peek(); // T_DOLLAR|T_VARIABLE === Variable variable, // T_CURLY_BRACE_OPEN === Compound variable switch ($tokenType) { case self::T_DOLLAR: case self::T_VARIABLE: $variable = $this->_builder->buildASTVariableVariable($token->image); $variable->addChild($this->_parseCompoundVariableOrVariableVariableOrVariable()); break; default: $variable = $this->_builder->buildASTCompoundVariable($token->image); $variable->addChild($this->_parseCompoundExpression()); break; } return $this->_setNodePositionsAndReturn($variable); }