public function visitAction(ActionNode $node) { $use = $this->createUseClause(); $this->results[] = <<<EOS {$this->getResult()} if (\$_success) { \$this->value = call_user_func(function (){$use} { {$node->getCode()} }); } EOS; }
function it_should_create_an_action_from_a_node() { $actionNode = new ActionNode(new LabelNode('name', new RuleReferenceNode('Foo')), 'return $name;'); $actionCode = <<<EOS \$_success = \$this->parseFoo(); if (\$_success) { \$name = \$this->value; } if (\$_success) { \$this->value = call_user_func(function () use (&\$name) { return \$name; }); } EOS; $actionNode->accept($this->getWrappedObject()); $this->getResult()->shouldBe($actionCode); }