Skip to content
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
1 change: 0 additions & 1 deletion config/sets/symfony/symfony5/symfony52.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Symfony\Set\SymfonySetList;

# https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md

Expand Down
111 changes: 9 additions & 102 deletions config/sets/symfony/symfony5/symfony53.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,112 +2,19 @@

declare(strict_types=1);

use PHPStan\Type\ObjectType;
use PHPStan\Type\StringType;
use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use Rector\Renaming\ValueObject\RenameClassConstFetch;
use Rector\Symfony\Set\SymfonySetList;
use Rector\Symfony\Symfony53\Rector\StaticPropertyFetch\KernelTestCaseContainerPropertyDeprecationRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;

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

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES]);

$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
// @see https://github.com/symfony/symfony/pull/40536
new MethodCallRename(
'Symfony\Component\HttpFoundation\RequestStack',
'getMasterRequest',
'getMainRequest',
),
new MethodCallRename('Symfony\Component\Console\Helper\Helper', 'strlen', 'width'),
new MethodCallRename(
'Symfony\Component\Console\Helper\Helper',
'strlenWithoutDecoration',
'removeDecoration',
),
new MethodCallRename('Symfony\Component\HttpKernel\Event\KernelEvent', 'isMasterRequest', 'isMainRequest'),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\TokenInterface',
'getUsername',
'getUserIdentifier',
),
new MethodCallRename(
'Symfony\Component\Security\Core\Exception\UsernameNotFoundException',
'getUsername',
'getUserIdentifier'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Exception\UsernameNotFoundException',
'setUsername',
'setUserIdentifier'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\RememberMe\PersistentTokenInterface',
'getUsername',
'getUserIdentifier'
),
]);

$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
'Symfony\Component\Security\Core\Exception\UsernameNotFoundException' => 'Symfony\Component\Security\Core\Exception\UserNotFoundException',
// @see https://github.com/symfony/symfony/pull/39802
'Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface' => 'Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryInterface',
'Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\MessageDigestPasswordHasher',
'Symfony\Component\Security\Core\Encoder\MigratingPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\MigratingPasswordHasher',
'Symfony\Component\Security\Core\Encoder\NativePasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\NativePasswordHasher',
'Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface' => 'Symfony\Component\PasswordHasher\PasswordHasherInterface',
'Symfony\Component\Security\Core\Encoder\Pbkdf2PasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\Pbkdf2PasswordHasher',
'Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\PlaintextPasswordHasher',
'Symfony\Component\Security\Core\Encoder\SelfSaltingEncoderInterface' => 'Symfony\Component\PasswordHasher\LegacyPasswordHasherInterface',
'Symfony\Component\Security\Core\Encoder\SodiumPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\SodiumPasswordHasher',
'Symfony\Component\Security\Core\Encoder\UserPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\UserPasswordHasher',
'Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface' => 'Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface',
]);

$rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [
new AddReturnTypeDeclaration(
'Symfony\Component\Mailer\Transport\AbstractTransportFactory',
'getEndpoint',
new StringType(),
),
]);

// rename constant
$rectorConfig->ruleWithConfiguration(RenameClassConstFetchRector::class, [
// @see https://github.com/symfony/symfony/pull/40536
new RenameClassConstFetch(
'Symfony\Component\HttpKernel\HttpKernelInterface',
'MASTER_REQUEST',
'MAIN_REQUEST'
),
]);

$rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [
// @see https://github.com/symfony/symfony/commit/ce77be2507631cd12e4ca37510dab37f4c2b759a
new AddParamTypeDeclaration(
'Symfony\Component\Form\DataMapperInterface',
'mapFormsToData',
0,
new ObjectType(Traversable::class)
),
// @see https://github.com/symfony/symfony/commit/ce77be2507631cd12e4ca37510dab37f4c2b759a
new AddParamTypeDeclaration(
'Symfony\Component\Form\DataMapperInterface',
'mapDataToForms',
1,
new ObjectType(Traversable::class)
),
]);

$rectorConfig->rules([KernelTestCaseContainerPropertyDeprecationRector::class]);
// $rectorConfig->sets([SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES]);

$rectorConfig->import(__DIR__ . '/symfony53/symfony53-http-foundation.php');
$rectorConfig->import(__DIR__ . '/symfony53/symfony53-console.php');
$rectorConfig->import(__DIR__ . '/symfony53/symfony53-http-kernel.php');
$rectorConfig->import(__DIR__ . '/symfony53/symfony53-security-core.php');
$rectorConfig->import(__DIR__ . '/symfony53/symfony53-mailer.php');
$rectorConfig->import(__DIR__ . '/symfony53/symfony53-form.php');
$rectorConfig->import(__DIR__ . '/symfony53/symfony53-framework-bundle.php');
};
18 changes: 18 additions & 0 deletions config/sets/symfony/symfony5/symfony53/symfony53-console.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
new MethodCallRename('Symfony\Component\Console\Helper\Helper', 'strlen', 'width'),
new MethodCallRename(
'Symfony\Component\Console\Helper\Helper',
'strlenWithoutDecoration',
'removeDecoration',
),
]);
};
27 changes: 27 additions & 0 deletions config/sets/symfony/symfony5/symfony53/symfony53-form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

use PHPStan\Type\ObjectType;
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [
// @see https://github.com/symfony/symfony/commit/ce77be2507631cd12e4ca37510dab37f4c2b759a
new AddParamTypeDeclaration(
'Symfony\Component\Form\DataMapperInterface',
'mapFormsToData',
0,
new ObjectType(Traversable::class)
),
// @see https://github.com/symfony/symfony/commit/ce77be2507631cd12e4ca37510dab37f4c2b759a
new AddParamTypeDeclaration(
'Symfony\Component\Form\DataMapperInterface',
'mapDataToForms',
1,
new ObjectType(Traversable::class)
),
]);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Symfony\Symfony53\Rector\StaticPropertyFetch\KernelTestCaseContainerPropertyDeprecationRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rules([KernelTestCaseContainerPropertyDeprecationRector::class]);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
// @see https://github.com/symfony/symfony/pull/40536
new MethodCallRename(
'Symfony\Component\HttpFoundation\RequestStack',
'getMasterRequest',
'getMainRequest',
),
]);
};
25 changes: 25 additions & 0 deletions config/sets/symfony/symfony5/symfony53/symfony53-http-kernel.php
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\ClassConstFetch\RenameClassConstFetchRector;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use Rector\Renaming\ValueObject\RenameClassConstFetch;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
new MethodCallRename('Symfony\Component\HttpKernel\Event\KernelEvent', 'isMasterRequest', 'isMainRequest'),
]);

// rename constant
$rectorConfig->ruleWithConfiguration(RenameClassConstFetchRector::class, [
// @see https://github.com/symfony/symfony/pull/40536
new RenameClassConstFetch(
'Symfony\Component\HttpKernel\HttpKernelInterface',
'MASTER_REQUEST',
'MAIN_REQUEST'
),
]);
};
18 changes: 18 additions & 0 deletions config/sets/symfony/symfony5/symfony53/symfony53-mailer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

use PHPStan\Type\StringType;
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [
new AddReturnTypeDeclaration(
'Symfony\Component\Mailer\Transport\AbstractTransportFactory',
'getEndpoint',
new StringType(),
),
]);
};
49 changes: 49 additions & 0 deletions config/sets/symfony/symfony5/symfony53/symfony53-security-core.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Renaming\ValueObject\MethodCallRename;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\TokenInterface',
'getUsername',
'getUserIdentifier',
),
new MethodCallRename(
'Symfony\Component\Security\Core\Exception\UsernameNotFoundException',
'getUsername',
'getUserIdentifier'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Exception\UsernameNotFoundException',
'setUsername',
'setUserIdentifier'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\RememberMe\PersistentTokenInterface',
'getUsername',
'getUserIdentifier'
),
]);

$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
'Symfony\Component\Security\Core\Exception\UsernameNotFoundException' => 'Symfony\Component\Security\Core\Exception\UserNotFoundException',
// @see https://github.com/symfony/symfony/pull/39802
'Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface' => 'Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryInterface',
'Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\MessageDigestPasswordHasher',
'Symfony\Component\Security\Core\Encoder\MigratingPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\MigratingPasswordHasher',
'Symfony\Component\Security\Core\Encoder\NativePasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\NativePasswordHasher',
'Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface' => 'Symfony\Component\PasswordHasher\PasswordHasherInterface',
'Symfony\Component\Security\Core\Encoder\Pbkdf2PasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\Pbkdf2PasswordHasher',
'Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\PlaintextPasswordHasher',
'Symfony\Component\Security\Core\Encoder\SelfSaltingEncoderInterface' => 'Symfony\Component\PasswordHasher\LegacyPasswordHasherInterface',
'Symfony\Component\Security\Core\Encoder\SodiumPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\SodiumPasswordHasher',
'Symfony\Component\Security\Core\Encoder\UserPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\UserPasswordHasher',
'Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface' => 'Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface',
]);
};
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@
naming: true,
rectorPreset: true
)
->withImportNames();
->withImportNames(removeUnusedImports: true);
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt\Expression;
use Rector\Exception\NotImplementedYetException;
use Rector\Naming\Naming\PropertyNaming;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Nette\Utils\Strings;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\ArrayItem;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Array_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Param;
use PhpParser\Node\PropertyItem;
use PhpParser\Node\Stmt\Property;
use PhpParser\Node\Stmt\Trait_;
Expand Down
52 changes: 51 additions & 1 deletion src/Set/SetProvider/Symfony5SetProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,60 @@ public function provide(): array

new ComposerTriggeredSet(
SetGroup::SYMFONY,
'symfony/*',
'symfony/symfony',
'5.3',
__DIR__ . '/../../../config/sets/symfony/symfony5/symfony53.php'
),

new ComposerTriggeredSet(
SetGroup::SYMFONY,
'symfony/http-foundation',
'5.3',
__DIR__ . '/../../../config/sets/symfony/symfony5/symfony53/symfony53-http-foundation.php'
),

new ComposerTriggeredSet(
SetGroup::SYMFONY,
'symfony/console',
'5.3',
__DIR__ . '/../../../config/sets/symfony/symfony5/symfony53/symfony53-console.php'
),

new ComposerTriggeredSet(
SetGroup::SYMFONY,
'symfony/http-kernel',
'5.3',
__DIR__ . '/../../../config/sets/symfony/symfony5/symfony53/symfony53-http-kernel.php'
),

new ComposerTriggeredSet(
SetGroup::SYMFONY,
'symfony/security-core',
'5.3',
__DIR__ . '/../../../config/sets/symfony/symfony5/symfony53/symfony53-security-core.php'
),

new ComposerTriggeredSet(
SetGroup::SYMFONY,
'symfony/security-mailer',
'5.3',
__DIR__ . '/../../../config/sets/symfony/symfony5/symfony53/symfony53-mailer.php'
),

new ComposerTriggeredSet(
SetGroup::SYMFONY,
'symfony/form',
'5.3',
__DIR__ . '/../../../config/sets/symfony/symfony5/symfony53/symfony53-form.php'
),

new ComposerTriggeredSet(
SetGroup::SYMFONY,
'symfony/framework-bundle',
'5.3',
__DIR__ . '/../../../config/sets/symfony/symfony5/symfony53/symfony53-framework-bundle.php'
),

new ComposerTriggeredSet(
SetGroup::SYMFONY,
'symfony/*',
Expand Down
Loading