-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[Console] Deprecating Command getDefaultName and getDefaultDescription methods #59565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
abf9433
to
2a93981
Compare
src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php
Outdated
Show resolved
Hide resolved
a951fd4
to
4d91a0d
Compare
0aae29c
to
25d44d4
Compare
25d44d4
to
99ba1a4
Compare
src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php
Outdated
Show resolved
Hide resolved
99ba1a4
to
7e3d761
Compare
src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php
Outdated
Show resolved
Hide resolved
7e3d761
to
b529726
Compare
Thank you @yceruto. |
This PR was merged into the 8.0 branch. Discussion ---------- [Console] Remove deprecated code | Q | A | ------------- | --- | Branch? | 8.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | - | License | MIT Refs: #60076, #59565, #59474 Commits ------- a13c74c Remove deprecated methods and legacy code
I've encountered this deprecation warning today, but the message does clarify on how to resolve it. What would be alternative to using public function execute(InputInterface $input, OutputInterface $output): int
{
$commandName = MyCommand::getDefaultName(); // 'hello:world' as defined in the AsCommand attribute
$commandInput = new ArrayInput([]);
$command = $this->getApplication()->find($commandName);
$code = $command->run($commandInput, $output);
if ($code !== Command::SUCCESS) {
return Command::FAILURE;
}
return Command::SUCCESS;
} Do I need to start extacting the command name myself starting from |
@ToshY Indeed, that use case wasn't considered when deprecating these methods. I'd suggest hardcoding command names in such tests -- just like route paths for controllers in functional tests -- and check for all occurrences in case of renaming. If you really want to get it programmatically from the command class name, you can either get it from the |
FYI, the use case I sketched is not for a "test" (even though it could be). It is a use case on "how to call other commands". I've been using
Yes, I understand I would need to do either the reflection bit myself or indeed could use a constant for it. I just don't understand why it got deprecated, as #59473 (comment) only talks about deprecating name/description for consistency reasons. |
It got deprecated because we don't need it anymore. I understand that the method was convenient for you, but it was never intended to be used that way. |
Ah okay, I didn't know that. Thanks both for the clarification 👍 |
related discussion #59473 (comment)