create(ParserFactory::PREFER_PHP7)->parse( 'addVisitor(new NodeConnectingVisitor); $ast = $traverser->traverse($ast); $node = (new NodeFinder)->findFirstInstanceof($ast, Else_::class); $this->assertSame(If_::class, get_class($node->getAttribute('parent'))); $this->assertSame(ConstFetch::class, get_class($node->getAttribute('previous'))); $node = (new NodeFinder)->findFirstInstanceof($ast, ConstFetch::class); $this->assertSame(Else_::class, get_class($node->getAttribute('next'))); } }