8000 [FrameworkBundle] debug:container deprecate not passing --show-arguments · symfony/symfony@91d7211 · GitHub
[go: up one dir, main page]

Skip to content

Commit 91d7211

Browse files
committed
[FrameworkBundle] debug:container deprecate not passing --show-arguments
1 parent dd061aa commit 91d7211
Copy full SHA for 91d7211

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
151151
$tag = $this->findProperTagName($input, $errorIo, $object, $tag);
152152
$options = ['tag' => $tag];
153153
} elseif ($name = $input->getArgument('name')) {
154+
if (!$input->getOption('show-arguments')) {
155+
$errorIo->warning('Not passing the --show-arguments option is deprecated when a service name is provided.');
156+
}
157+
154158
$name = $this->findProperServiceName($input, $errorIo, $object, $name, $input->getOption('show-hidden'));
155159
$options = ['id' => $name];
156160
} elseif ($input->getOption('deprecations')) {

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function testPrivateAlias()
8080
$this->assertStringContainsString('public', $tester->getDisplay());
8181< 8000 div class="diff-text-inner"> $this->assertStringContainsString('private_alias', $tester->getDisplay());
8282

83-
$tester->run(['command' => 'debug:container', 'name' => 'private_alias']);
83+
$tester->run(['command' => 'debug:container', 'name' => 'private_alias', '--show-arguments' => true]);
8484
$this->assertStringContainsString('The "private_alias" service or alias has been removed', $tester->getDisplay());
8585
}
8686

@@ -93,10 +93,10 @@ public function testDeprecatedServiceAndAlias()
9393

9494
$tester = new ApplicationTester($application);
9595

96-
$tester->run(['command' => 'debug:container', 'name' => 'deprecated', '--format' => 'txt']);
96+
$tester->run(['command' => 'debug:container', 'name' => 'deprecated', '--format' => 'txt', '--show-arguments' => true]);
9797
$this->assertStringContainsString('[WARNING] The "deprecated" service is deprecated since foo/bar 1.9 and will be removed in 2.0', $tester->getDisplay());
9898

99-
$tester->run(['command' => 'debug:container', 'name' => 'deprecated_alias', '--format' => 'txt']);
99+
$tester->run(['command' => 'debug:container', 'name' => 'deprecated_alias', '--format' => 'txt', '--show-arguments' => true]);
100100
$this->assertStringContainsString('[WARNING] The "deprecated_alias" alias is deprecated since foo/bar 1.9 and will be removed in 2.0', $tester->getDisplay());
101101
}
102102

@@ -124,7 +124,7 @@ public function testIgnoreBackslashWhenFindingService(string $validServiceId)
124124
$application->setAutoExit(false);
125125

126126
$tester = new ApplicationTester($application);
127-
$tester->run(['command' => 'debug:container', 'name' => $validServiceId]);
127+
$tester->run(['command' => 'debug:container', 'name' => $validServiceId, '--show-arguments' => true]);
128128
$this->assertStringNotContainsString('No services found', $tester->getDisplay());
129129
}
130130

@@ -341,4 +341,22 @@ public static function provideCompletionSuggestions(): iterable
341341
['txt', 'xml', 'json', 'md'],
342342
];
343343
}
344+
345+
public function testShowArgumentsNotProvidedShouldTriggerDeprecation()
346+
{
347+
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml', 'debug' => true]);
348+
$path = sprintf('%s/%sDeprecations.log', static::$kernel->getContainer()->getParameter('kernel.build_dir'), static::$kernel->getContainer()->getParameter('kernel.container_class'));
349+
@unlink($path);
350+
351+
$application = new Application(static::$kernel);
352+
$application->setAutoExit(false);
353+
354+
@unlink(static::getContainer()->getParameter('debug.container.dump'));
355+
356+
$tester = new ApplicationTester($application);
357+
$tester->run(['command' => 'debug:container', 'name' => 'router']);
358+
359+
$tester->assertCommandIsSuccessful();
360+
$this->assertStringContainsString('[WARNING] Not passing the --show-arguments option is deprecated when a service name is provided.', $tester->getDisplay());
361+
}
344362
}

0 commit comments

Comments
 (0)
0