addVisitor(new PHPParser_NodeVisitor_NameResolver); $stmts = $parser->parse(new PHPParser_Lexer($code)); $stmts = $traverser->traverse($stmts); $this->assertEquals($expectedCode, $prettyPrinter->prettyPrint($stmts)); } /** * @covers PHPParser_NodeVisitor_NameResolver */ public function testAddNamespacedName() { $code = <<addVisitor(new PHPParser_NodeVisitor_NameResolver); $stmts = $parser->parse(new PHPParser_Lexer($code)); $stmts = $traverser->traverse($stmts); $this->assertEquals('Foo\\A', (string) $stmts[0]->stmts[0]->namespacedName); $this->assertEquals('Foo\\B', (string) $stmts[0]->stmts[1]->namespacedName); $this->assertEquals('Foo\\C', (string) $stmts[0]->stmts[2]->namespacedName); $this->assertEquals('Foo\\D', (string) $stmts[0]->stmts[3]->namespacedName); $this->assertEquals('Foo\\E', (string) $stmts[0]->stmts[4]->consts[0]->namespacedName); $this->assertEquals('A', (string) $stmts[1]->stmts[0]->namespacedName); $this->assertEquals('B', (string) $stmts[1]->stmts[1]->namespacedName); $this->assertEquals('C', (string) $stmts[1]->stmts[2]->namespacedName); $this->assertEquals('D', (string) $stmts[1]->stmts[3]->namespacedName); $this->assertEquals('E', (string) $stmts[1]->stmts[4]->consts[0]->namespacedName); } }