Repository navigation
Conversation
AbstractCommand does not extend Symfony's Command, so a command written the way the Symfony 7 documentation describes, with #[AsCommand] instead of the static $defaultName removed from Symfony, had no name and could not be registered. getDefaultName() now falls back to the attribute when the class does not declare $defaultName, and the constructor applies the attribute's aliases, hidden flag, description and help. $defaultName keeps precedence. The reflection result is cached per class instead of being rebuilt on every getDefaultName() call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Symfony removed Command::$defaultName in 7.0 in favour of #[AsCommand], which AbstractCommand now reads as well. Deprecate the property for removal in 5.0: getDefaultName() triggers a deprecation when a class names itself through it. The help and list commands use the attribute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
I would remove this in version 6.0 of the framework and not in 5.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
Symfony removed
Command::$defaultNamein 7.0 in favour of the#[AsCommand]attribute, whichAbstractCommandreads as well once #38 is merged. This deprecates the static property for removal in 5.0:AbstractCommand::$defaultNamegets@deprecated 5.0 Use the #[AsCommand] attribute instead;AbstractCommand::getDefaultName()(and so the constructor) triggers a deprecation viatrigger_deprecation('joomla/console', '__DEPLOY_VERSION__', …)when a class names itself through the property; commands using the attribute trigger nothing;helpandlistcommands use#[AsCommand]instead of the property;symfony/deprecation-contracts(^2|^3, as in the other packages) is added torequirefortrigger_deprecation().The property keeps working unchanged in 4.x.
Depends on #38: this branch contains its commit; please review only the last commit ("Deprecate naming commands with the static $defaultName property"). The 5.x removal is a separate PR against
5.x-dev.Related to #39, which changes the
symfony/consoleline incomposer.jsonright next to the addedsymfony/deprecation-contractsline — expect a one-line conflict there, keep both changes.Testing Instructions
AbstractCommandTest::testTheDefaultNamePropertyIsDeprecatedexpects the deprecation for a$defaultNamecommand (fails without this change);AbstractCommandTest::testTheAsCommandAttributeIsNotDeprecatedchecks that an attribute-only command raises no deprecation;help/listcover the switch to the attribute.The test fixtures keep using
$defaultNamein 4.x to show it still works; the deprecation is silenced (@trigger_error) like all Symfony-style deprecations.Documentation Changes Required
docs/overview.md: the paragraph on naming commands says$defaultNameis deprecated since 4.1 and not read in 5.0.docs/v3-to-v4-update.md: the 4.1 note mentions the deprecation.🤖 Generated with Claude Code