Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7845da7

Browse filesBrowse files
[FrameworkBundle] Skip loading classes targetted by deprecated aliases in DebugAutowiringCommand
1 parent 74ac512 commit 7845da7
Copy full SHA for 7845da7

2 files changed

+22-2Lines changed: 22 additions & 2 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
113113
if ($isNewGroup = !str_starts_with($serviceId, $previousId.' $')) {
114114
$text[] = '';
115115
$previousId = preg_replace('/ \$.*/', '', $serviceId);
116-
$description = Descriptor::getClassDescription($previousId, $resolvedServiceId);
116+
$skipReflection = $container->hasAlias($previousId) && $container->getAlias($previousId)->isDeprecated();
117+
$description = $skipReflection ? '' : Descriptor::getClassDescription($previousId, $resolvedServiceId);
117118
if ('' !== $description && isset($hasAlias[$previousId])) {
118119
continue;
119120
}
@@ -143,7 +144,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
143144
if ($isNewGroup) {
144145
// Build the main type line with optional file link
145146
$typeLine = \sprintf('<fg=yellow>%s</>', $previousId);
146-
if ('' !== $fileLink = $this->getFileLink($previousId)) {
147+
if (!$skipReflection && '' !== $fileLink = $this->getFileLink($previousId)) {
147148
$typeLine = \sprintf('<fg=yellow;href=%s>%s</>', $fileLink, $previousId);
148149
}
149150

Collapse file

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,25 @@ public function testBasicFunctionality()
3939
$this->assertStringContainsString('→ http_kernel', $tester->getDisplay());
4040
}
4141

42+
public function testDoesNotLoadDeprecatedAliasClasses()
43+
{
44+
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']);
45+
46+
$application = new Application(static::$kernel);
47+
$application->setAutoExit(false);
48+
49+
$tester = new ApplicationTester($application);
50+
$tester->run(['command' => 'debug:autowiring'], ['decorated' => false]);
51+
52+
// The legacy ServicesResetterInterface alias is deprecated; running the
53+
// command must not autoload its file (which would trigger a deprecation).
54+
$this->assertFalse(
55+
interface_exists('Symfony\Component\HttpKernel\DependencyInjection\ServicesResetterInterface', false),
56+
'debug:autowiring should not autoload deprecated alias classes.'
57+
);
58+
$this->assertStringContainsString('[deprecated]', $tester->getDisplay());
59+
}
60+
4261
public function testSearchArgument()
4362
{
4463
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.