Skip to content

Commit c02c255

Browse files
authored
[SYMFONY 5 & 6] Security add missing param (#699)
1 parent d2bdae4 commit c02c255

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

config/sets/symfony/symfony50.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,46 @@
22

33
declare(strict_types=1);
44

5+
use PHPStan\Type\StringType;
56
use Rector\Config\RectorConfig;
67
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
78
use Rector\Renaming\Rector\Name\RenameClassRector;
89
use Rector\Renaming\ValueObject\MethodCallRename;
10+
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
11+
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;
912

1013
# https://github.com/symfony/symfony/blob/5.0/UPGRADE-5.0.md
1114

1215
return static function (RectorConfig $rectorConfig): void {
1316
$rectorConfig->import(__DIR__ . '/symfony50-types.php');
1417

18+
$rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [
19+
new AddParamTypeDeclaration(
20+
'Symfony\Component\Security\Core\User\UserProviderInterface',
21+
'loadUserByUsername',
22+
0,
23+
new StringType(),
24+
),
25+
new AddParamTypeDeclaration(
26+
'Symfony\Component\Security\Core\User\UserProviderInterface',
27+
'supportsClass',
28+
0,
29+
new StringType(),
30+
),
31+
new AddParamTypeDeclaration(
32+
'Symfony\Bridge\Doctrine\Security\User\EntityUserProvider',
33+
'loadUserByUsername',
34+
0,
35+
new StringType(),
36+
),
37+
new AddParamTypeDeclaration(
38+
'Symfony\Bridge\Doctrine\Security\User\EntityUserProvider',
39+
'supportsClass',
40+
0,
41+
new StringType(),
42+
),
43+
]);
44+
1545
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
1646
'Symfony\Component\Debug\Debug' => 'Symfony\Component\ErrorHandler\Debug',
1747
]);

config/sets/symfony/symfony60.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PhpParser\Node\Scalar\String_;
66
use PHPStan\Type\MixedType;
77
use PHPStan\Type\ObjectType;
8+
use PHPStan\Type\StringType;
89
use Rector\Config\RectorConfig;
910
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
1011
use Rector\Renaming\Rector\Name\RenameClassRector;
@@ -36,7 +37,18 @@
3637
]);
3738

3839
$rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [
39-
new AddParamTypeDeclaration('Symfony\Component\Config\Loader\LoaderInterface', 'load', 0, new MixedType(true)),
40+
new AddParamTypeDeclaration(
41+
'Symfony\Component\Config\Loader\LoaderInterface',
42+
'load',
43+
0,
44+
new MixedType(true)
45+
),
46+
new AddParamTypeDeclaration(
47+
'Symfony\Component\Config\Loader\LoaderInterface',
48+
'supports',
49+
0,
50+
new MixedType(true)
51+
),
4052
new AddParamTypeDeclaration(
4153
'Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait',
4254
'configureRoutes',

0 commit comments

Comments
 (0)