[ClassLoader] fixed order of interfaces in generated class collection caches (closes #4841)
This commit is contained in:
parent
e83c1a590a
commit
9a2c61780b
@ -283,12 +283,21 @@ class ClassCollectionLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($class->getInterfaces() as $interface) {
|
return array_merge(self::getInterfaces($class), $classes);
|
||||||
if ($interface->isUserDefined() && !isset(self::$seen[$interface->getName()])) {
|
}
|
||||||
self::$seen[$interface->getName()] = true;
|
|
||||||
|
|
||||||
array_unshift($classes, $interface);
|
private static function getInterfaces(\ReflectionClass $class)
|
||||||
}
|
{
|
||||||
|
$classes = array();
|
||||||
|
|
||||||
|
foreach ($class->getInterfaces() as $interface) {
|
||||||
|
$classes = array_merge($classes, self::getInterfaces($interface));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($class->isUserDefined() && $class->isInterface() && !isset(self::$seen[$class->getName()])) {
|
||||||
|
self::$seen[$class->getName()] = true;
|
||||||
|
|
||||||
|
$classes[] = $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $classes;
|
return $classes;
|
||||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\ClassLoader\Tests;
|
|||||||
|
|
||||||
use Symfony\Component\ClassLoader\ClassCollectionLoader;
|
use Symfony\Component\ClassLoader\ClassCollectionLoader;
|
||||||
|
|
||||||
|
require_once __DIR__.'/Fixtures/ClassesWithParents/GInterface.php';
|
||||||
require_once __DIR__.'/Fixtures/ClassesWithParents/CInterface.php';
|
require_once __DIR__.'/Fixtures/ClassesWithParents/CInterface.php';
|
||||||
require_once __DIR__.'/Fixtures/ClassesWithParents/B.php';
|
require_once __DIR__.'/Fixtures/ClassesWithParents/B.php';
|
||||||
require_once __DIR__.'/Fixtures/ClassesWithParents/A.php';
|
require_once __DIR__.'/Fixtures/ClassesWithParents/A.php';
|
||||||
@ -25,6 +26,7 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testClassReordering(array $classes)
|
public function testClassReordering(array $classes)
|
||||||
{
|
{
|
||||||
$expected = array(
|
$expected = array(
|
||||||
|
'ClassesWithParents\\GInterface',
|
||||||
'ClassesWithParents\\CInterface',
|
'ClassesWithParents\\CInterface',
|
||||||
'ClassesWithParents\\B',
|
'ClassesWithParents\\B',
|
||||||
'ClassesWithParents\\A',
|
'ClassesWithParents\\A',
|
||||||
@ -45,6 +47,7 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
array(array(
|
array(array(
|
||||||
'ClassesWithParents\\A',
|
'ClassesWithParents\\A',
|
||||||
'ClassesWithParents\\CInterface',
|
'ClassesWithParents\\CInterface',
|
||||||
|
'ClassesWithParents\\GInterface',
|
||||||
'ClassesWithParents\\B',
|
'ClassesWithParents\\B',
|
||||||
)),
|
)),
|
||||||
array(array(
|
array(array(
|
||||||
@ -81,6 +84,7 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
require_once __DIR__.'/Fixtures/ClassesWithParents/E.php';
|
require_once __DIR__.'/Fixtures/ClassesWithParents/E.php';
|
||||||
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
|
'ClassesWithParents\\GInterface',
|
||||||
'ClassesWithParents\\CInterface',
|
'ClassesWithParents\\CInterface',
|
||||||
'ClassesWithParents\\CTrait',
|
'ClassesWithParents\\CTrait',
|
||||||
'ClassesWithParents\\ATrait',
|
'ClassesWithParents\\ATrait',
|
||||||
|
@ -2,4 +2,6 @@
|
|||||||
|
|
||||||
namespace ClassesWithParents;
|
namespace ClassesWithParents;
|
||||||
|
|
||||||
interface CInterface {}
|
interface CInterface extends GInterface
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ClassesWithParents;
|
||||||
|
|
||||||
|
interface GInterface
|
||||||
|
{
|
||||||
|
}
|
Reference in New Issue
Block a user