public function compile(Compiler $compiler, OperatorNode $node) { $data = $node->getChild(OperatorNode::OPERAND_LEFT); $filter = $node->getChild(OperatorNode::OPERAND_RIGHT); if ($filter instanceof FunctionNode) { $arguments = $filter->getArguments(); array_unshift($arguments, $data); $filter->setArguments($arguments); } elseif ($filter instanceof IdentifierNode && !$filter instanceof VariableNode) { $filter = new FunctionNode($filter->getData('name'), [$data]); } else { throw new ParseException('Invalid filter node.'); } $filter->compile($compiler); }
public function createMethodCallNode($object, $function, array $arguments = []) { $functionNode = new FunctionNode($function, $arguments); $functionNode->setObject($object); return $functionNode; }
private function isFunctionNodeSafe(FunctionNode $node) { if ($this->functionLevel++ === 0) { if ($node->getObject()) { return false; } return $this->isFunctionSafe($node); } return true; }
private function parseIdentifier($identifier) { if ($this->stream->nextTokenIf(Token::PUNCTUATION, '(')) { //function call $node = new FunctionNode($identifier, $this->parseArgumentList()); $lastOperator = $this->operatorStack->top(); if ($lastOperator instanceof PropertyAccessOperator) { $this->operatorStack->pop(); $node->setObject($this->operandStack->pop()); } } else { $node = new IdentifierNode($identifier); } $this->operandStack->push($node); }