Skip to content

Commit 269aaae

Browse files
authored
[symfony 5.3] split of configs per package (#738)
* [symfony 5.3] split of configs per package * register symfony53-http-foundation * register symfony53-http-foundation * fix typo path * add symfony53-console * add symfony53-http-kernel * add symfony53-http-kernel * remove unused imports * fix name * comment like other * remove unused imports * add symfony53-core * add symfony53-mailer * add symfony53-form * add symfony53 * add symfony53-framework-bundle
1 parent e2c8f99 commit 269aaae

File tree

14 files changed

+226
-108
lines changed

14 files changed

+226
-108
lines changed

config/sets/symfony/symfony5/symfony52.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
declare(strict_types=1);
44

55
use Rector\Config\RectorConfig;
6-
use Rector\Symfony\Set\SymfonySetList;
76

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

config/sets/symfony/symfony5/symfony53.php

Lines changed: 9 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -2,112 +2,19 @@
22

33
declare(strict_types=1);
44

5-
use PHPStan\Type\ObjectType;
6-
use PHPStan\Type\StringType;
75
use Rector\Config\RectorConfig;
8-
use Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector;
9-
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
10-
use Rector\Renaming\Rector\Name\RenameClassRector;
11-
use Rector\Renaming\ValueObject\MethodCallRename;
12-
use Rector\Renaming\ValueObject\RenameClassConstFetch;
13-
use Rector\Symfony\Set\SymfonySetList;
146
use Rector\Symfony\Symfony53\Rector\StaticPropertyFetch\KernelTestCaseContainerPropertyDeprecationRector;
15-
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
16-
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
17-
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;
18-
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
197

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

2210
return static function (RectorConfig $rectorConfig): void {
23-
$rectorConfig->sets([SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES]);
24-
25-
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
26-
// @see https://github.com/symfony/symfony/pull/40536
27-
new MethodCallRename(
28-
'Symfony\Component\HttpFoundation\RequestStack',
29-
'getMasterRequest',
30-
'getMainRequest',
31-
),
32-
new MethodCallRename('Symfony\Component\Console\Helper\Helper', 'strlen', 'width'),
33-
new MethodCallRename(
34-
'Symfony\Component\Console\Helper\Helper',
35-
'strlenWithoutDecoration',
36-
'removeDecoration',
37-
),
38-
new MethodCallRename('Symfony\Component\HttpKernel\Event\KernelEvent', 'isMasterRequest', 'isMainRequest'),
39-
new MethodCallRename(
40-
'Symfony\Component\Security\Core\Authentication\Token\TokenInterface',
41-
'getUsername',
42-
'getUserIdentifier',
43-
),
44-
new MethodCallRename(
45-
'Symfony\Component\Security\Core\Exception\UsernameNotFoundException',
46-
'getUsername',
47-
'getUserIdentifier'
48-
),
49-
new MethodCallRename(
50-
'Symfony\Component\Security\Core\Exception\UsernameNotFoundException',
51-
'setUsername',
52-
'setUserIdentifier'
53-
),
54-
new MethodCallRename(
55-
'Symfony\Component\Security\Core\Authentication\RememberMe\PersistentTokenInterface',
56-
'getUsername',
57-
'getUserIdentifier'
58-
),
59-
]);
60-
61-
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
62-
'Symfony\Component\Security\Core\Exception\UsernameNotFoundException' => 'Symfony\Component\Security\Core\Exception\UserNotFoundException',
63-
// @see https://github.com/symfony/symfony/pull/39802
64-
'Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface' => 'Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryInterface',
65-
'Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\MessageDigestPasswordHasher',
66-
'Symfony\Component\Security\Core\Encoder\MigratingPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\MigratingPasswordHasher',
67-
'Symfony\Component\Security\Core\Encoder\NativePasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\NativePasswordHasher',
68-
'Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface' => 'Symfony\Component\PasswordHasher\PasswordHasherInterface',
69-
'Symfony\Component\Security\Core\Encoder\Pbkdf2PasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\Pbkdf2PasswordHasher',
70-
'Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\PlaintextPasswordHasher',
71-
'Symfony\Component\Security\Core\Encoder\SelfSaltingEncoderInterface' => 'Symfony\Component\PasswordHasher\LegacyPasswordHasherInterface',
72-
'Symfony\Component\Security\Core\Encoder\SodiumPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\SodiumPasswordHasher',
73-
'Symfony\Component\Security\Core\Encoder\UserPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\UserPasswordHasher',
74-
'Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface' => 'Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface',
75-
]);
76-
77-
$rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [
78-
new AddReturnTypeDeclaration(
79-
'Symfony\Component\Mailer\Transport\AbstractTransportFactory',
80-
'getEndpoint',
81-
new StringType(),
82-
),
83-
]);
84-
85-
// rename constant
86-
$rectorConfig->ruleWithConfiguration(RenameClassConstFetchRector::class, [
87-
// @see https://github.com/symfony/symfony/pull/40536
88-
new RenameClassConstFetch(
89-
'Symfony\Component\HttpKernel\HttpKernelInterface',
90-
'MASTER_REQUEST',
91-
'MAIN_REQUEST'
92-
),
93-
]);
94-
95-
$rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [
96-
// @see https://github.com/symfony/symfony/commit/ce77be2507631cd12e4ca37510dab37f4c2b759a
97-
new AddParamTypeDeclaration(
98-
'Symfony\Component\Form\DataMapperInterface',
99-
'mapFormsToData',
100-
0,
101-
new ObjectType(Traversable::class)
102-
),
103-
// @see https://github.com/symfony/symfony/commit/ce77be2507631cd12e4ca37510dab37f4c2b759a
104-
new AddParamTypeDeclaration(
105-
'Symfony\Component\Form\DataMapperInterface',
106-
'mapDataToForms',
107-
1,
108-
new ObjectType(Traversable::class)
109-
),
110-
]);
111-
112-
$rectorConfig->rules([KernelTestCaseContainerPropertyDeprecationRector::class]);
11+
// $rectorConfig->sets([SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES]);
12+
13+
$rectorConfig->import(__DIR__ . '/symfony53/symfony53-http-foundation.php');
14+
$rectorConfig->import(__DIR__ . '/symfony53/symfony53-console.php');
15+
$rectorConfig->import(__DIR__ . '/symfony53/symfony53-http-kernel.php');
16+
$rectorConfig->import(__DIR__ . '/symfony53/symfony53-security-core.php');
17+
$rectorConfig->import(__DIR__ . '/symfony53/symfony53-mailer.php');
18+
$rectorConfig->import(__DIR__ . '/symfony53/symfony53-form.php');
19+
$rectorConfig->import(__DIR__ . '/symfony53/symfony53-framework-bundle.php');
11320
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
7+
use Rector\Renaming\ValueObject\MethodCallRename;
8+
9+
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
11+
new MethodCallRename('Symfony\Component\Console\Helper\Helper', 'strlen', 'width'),
12+
new MethodCallRename(
13+
'Symfony\Component\Console\Helper\Helper',
14+
'strlenWithoutDecoration',
15+
'removeDecoration',
16+
),
17+
]);
18+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PHPStan\Type\ObjectType;
6+
use Rector\Config\RectorConfig;
7+
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
8+
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;
9+
10+
return static function (RectorConfig $rectorConfig): void {
11+
$rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [
12+
// @see https://github.com/symfony/symfony/commit/ce77be2507631cd12e4ca37510dab37f4c2b759a
13+
new AddParamTypeDeclaration(
14+
'Symfony\Component\Form\DataMapperInterface',
15+
'mapFormsToData',
16+
0,
17+
new ObjectType(Traversable::class)
18+
),
19+
// @see https://github.com/symfony/symfony/commit/ce77be2507631cd12e4ca37510dab37f4c2b759a
20+
new AddParamTypeDeclaration(
21+
'Symfony\Component\Form\DataMapperInterface',
22+
'mapDataToForms',
23+
1,
24+
new ObjectType(Traversable::class)
25+
),
26+
]);
27+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Symfony\Symfony53\Rector\StaticPropertyFetch\KernelTestCaseContainerPropertyDeprecationRector;
7+
8+
return static function (RectorConfig $rectorConfig): void {
9+
$rectorConfig->rules([KernelTestCaseContainerPropertyDeprecationRector::class]);
10+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
7+
use Rector\Renaming\ValueObject\MethodCallRename;
8+
9+
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
11+
// @see https://github.com/symfony/symfony/pull/40536
12+
new MethodCallRename(
13+
'Symfony\Component\HttpFoundation\RequestStack',
14+
'getMasterRequest',
15+
'getMainRequest',
16+
),
17+
]);
18+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector;
7+
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
8+
use Rector\Renaming\ValueObject\MethodCallRename;
9+
use Rector\Renaming\ValueObject\RenameClassConstFetch;
10+
11+
return static function (RectorConfig $rectorConfig): void {
12+
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
13+
new MethodCallRename('Symfony\Component\HttpKernel\Event\KernelEvent', 'isMasterRequest', 'isMainRequest'),
14+
]);
15+
16+
// rename constant
17+
$rectorConfig->ruleWithConfiguration(RenameClassConstFetchRector::class, [
18+
// @see https://github.com/symfony/symfony/pull/40536
19+
new RenameClassConstFetch(
20+
'Symfony\Component\HttpKernel\HttpKernelInterface',
21+
'MASTER_REQUEST',
22+
'MAIN_REQUEST'
23+
),
24+
]);
25+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PHPStan\Type\StringType;
6+
use Rector\Config\RectorConfig;
7+
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
8+
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
9+
10+
return static function (RectorConfig $rectorConfig): void {
11+
$rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [
12+
new AddReturnTypeDeclaration(
13+
'Symfony\Component\Mailer\Transport\AbstractTransportFactory',
14+
'getEndpoint',
15+
new StringType(),
16+
),
17+
]);
18+
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
7+
use Rector\Renaming\Rector\Name\RenameClassRector;
8+
use Rector\Renaming\ValueObject\MethodCallRename;
9+
10+
return static function (RectorConfig $rectorConfig): void {
11+
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
12+
new MethodCallRename(
13+
'Symfony\Component\Security\Core\Authentication\Token\TokenInterface',
14+
'getUsername',
15+
'getUserIdentifier',
16+
),
17+
new MethodCallRename(
18+
'Symfony\Component\Security\Core\Exception\UsernameNotFoundException',
19+
'getUsername',
20+
'getUserIdentifier'
21+
),
22+
new MethodCallRename(
23+
'Symfony\Component\Security\Core\Exception\UsernameNotFoundException',
24+
'setUsername',
25+
'setUserIdentifier'
26+
),
27+
new MethodCallRename(
28+
'Symfony\Component\Security\Core\Authentication\RememberMe\PersistentTokenInterface',
29+
'getUsername',
30+
'getUserIdentifier'
31+
),
32+
]);
33+
34+
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
35+
'Symfony\Component\Security\Core\Exception\UsernameNotFoundException' => 'Symfony\Component\Security\Core\Exception\UserNotFoundException',
36+
// @see https://github.com/symfony/symfony/pull/39802
37+
'Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface' => 'Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryInterface',
38+
'Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\MessageDigestPasswordHasher',
39+
'Symfony\Component\Security\Core\Encoder\MigratingPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\MigratingPasswordHasher',
40+
'Symfony\Component\Security\Core\Encoder\NativePasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\NativePasswordHasher',
41+
'Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface' => 'Symfony\Component\PasswordHasher\PasswordHasherInterface',
42+
'Symfony\Component\Security\Core\Encoder\Pbkdf2PasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\Pbkdf2PasswordHasher',
43+
'Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\PlaintextPasswordHasher',
44+
'Symfony\Component\Security\Core\Encoder\SelfSaltingEncoderInterface' => 'Symfony\Component\PasswordHasher\LegacyPasswordHasherInterface',
45+
'Symfony\Component\Security\Core\Encoder\SodiumPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\SodiumPasswordHasher',
46+
'Symfony\Component\Security\Core\Encoder\UserPasswordEncoder' => 'Symfony\Component\PasswordHasher\Hasher\UserPasswordHasher',
47+
'Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface' => 'Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface',
48+
]);
49+
};

rector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@
5454
naming: true,
5555
rectorPreset: true
5656
)
57-
->withImportNames();
57+
->withImportNames(removeUnusedImports: true);

0 commit comments

Comments
 (0)