-
Notifications
You must be signed in to change notification settings - Fork 102
[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
Changes from 2 commits
1fa4726
34cd6e0
8b7251b
565ac15
38eb98d
a2837ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\Symfony\Set\SymfonyLevelSetList; | ||
use Rector\Symfony\Set\SymfonySetList; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->sets([SymfonySetList::SYMFONY_61, SymfonyLevelSetList::UP_TO_SYMFONY_60]); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\Renaming\Rector\Name\RenameClassRector; | ||
use Rector\Symfony\Rector\Class_\CommandDescriptionToPropertyRector; | ||
|
||
# https://github.com/symfony/symfony/blob/6.1/UPGRADE-6.1.md | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
// @see https://symfony.com/blog/new-in-symfony-5-3-lazy-command-description | ||
$rectorConfig->rule(CommandDescriptionToPropertyRector::class); | ||
|
||
$rectorConfig->ruleWithConfiguration( | ||
RenameClassRector::class, | ||
[ | ||
// @see https://github.com/symfony/symfony/pull/43982 | ||
'Symfony\Component\Serializer\Normalizer\ContextAwareDecoderInterface' => 'Symfony\Component\Serializer\Normalizer\DecoderInterface', | ||
JohJohan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
'Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface' => 'Symfony\Component\Serializer\Normalizer\DenormalizerInterface', | ||
'Symfony\Component\Serializer\Normalizer\ContextAwareEncoderInterface' => 'Symfony\Component\Serializer\Normalizer\EncoderInterface', | ||
'Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface' => 'Symfony\Component\Serializer\Normalizer\NormalizerInterface', | ||
], | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Rector\Symfony\Tests\Set\Symfony61\Fixture; | ||
|
||
use Symfony\Component\Serializer\Normalizer\ContextAwareDecoderInterface; | ||
use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface; | ||
use Symfony\Component\Serializer\Normalizer\ContextAwareEncoderInterface; | ||
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface; | ||
use Symfony\Component\Serializer\Normalizer\DecoderInterface; | ||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; | ||
use Symfony\Component\Serializer\Normalizer\EncoderInterface; | ||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; | ||
|
||
class ReplaceDepricatedInterfacesSerializer implements DecoderInterface, DenormalizerInterface, EncoderInterface, NormalizerInterface, ContextAwareDecoderInterface, ContextAwareEncoderInterface, ContextAwareNormalizerInterface, ContextAwareDenormalizerInterface | ||
{ | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Symfony\Tests\Set\Symfony61\Fixture; | ||
|
||
|
||
use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface; | ||
use Symfony\Component\Serializer\Normalizer\ContextAwareEncoderInterface; | ||
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface; | ||
use Symfony\Component\Serializer\Normalizer\DecoderInterface; | ||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; | ||
use Symfony\Component\Serializer\Normalizer\EncoderInterface; | ||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; | ||
|
||
class ReplaceDepricatedInterfacesSerializer implements DecoderInterface, DenormalizerInterface, EncoderInterface, NormalizerInterface | ||
{ | ||
} | ||
|
||
?> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace Rector\Symfony\Tests\Set\Symfony61\Fixture; | ||
|
||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class SetDescriptionAtTop extends \Symfony\Component\Console\Command\Command | ||
{ | ||
public function configure() | ||
{ | ||
$this | ||
->setName('some:command') | ||
->setDescription('Description'); | ||
} | ||
|
||
protected function initialize(InputInterface $input, OutputInterface $output): void | ||
{ | ||
parent::initialize($input, $output); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
return 0; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Symfony\Tests\Set\Symfony61\Fixture; | ||
|
||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay so i added There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
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 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 commentThe reason will be displayed to describe this comment to others. Learn more.
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 commentThe reason will be displayed to describe this comment to others. Learn more. Check i added missing stubs |
||
public function configure() | ||
{ | ||
$this | ||
->setName('some:command'); | ||
} | ||
|
||
protected function initialize(InputInterface $input, OutputInterface $output): void | ||
{ | ||
parent::initialize($input, $output); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
return 0; | ||
} | ||
} | ||
|
||
?> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Symfony\Tests\Set\Symfony61; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class Symfony61Test extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/symfony61.php'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\Symfony\Set\SymfonySetList; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->import(__DIR__ . '/../../../../config/config.php'); | ||
$rectorConfig->sets([SymfonySetList::SYMFONY_61]); | ||
}; |
Uh oh!
There was an error while loading. Please reload this page.