public function visitAdditionNode(AdditionNode $node) { return $this->_renderNode($this->_indent($this->depth + 1) . '<addition>' . PHP_EOL . implode(PHP_EOL, array_map(function (DerivableNodeInterface $child) { $v = new XMLVisitor($this->depth + 2); return $v->visit($child); }, $node->getChildren())) . PHP_EOL . $this->_indent($this->depth + 1) . '</addition>'); }
public function visitAdditionNode(AdditionNode $node) { $nodes = []; $constant = 0; foreach ($node->getChildren() as $child) { $child = $this->visit($child); if ($this->isConstantVisitor->visit($child)) { $constant += $this->evaluationVisitor->visit($child); } else { if (!$this->isZeroVisitor->visit($child)) { $nodes[] = $this->visit($child); } } } if ($constant != 0) { $nodes[] = new ConstantNode($constant); } if (count($nodes) == 0) { return Tree::init(0); } if (count($nodes) == 1) { return $nodes[0]; } return new AdditionNode(...$nodes); }
public function visitAdditionNode(AdditionNode $node) { return new AdditionNode(...array_map(function (DerivableNodeInterface $child) { return $this->visit($child); }, $node->getChildren())); }