Add CommandAttributeTest to validate command attributes and descriptions #55911
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.
Fixing Symfony Console 7.3 Deprecation Warning
Issue Description
When running
composer run devin Laravel 12.16.0 applications with PHP 8.3.14, users were encountering repeated truncated deprecation warnings from Symfony Console 7.3:The full log message:
{ "message": "Since symfony/console 7.3: Method \"Symfony\\Component\\Console\\Command\\Command::getDefaultDescription()\" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead. in /Users/Kyrian/Packages/filament-daterange-picker/playground/vendor/symfony/deprecation-contracts/function.php on line 25", "context": { "__pail": { "origin": { "type": "console", "command": null, "trace": null } } }, "level": 300, "level_name": "WARNING", "channel": "pail", "datetime": "2025-05-30T11:46:28.118492+00:00", "extra": {} }Root Cause
The issue was related to Laravel's
ClosureCommandclass not having a$descriptionproperty defined. In Symfony Console 7.3, thegetDefaultDescription()method was deprecated in favor of using the#[AsCommand]attribute, and Symfony was generating deprecation warnings because of this.Fix Summary
The fix involved adding a
$descriptionproperty to theClosureCommandclass in Laravel's codebase:This ensures that when closure commands are created, they have a proper description property that is compatible with Symfony Console 7.3's expectations.
Implementation Details
Added a
$descriptionproperty to theClosureCommandclass in:/src/Illuminate/Foundation/Console/ClosureCommand.phpCreated a test to verify that closure commands work correctly:
/tests/Integration/Foundation/Console/ClosureCommandTest.phpThis approach follows the same implementation pattern used in Laravel 11, as demonstrated in PR #55888.
Benefits
Related Issues and PRs