Skip to content

Commit

Permalink
[SYMFONY 5 & 6] Security add missing param
Browse files Browse the repository at this point in the history
  • Loading branch information
JohJohan committed Jan 29, 2025
1 parent 4661c01 commit 2681ada
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
12 changes: 12 additions & 0 deletions config/sets/symfony/symfony50.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
Expand Down
14 changes: 13 additions & 1 deletion config/sets/symfony/symfony60.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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, [
Expand Down

0 comments on commit 2681ada

Please sign in to comment.