Skip to content
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

[Symfony61] Add rules for upgrade #266

Merged
merged 6 commits into from
Nov 7, 2022
Merged

Conversation

JohJohan
Copy link
Contributor

@JohJohan JohJohan commented Nov 2, 2022

@JohJohan
Copy link
Contributor Author

JohJohan commented Nov 2, 2022


class SetDescriptionAtTop extends \Symfony\Component\Console\Command\Command
{
protected static $defaultDescription = 'Description';
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Contributor Author

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

@JohJohan JohJohan requested review from stefantalen and TomasVotruba and removed request for stefantalen November 5, 2022 18:50
@TomasVotruba
Copy link
Member

Thank you 👍

@TomasVotruba TomasVotruba merged commit 5edba8c into rectorphp:main Nov 7, 2022
@JohJohan JohJohan deleted the symfony61 branch November 7, 2022 09:27
samsonasik pushed a commit to JohJohan/rector-symfony that referenced this pull request Nov 23, 2022
Co-authored-by: johan <johan@adivare.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants