8000 [Symfony61] Add rules for upgrade · rectorphp/rector-symfony@1f53ebc · GitHub
[go: up one dir, main page]

Skip to content

Commit 1f53ebc

Browse files
committed
[Symfony61] Add rules for upgrade
1 parent 5f0c972 commit 1f53ebc

File tree

7 files changed

+176
-0
lines changed

7 files changed

+176
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Symfony\Set\SymfonyLevelSetList;
7+
use Rector\Symfony\Set\SymfonySetList;
8+
9+
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->sets([SymfonySetList::SYMFONY_61, SymfonyLevelSetList::UP_TO_SYMFONY_60]);
11+
};

config/sets/symfony/symfony61.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Renaming\Rector\Name\RenameClassRector;
7+
use Rector\Symfony\Rector\Class_\CommandDescriptionToPropertyRector;
8+
9+
# https://github.com/symfony/symfony/blob/6.1/UPGRADE-6.1.md
10+
11+
return static function (RectorConfig $rectorConfig): void {
12+
// @see https://symfony.com/blog/new-in-symfony-5-3-lazy-command-description
13+
$rectorConfig->rule(CommandDescriptionToPropertyRector::class);
14+
15+
$rectorConfig->ruleWithConfiguration(
16+
RenameClassRector::class,
17+
[
18+
19+
// @see https://github.com/symfony/symfony/pull/43982
20+
'Symfony\Component\Serializer\Normalizer\ContextAwareDecoderInterface' => 'Symfony\Component\Serializer\Normalizer\DecoderInterface',
21+
'Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface' => 'Symfony\Component\Serializer\Normalizer\DenormalizerInterface',
22+
'Symfony\Component\Serializer\Normalizer\ContextAwareEncoderInterface' => 'Symfony\Component\Serializer\Normalizer\EncoderInterface',
23+
'Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface' => 'Symfony\Component\Serializer\Normalizer\NormalizerInterface',
24+
],
25+
);
26+
};

src/Set/SymfonySetList.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ final class SymfonySetList implements SetListInterface
123123
*/
124124
final public const SYMFONY_60 = __DIR__ . '/../../config/sets/symfony/symfony60.php';
125125

126+
/**
127+
* @var string
128+
*/
129+
final public const SYMFONY_61 = __DIR__ . '/../../config/sets/symfony/symfony61.php';
130+
126131
/**
127132
* @var string
128133
*/
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Rector\Symfony\Tests\Set\Symfony61\Fixture;
4+
5+
use Symfony\Component\Serializer\Normalizer\ContextAwareDecoderInterface;
6+
use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface;
7+
use Symfony\Component\Serializer\Normalizer\ContextAwareEncoderInterface;
8+
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
9+
use Symfony\Component\Serializer\Normalizer\DecoderInterface;
10+
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
11+
use Symfony\Component\Serializer\Normalizer\EncoderInterface;
12+
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
13+
14+
class ReplaceDepricatedInterfacesSerializer implements DecoderInterface, DenormalizerInterface, EncoderInterface, NormalizerInterface, ContextAwareDecoderInterface, ContextAwareEncoderInterface, ContextAwareNormalizerInterface, ContextAwareDenormalizerInterface
15+
{
16+
}
17+
18+
?>
19+
-----
20+
<?php
21+
22+
namespace Rector\Symfony\Tests\Set\Symfony61\Fixture;
23+
24+
25+
use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface;
26+
use Symfony\Component\Serializer\Normalizer\ContextAwareEncoderInterface;
27+
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
28+
use Symfony\Component\Serializer\Normalizer\DecoderInterface;
29+
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
30+
use Symfony\Component\Serializer\Normalizer\EncoderInterface;
31+
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
32+
33+
class ReplaceDepricatedInterfacesSerializer implements DecoderInterface, DenormalizerInterface, EncoderInterface, NormalizerInterface
34+
{
35+
}
36+
37+
?>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
namespace Rector\Symfony\Tests\Set\Symfony61\Fixture;
4+
5+
use Symfony\Component\Console\Input\InputInterface;
6+
use Symfony\Component\Console\Output\OutputInterface;
7+
8+
class SetDescriptionAtTop extends \Symfony\Component\Console\Command\Command
9+
{
10+
public function configure()
11+
{
12+
$this
13+
->setName('some:command')
14+
->setDescription('Description');
15+
}
16+
17+
protected function initialize(InputInterface $input, OutputInterface $output): void
18+
{
19+
parent::initialize($input, $output);
20+
}
21+
22+
protected function execute(InputInterface $input, OutputInterface $output): int
23+
{
24+
return 0;
25+
}
26+
}
27+
28+
?>
29+
-----
30+
<?php
31+
32+
namespace Rector\Symfony\Tests\Set\Symfony61\Fixture;
33+
34+
use Symfony\Component\Console\Input\InputInterface;
35+
use Symfony\Component\Console\Output\OutputInterface;
36+
37+
class SetDescriptionAtTop extends \Symfony\Component\Console\Command\Command
38+
{
39+
protected static $defaultDescription = 'Description';
40+
public function configure()
41+
{
42+
$this
43+
->setName('some:command');
44+
}
45+
46+
protected function initialize(InputInterface $input, OutputInterface $output): void
47+
{
48+
parent::initialize($input, $output);
49+
}
50+
51+
protected function execute(InputInterface $input, OutputInterface $output): int
52+
{
53+
return 0;
54+
}
55+
}
56+
57+
?>

tests/Set/Symfony61/Symfony61Test.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Symfony\Tests\Set\Symfony61;
6+
7+
use Iterator;
8+
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
9+
10+
final class Symfony61Test extends AbstractRectorTestCase
11+
{
12+
/**
13+
* @dataProvider provideData()
14+
*/
15+
public function test(string $filePath): void
16+
{
17+
$this->doTestFile($filePath);
18+
}
19+
20+
public function provideData(): Iterator
21+
{
22+
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
23+
}
24+
25+
public function provideConfigFilePath(): string
26+
{
27+
return __DIR__.'/config/symfony61.php';
28+
}
29+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Symfony\Set\SymfonySetList;
7+
8+
return static function (RectorConfig $rectorConfig): void {
9+
$rectorConfig->import(__DIR__ . '/../../../../config/config.php');
10+
$rectorConfig->sets([SymfonySetList::SYMFONY_61]);
11+
};

0 commit comments

Comments
 (0)
0