Fixing a bug where class_alias would cause incorrect items in debug:autowiring
This commit is contained in:
parent
2a92dd3728
commit
d34b437ce0
@ -103,9 +103,10 @@ EOF
|
||||
$serviceIdsNb = 0;
|
||||
foreach ($serviceIds as $serviceId) {
|
||||
$text = [];
|
||||
$resolvedServiceId = $serviceId;
|
||||
if (0 !== strpos($serviceId, $previousId)) {
|
||||
$text[] = '';
|
||||
if ('' !== $description = Descriptor::getClassDescription($serviceId, $serviceId)) {
|
||||
if ('' !== $description = Descriptor::getClassDescription($serviceId, $resolvedServiceId)) {
|
||||
if (isset($hasAlias[$serviceId])) {
|
||||
continue;
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures;
|
||||
|
||||
class_alias(
|
||||
ClassAliasTargetClass::class,
|
||||
__NAMESPACE__ . '\ClassAliasExampleClass'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
class ClassAliasExampleClass
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures;
|
||||
|
||||
class ClassAliasTargetClass
|
||||
{
|
||||
}
|
@ -97,4 +97,16 @@ class DebugAutowiringCommandTest extends AbstractWebTestCase
|
||||
$tester->run(['command' => 'debug:autowiring', 'search' => 'redirect', '--all' => true]);
|
||||
$this->assertStringContainsString('Pro-tip: use interfaces in your type-hints instead of classes to benefit from the dependency inversion principle.', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testNotConfusedByClassAliases()
|
||||
{
|
||||
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']);
|
||||
|
||||
$application = new Application(static::$kernel);
|
||||
$application->setAutoExit(false);
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(['command' => 'debug:autowiring', 'search' => 'ClassAlias']);
|
||||
$this->assertStringContainsString('Symfony\Bundle\FrameworkBundle\Tests\Fixtures\ClassAliasExampleClass (public)', $tester->getDisplay());
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ services:
|
||||
public: false
|
||||
Symfony\Bundle\FrameworkBundle\Tests\Fixtures\BackslashClass:
|
||||
class: Symfony\Bundle\FrameworkBundle\Tests\Fixtures\BackslashClass
|
||||
Symfony\Bundle\FrameworkBundle\Tests\Fixtures\ClassAliasExampleClass: '@public'
|
||||
env:
|
||||
class: stdClass
|
||||
arguments:
|
||||
|
Reference in New Issue
Block a user