Repository navigation
Conversation
Two 5.x changes add entries to it; creating the file once keeps them from conflicting over its creation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Several public signatures were typed only in doc blocks: AbstractCommand::addOption() and addArgument() defaults, AbstractCommand::setDefinition(), LoaderInterface::has(), DescriptorHelper::describe() and Application::execute(). Add the native types and type all private properties. Adding types to interface and overridable methods breaks implementers, so this goes to 5.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
Naming a command through $defaultName was deprecated in 4.1 in favour of Symfony's #[AsCommand] attribute, which replaced the property in Symfony 7.0. AbstractCommand now reads the attribute only, so the deprecation layer and symfony/deprecation-contracts go as well. The test commands use the attribute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
I would not remove this 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
Removes the static
AbstractCommand::$defaultNameproperty, deprecated in 4.x (#40) in favour of Symfony's#[AsCommand]attribute, which replaced the property in Symfony 7.0 and whichAbstractCommandreads since #38.AbstractCommand::getDefaultName()and the constructor read the attribute only; the deprecation layer from [4.x] Deprecate naming commands with the static $defaultName property #40 goes, and with it thesymfony/deprecation-contractsrequirement [4.x] Deprecate naming commands with the static $defaultName property #40 adds.$defaultNameis a plain subclass property now: it has no name, andApplication::addCommand()rejects it with "The command class … does not have a name".#[AsCommand].Depends on #38 and #40 (4.x) and on #41/#42 (5.x): this branch is stacked on the native-types branch and contains cherry-picks of the #38 and #40 commits, so it builds and tests on its own. Please review only the last commit ("Remove the static $defaultName property from AbstractCommand"). When 4.x-dev is merged into 5.x-dev after #38/#40, those cherry-picks drop out; check that
AbstractCommand::getDefaultName(), the constructor andcomposer.jsonend up as in this PR (no$defaultName, nosymfony/deprecation-contracts).Testing Instructions
vendor/bin/phpunit, phpcs and PHPStan pass.AbstractCommandTest::testTheDefaultNamePropertyIsNotReadchecks that a class declaring$defaultNamegets no name; the attribute tests from #38 still pass, and every other test now names its commands with the attribute.Documentation Changes Required
docs/v4-to-v5-update.md: new section "AbstractCommand::$defaultNameremoved" with a before/after example; the native-types section no longer mentions the property.docs/overview.md: the paragraph on naming commands describes the attribute only.🤖 Generated with Claude Code