/** * Creates a syntax tree for an arry or an epObject * @param array|epObject &$v * @param string $prefix * @return false|epQueryNode */ protected function &_createSyntaxNodes(&$v, $prefix) { $nodes = array(); // create expression for primitve vars from array or object if (!($exprs = $this->_getPrimitiveExprs($v, $prefix))) { return $nodes; } // create comparison '=' nodes foreach ($exprs as $path => $value) { // insert path into tree if (!$this->pm->insertPath($path)) { // should not happen continue; } // create a comparison node if (!($node = new epQueryNode(EPQ_N_EXPR_COMPARISON))) { // should not happen continue; } // set operator '=' $node->setParam('op', '='); // create left hand side variable if (!($left = new epQueryNode(EPQ_N_VARIABLE))) { // should not happen continue; } // set param path $left->setParam('path', $path); // add left hand side $node->addChild($left, 'left'); // create right hand side value if (!($right = new epQueryNode(EPQ_N_STRING))) { // should not happen continue; } $right->setParam('val', $value); // add left hand side $node->addChild($right, 'right'); // collect node $nodes[] = $node; } return $nodes; }
/** * Create a new node and set it as the current node * @return epQueryNode */ protected function node($type) { // create a node with type $this->n = new epQueryNode($type); // set line and char if (isset($this->t) && isset($this->t->line)) { $this->n->setParam('line', $this->t->line); } if (isset($this->t) && isset($this->t->char)) { $this->n->setParam('char', $this->t->char); } // return this node return $this->n; }