Trismegiste\Mondrian\Visitor\VisitorGateway::leaveNode PHP Method

leaveNode() public method

public leaveNode ( PhpParser\Node $node )
$node PhpParser\Node
    public function leaveNode(Node $node)
    {
        if ($this->debug) {
            printf("Leaving %s %s %s %d\n", $this->stateStack[0]['key'], $node->getType(), $node->name, count($this->stateStack));
        }
        $ret = $this->stateStack[0]['state']->leave($node);
        if ($this->stateStack[0]['nodeType'] === $node->getType()) {
            array_shift($this->stateStack);
        }
        return $ret;
    }

Usage Example

 public function testPushState()
 {
     $listing = [$this->getMockState('one'), $this->getMockState('two'), $this->getMockState('three')];
     $this->buildVisitor($listing);
     $node = [$this->getMock('PhpParser\\Node'), $this->getMock('PhpParser\\Node'), $this->getMock('PhpParser\\Node')];
     $this->assertNull($this->sut->getNodeFor('one'));
     $this->sut->pushState('two', $node[0]);
     $this->assertNull($this->sut->getNodeFor('one'));
     $this->assertEquals($node[0], $this->sut->getNodeFor('two'));
     $this->sut->pushState('three', $node[1]);
     $this->assertNull($this->sut->getNodeFor('one'));
     $this->assertEquals($node[0], $this->sut->getNodeFor('two'));
     $this->assertEquals($node[1], $this->sut->getNodeFor('three'));
     $this->sut->leaveNode($node[1]);
     $this->assertNull($this->sut->getNodeFor('one'));
     $this->assertEquals($node[0], $this->sut->getNodeFor('two'));
     $this->assertAttributeCount(2, 'stateStack', $this->sut);
     $this->sut->leaveNode($node[0]);
     $this->assertAttributeCount(1, 'stateStack', $this->sut);
 }