public function ParseExpressionNode(\PHPParser_Node_Expr $Node) { $FullNodeName = get_class($Node); $NodeType = str_replace('PHPParser_Node_Expr_', '', $FullNodeName); if ($this->ActsUponEntityVariable($Node)) { $PropertyExpression = $this->ParsePropertyNode($Node); if ($PropertyExpression !== null) { return $PropertyExpression; } } switch (true) { case $MappedNode = $this->ParseOperatorNode($Node, $NodeType): return $MappedNode; case $Node instanceof \PHPParser_Node_Expr_Array: $ValueExpressions = []; foreach ($Node->items as $Key => $Item) { $ValueExpressions[$Key] = $this->ParseNodeInternal($Item->value); } return Expression::NewArray($ValueExpressions); case $Node instanceof \PHPParser_Node_Expr_FuncCall: return Expression::FunctionCall($this->VerifyNameNode($Node->name), $this->ParseNodesInternal($Node->args)); case $Node instanceof \PHPParser_Node_Expr_New: return Expression::Construct($this->VerifyNameNode($Node->class), $this->ParseNodesInternal($Node->args)); case $Node instanceof \PHPParser_Node_Expr_MethodCall: return Expression::MethodCall($this->ParseNodeInternal($Node->var), $this->VerifyNameNode($Node->name), $this->ParseNodesInternal($Node->args)); case $Node instanceof \PHPParser_Node_Expr_PropertyFetch: return Expression::PropertyFetch($this->ParseNodeInternal($Node->var), $this->VerifyNameNode($Node->name)); case $Node instanceof \PHPParser_Node_Expr_StaticCall: return Expression::MethodCall(Expression::Object($this->VerifyNameNode($Node->class)), $this->VerifyNameNode($Node->name), $this->ParseNodesInternal($Node->args)); case $Node instanceof \PHPParser_Node_Expr_Ternary: $If = $Node->if ?: $Node->cond; return Expression::Ternary($this->ParseNodeInternal($Node->cond), $this->ParseNodeInternal($If), $this->ParseNodeInternal($Node->else)); case $Node instanceof \PHPParser_Node_Expr_Variable: $Name = $this->VerifyNameNode($Node->name); if ($Name !== $this->EntityVariableName) { throw new ASTException('Cannot parse AST with unresolvable variable $%s', $Name); } else { throw new ASTException('Cannot parse AST with unresolvable entity property'); } default: throw new ASTException('Cannot parse AST with unknown expression node: %s', get_class($Node)); } }