8000 [Symfony61] Add rules for upgrade by JohJohan · Pull Request #266 · rectorphp/rector-symfony · GitHub
[go: up one dir, main page]

Skip to content

[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

Merged
merged 6 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions config/sets/symfony/level/up-to-symfony-61.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\SymfonyLevelSetList;
use Rector\Symfony\Set\SymfonySetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([SymfonySetList::SYMFONY_61, SymfonyLevelSetList::UP_TO_SYMFONY_60]);
};
2 changes: 1 addition & 1 deletion config/sets/symfony/level/up-to-symfony-62.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
use Rector\Symfony\Set\SymfonySetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([SymfonySetList::SYMFONY_62, SymfonyLevelSetList::UP_TO_SYMFONY_60]);
$rectorConfig->sets([SymfonySetList::SYMFONY_62, SymfonyLevelSetList::UP_TO_SYMFONY_61]);
};
22 changes: 22 additions & 0 deletions config/sets/symfony/symfony61.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Symfony\Rector\Class_\CommandPropertyToAttributeRector;

# https://github.com/symfony/symfony/blob/6.1/UPGRADE-6.1.md

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(CommandPropertyToAttributeRector::class);

$rectorConfig->ruleWithConfiguration(
RenameClassRector::class,
[
// @see https://github.com/symfony/symfony/pull/43982
'Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface' => 'Symfony\Component\Serializer\Normalizer\DenormalizerInterface',
'Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface' => 'Symfony\Component\Serializer\Normalizer\NormalizerInterface',
],
);
};
5 changes: 5 additions & 0 deletions src/Set/SymfonyLevelSetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ final class SymfonyLevelSetList implements SetListInterface
*/
final public const UP_TO_SYMFONY_60 = __DIR__ . '/../../config/sets/symfony/level/up-to-symfony-60.php';

/**
* @var string
*/
final public const UP_TO_SYMFONY_61 = __DIR__ . '/../../config/sets/symfony/level/up-to-symfony-61.php';

/**
* @var string
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Set/SymfonySetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ final class SymfonySetList implements SetListInterface
*/
final public const SYMFONY_60 = __DIR__ . '/../../config/sets/symfony/symfony60.php';

/**
* @var string
*/
final public const SYMFONY_61 = __DIR__ . '/../../config/sets/symfony/symfony61.php';

/**
* @var string
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Symfony\Component\Serializer\Normalizer;

if (interface_exists('Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface')) {
return;
}

interface ContextAwareDenormalizerInterface
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Symfony\Component\Serializer\Normalizer;

if (interface_exists('Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface')) {
return;
}

interface ContextAwareNormalizerInterface
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Symfony\Component\Serializer\Normalizer;

if (interface_exists('Symfony\Component\Serializer\Normalizer\DenormalizerInterface')) {
return;
}

interface DenormalizerInterface
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Symfony\Component\Serializer\Normalizer;

if (interface_exists('Symfony\Component\Serializer\Normalizer\NormalizerInterface')) {
return;
}

interface NormalizerInterface
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Rector\Symfony\Tests\Set\Symfony61\Fixture;

use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;

class ReplaceDepricatedInterfacesSerializer implements DenormalizerInterface, NormalizerInterface, ContextAwareNormalizerInterface, ContextAwareDenormalizerInterface
{
}

?>
-----
<?php

namespace Rector\Symfony\Tests\Set\Symfony61\Fixture;

use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;

class ReplaceDepricatedInterfacesSerializer implements DenormalizerInterface, NormalizerInterface
{
}

?>
29 changes: 29 additions & 0 deletions tests/Set/Symfony61/Symfony61Test.php
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';
}
}
11 changes: 11 additions & 0 deletions tests/Set/Symfony61/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]);
};
0