diff --git a/lib/PhpParser/NodeVisitor/NameResolver.php b/lib/PhpParser/NodeVisitor/NameResolver.php index cdac1f7..2850fef 100644 --- a/lib/PhpParser/NodeVisitor/NameResolver.php +++ b/lib/PhpParser/NodeVisitor/NameResolver.php @@ -122,7 +122,7 @@ class NameResolver extends NodeVisitorAbstract protected function resolveClassName(Name $name) { // don't resolve special class names - if (in_array((string) $name, array('self', 'parent', 'static'))) { + if (in_array(strtolower($name), array('self', 'parent', 'static'))) { return $name; } diff --git a/test/PhpParser/NodeVisitor/NameResolverTest.php b/test/PhpParser/NodeVisitor/NameResolverTest.php index c13ccde..ec88238 100644 --- a/test/PhpParser/NodeVisitor/NameResolverTest.php +++ b/test/PhpParser/NodeVisitor/NameResolverTest.php @@ -314,4 +314,35 @@ EOC; $this->assertEquals(array('Bar', 'Baz'), $stmt->stmts[1]->expr->class->parts); } + + public function testSpecialClassNamesAreCaseInsensitive() { + $source = <<<'EOC' +parse($source); + + $traverser = new PhpParser\NodeTraverser; + $traverser->addVisitor(new NameResolver); + + $stmts = $traverser->traverse($stmts); + $classStmt = $stmts[0]; + $methodStmt = $classStmt->stmts[0]->stmts[0]; + + $this->assertEquals('SELF', (string)$methodStmt->stmts[0]->class); + $this->assertEquals('PARENT', (string)$methodStmt->stmts[1]->class); + $this->assertEquals('static', (string)$methodStmt->stmts[2]->class); + } }