Fix classmap generator over anonymous classes extending/implementing something, fixes #5239
parent
ec933398c4
commit
f0d67923a5
|
@ -188,6 +188,10 @@ class ClassMapGenerator
|
||||||
$namespace = str_replace(array(' ', "\t", "\r", "\n"), '', $matches['nsname'][$i]) . '\\';
|
$namespace = str_replace(array(' ', "\t", "\r", "\n"), '', $matches['nsname'][$i]) . '\\';
|
||||||
} else {
|
} else {
|
||||||
$name = $matches['name'][$i];
|
$name = $matches['name'][$i];
|
||||||
|
// skip anon classes extending/implementing
|
||||||
|
if ($name === 'extends' || $name === 'implements') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ($name[0] === ':') {
|
if ($name[0] === ':') {
|
||||||
// This is an XHP class, https://github.com/facebook/xhp
|
// This is an XHP class, https://github.com/facebook/xhp
|
||||||
$name = 'xhp'.substr(str_replace(array('-', ':'), array('_', '__'), $name), 1);
|
$name = 'xhp'.substr(str_replace(array('-', ':'), array('_', '__'), $name), 1);
|
||||||
|
|
|
@ -87,6 +87,11 @@ class ClassMapGeneratorTest extends TestCase
|
||||||
'Foo\\CBar' => __DIR__.'/Fixtures/php5.4/traits.php',
|
'Foo\\CBar' => __DIR__.'/Fixtures/php5.4/traits.php',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
if (PHP_VERSION_ID >= 70000) {
|
||||||
|
$data[] = array(__DIR__.'/Fixtures/php7.0', array(
|
||||||
|
'Dummy\Test\AnonClassHolder' => __DIR__.'/Fixtures/php7.0/anonclass.php',
|
||||||
|
));
|
||||||
|
}
|
||||||
if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.3', '>=')) {
|
if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.3', '>=')) {
|
||||||
$data[] = array(__DIR__.'/Fixtures/hhvm3.3', array(
|
$data[] = array(__DIR__.'/Fixtures/hhvm3.3', array(
|
||||||
'FooEnum' => __DIR__.'/Fixtures/hhvm3.3/HackEnum.php',
|
'FooEnum' => __DIR__.'/Fixtures/hhvm3.3/HackEnum.php',
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace Dummy\Test;
|
||||||
|
|
||||||
|
use Dummy\Common\TestCase;
|
||||||
|
|
||||||
|
class AnonClassHolder extends TestCase
|
||||||
|
{
|
||||||
|
protected function getTest(): ClassAvailability
|
||||||
|
{
|
||||||
|
return new class extends ClassAvailability
|
||||||
|
{
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getTest2(): ClassAvailability
|
||||||
|
{
|
||||||
|
return new class(2) extends ClassAvailability
|
||||||
|
{
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getTest3(): ClassAvailability
|
||||||
|
{
|
||||||
|
return new class(2, 3) extends ClassAvailability
|
||||||
|
{
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getTest4(): ClassAvailability
|
||||||
|
{
|
||||||
|
return new class(2, 3) {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getTest5(): ClassAvailability
|
||||||
|
{
|
||||||
|
return new class implements FooInterface {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue