Skip ::class constant
This commit is contained in:
parent
633d0d835c
commit
a336f0e98e
@ -118,6 +118,25 @@ class ClassMapGenerator
|
|||||||
case T_CLASS:
|
case T_CLASS:
|
||||||
case T_INTERFACE:
|
case T_INTERFACE:
|
||||||
case SYMFONY_TRAIT:
|
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
|
// Find the classname
|
||||||
while (($t = $tokens[++$i]) && is_array($t)) {
|
while (($t = $tokens[++$i]) && is_array($t)) {
|
||||||
if (T_STRING === $t[0]) {
|
if (T_STRING === $t[0]) {
|
||||||
|
@ -47,7 +47,7 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* @dataProvider getTestCreateMapTests
|
* @dataProvider getTestCreateMapTests
|
||||||
*/
|
*/
|
||||||
public function testDump($directory, $expected)
|
public function testDump($directory)
|
||||||
{
|
{
|
||||||
$this->prepare_workspace();
|
$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;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ClassCons;
|
||||||
|
|
||||||
|
class Foo
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
\Foo\TBar/* foo */::class;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user