diff --git a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php index 112bee87bd..d242acdc1b 100644 --- a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php @@ -118,6 +118,25 @@ class ClassMapGenerator case T_CLASS: case T_INTERFACE: case SYMFONY_TRAIT: + // Skip usage of ::class constant + $isClassConstant = false; + for ($j = $i - 1; $j > 0; --$j) { + if (is_string($tokens[$j])) { + break; + } + + if (T_DOUBLE_COLON === $tokens[$j][0]) { + $isClassConstant = true; + break; + } elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) { + break; + } + } + + if ($isClassConstant) { + continue; + } + // Find the classname while (($t = $tokens[++$i]) && is_array($t)) { if (T_STRING === $t[0]) { diff --git a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php index 29c3288347..e6756f1898 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php @@ -47,7 +47,7 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase /** * @dataProvider getTestCreateMapTests */ - public function testDump($directory, $expected) + public function testDump($directory) { $this->prepare_workspace(); @@ -115,6 +115,12 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase )); } + if (PHP_VERSION_ID >= 50500) { + $data[] = array(__DIR__.'/Fixtures/php5.5', array( + 'ClassCons\\Foo' => __DIR__.'/Fixtures/php5.5/class_cons.php', + )); + } + return $data; } diff --git a/src/Symfony/Component/ClassLoader/Tests/Fixtures/php5.5/class_cons.php b/src/Symfony/Component/ClassLoader/Tests/Fixtures/php5.5/class_cons.php new file mode 100644 index 0000000000..0ed8d77fca --- /dev/null +++ b/src/Symfony/Component/ClassLoader/Tests/Fixtures/php5.5/class_cons.php @@ -0,0 +1,11 @@ +