From 2681ada078f2b7545f8cf7322f6f557125c80648 Mon Sep 17 00:00:00 2001 From: Johan Vlaar Date: Wed, 29 Jan 2025 16:27:07 +0100 Subject: [PATCH] [SYMFONY 5 & 6] Security add missing param --- config/sets/symfony/symfony50.php | 12 ++++++++++++ config/sets/symfony/symfony60.php | 14 +++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/config/sets/symfony/symfony50.php b/config/sets/symfony/symfony50.php index e1aeef38..d70e1b0b 100644 --- a/config/sets/symfony/symfony50.php +++ b/config/sets/symfony/symfony50.php @@ -2,16 +2,28 @@ declare(strict_types=1); +use PHPStan\Type\StringType; use Rector\Config\RectorConfig; use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\ValueObject\MethodCallRename; +use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector; +use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration; # https://github.com/symfony/symfony/blob/5.0/UPGRADE-5.0.md return static function (RectorConfig $rectorConfig): void { $rectorConfig->import(__DIR__ . '/symfony50-types.php'); + $rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [ + new AddParamTypeDeclaration( + 'Symfony\Component\Security\Core\User\UserProviderInterface', + 'loadUserByUsername', + 0, + new StringType(), + ), + ]); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ 'Symfony\Component\Debug\Debug' => 'Symfony\Component\ErrorHandler\Debug', ]); diff --git a/config/sets/symfony/symfony60.php b/config/sets/symfony/symfony60.php index 49d9c810..3e3e52b2 100644 --- a/config/sets/symfony/symfony60.php +++ b/config/sets/symfony/symfony60.php @@ -5,6 +5,7 @@ use PhpParser\Node\Scalar\String_; use PHPStan\Type\MixedType; use PHPStan\Type\ObjectType; +use PHPStan\Type\StringType; use Rector\Config\RectorConfig; use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\Rector\Name\RenameClassRector; @@ -36,13 +37,24 @@ ]); $rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [ - new AddParamTypeDeclaration('Symfony\Component\Config\Loader\LoaderInterface', 'load', 0, new MixedType(true)), + new AddParamTypeDeclaration( + 'Symfony\Component\Config\Loader\LoaderInterface', + 'load', + 0, + new MixedType(true) + ), new AddParamTypeDeclaration( 'Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait', 'configureRoutes', 0, new ObjectType('Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator'), ), + new AddParamTypeDeclaration( + 'Symfony\Component\Security\Core\User\UserProviderInterface', + 'supportsClass', + 0, + new StringType(), + ), ]); $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [