-
Notifications
You must be signed in to change notification settings - Fork 94
[Symfony61] Add rules for upgrade #266
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
I dont know why https://github.com/rectorphp/rector-symfony/actions/runs/3376828076/jobs/5605018494 fails for test case https://github.com/rectorphp/rector-symfony/blob/1f53ebc9ab27e9e9ef4f89ba03964e6353bbb981/tests/Set/Symfony61/Fixture/replace_deprecated_interfaces_serializer.php.inc it should just skip this as its not part off the Command class |
|
||
class SetDescriptionAtTop extends \Symfony\Component\Console\Command\Command | ||
{ | ||
protected static $defaultDescription = 'Description'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add this test for 6.1? It is just a copy of one of the CommandDescriptionToPropertyRector
tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay so i added CommandPropertyToAttributeRector
should i add a fixture of that test or should this be skipped as this is tested elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you ask me, the expected refactor for this deprecation should be a static property to an attribute.
Using setName()
and setDescription()
is not deprecated. The Symfony documentation just prefers it the "new" way for optimizations:
Defining the $defaultDescription static property instead of using the setDescription() method allows to get the command description without instantiating its class. This makes the php bin/console list command run much faster.
https://symfony.com/doc/current/console.html#configuring-the-command
So my personal expectation for using this set would be a refactors like this:
-#[\Symfony\Component\Console\Attribute\AsCommand(name: 'some:command']
+#[\Symfony\Component\Console\Attribute\AsCommand(name: 'some:command', description: 'Description')]
class SetDescriptionAtTop extends \Symfony\Component\Console\Command\Command
{
- protected static $defaultDescription = 'Description';
}
and
+#[\Symfony\Component\Console\Attribute\AsCommand(name: 'some:command', description: 'Description')]
class SetDescriptionAtTop extends \Symfony\Component\Console\Command\Command
{
- protected static $defaultName = 'some:command';
- protected static $defaultDescription = 'Description';
}
But that last example has already been covered by the tests for CommandPropertyToAttributeRector
, however we want to test changes using SymfonySetList::SYMFONY_61
.
Maybe @TomasVotruba can guide us here. Do we need duplicate tests when a Rector is used in a set to verify behaviour of the set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe @TomasVotruba can guide us here. Do we need duplicate tests when a Rector is used in a set to verify behaviour of the set?
That's not necessary indeed. But the bug should be fixed, so CI pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check i added missing stubs
Thank you 👍 |
Co-authored-by: johan <[email protected]>
Replace deprecated classes see https://github.com/symfony/symfony/blob/6.1/UPGRADE-6.1.md
TODO https://github.com/symfony/symfony/blob/6.1/UPGRADE-6.1.md#validator still has to be done