Skip to content

Commit 5b36ba6

Browse files
authored
[symfony 4.2] split to particular configs (#731)
* move * [symfony 4.1] split to particular configs * [symfony 4.2] Split off to per package configs * improve symfony set provider
1 parent 9cc7ebd commit 5b36ba6

15 files changed

+408
-185
lines changed

config/sets/symfony/symfony4/symfony41.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@
1010
$rectorConfig->import(__DIR__ . '/symfony41/symfony41-http-foundation.php');
1111
$rectorConfig->import(__DIR__ . '/symfony41/symfony41-workflow.php');
1212
$rectorConfig->import(__DIR__ . '/symfony41/symfony41-framework-bundle.php');
13-
1413
};

config/sets/symfony/symfony4/symfony42.php

Lines changed: 12 additions & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -2,190 +2,21 @@
22

33
declare(strict_types=1);
44

5-
use PHPStan\Type\IterableType;
6-
use PHPStan\Type\MixedType;
7-
use Rector\Arguments\NodeAnalyzer\ArgumentAddingScope;
8-
use Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector;
9-
use Rector\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector;
10-
use Rector\Arguments\ValueObject\ArgumentAdder;
11-
use Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue;
125
use Rector\Config\RectorConfig;
13-
use Rector\Removing\Rector\ClassMethod\ArgumentRemoverRector;
14-
use Rector\Removing\ValueObject\ArgumentRemover;
15-
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
16-
use Rector\Renaming\Rector\Name\RenameClassRector;
17-
use Rector\Renaming\ValueObject\MethodCallRename;
18-
use Rector\Symfony\Symfony42\Rector\New_\RootNodeTreeBuilderRector;
19-
use Rector\Symfony\Symfony42\Rector\New_\StringToArrayArgumentProcessRector;
20-
use Rector\Transform\Rector\ClassMethod\WrapReturnRector;
21-
use Rector\Transform\Rector\New_\NewToStaticCallRector;
22-
use Rector\Transform\ValueObject\NewToStaticCall;
23-
use Rector\Transform\ValueObject\WrapReturn;
24-
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
25-
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
26-
use Rector\ValueObject\MethodName;
27-
use Rector\ValueObject\Visibility;
28-
use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector;
29-
use Rector\Visibility\ValueObject\ChangeMethodVisibility;
306

317
# https://github.com/symfony/symfony/pull/28447
328

339
return static function (RectorConfig $rectorConfig): void {
34-
$rectorConfig->ruleWithConfiguration(NewToStaticCallRector::class, [
35-
new NewToStaticCall(
36-
'Symfony\Component\HttpFoundation\Cookie',
37-
'Symfony\Component\HttpFoundation\Cookie',
38-
'create'
39-
),
40-
]);
41-
42-
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
43-
# https://github.com/symfony/symfony/commit/a7e319d9e1316e2e18843f8ce15b67a8693e5bf9
44-
'Symfony\Bundle\FrameworkBundle\Controller\Controller' => 'Symfony\Bundle\FrameworkBundle\Controller\AbstractController',
45-
# https://github.com/symfony/symfony/commit/744bf0e7ac3ecf240d0bf055cc58f881bb0b3ec0
46-
'Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand' => 'Symfony\Component\Console\Command\Command',
47-
'Symfony\Component\Translation\TranslatorInterface' => 'Symfony\Contracts\Translation\TranslatorInterface',
48-
]);
49-
50-
$rectorConfig->rules([
51-
# https://symfony.com/blog/new-in-symfony-4-2-important-deprecations
52-
StringToArrayArgumentProcessRector::class,
53-
RootNodeTreeBuilderRector::class,
54-
]);
55-
56-
$rectorConfig->ruleWithConfiguration(ArgumentAdderRector::class, [
57-
new ArgumentAdder(
58-
'Symfony\Component\DomCrawler\Crawler',
59-
'children',
60-
0,
61-
null,
62-
null,
63-
null,
64-
ArgumentAddingScope::SCOPE_METHOD_CALL
65-
),
66-
new ArgumentAdder(
67-
'Symfony\Component\Finder\Finder',
68-
'sortByName',
69-
0,
70-
null,
71-
false,
72-
null,
73-
ArgumentAddingScope::SCOPE_METHOD_CALL
74-
),
75-
new ArgumentAdder(
76-
'Symfony\Bridge\Monolog\Processor\DebugProcessor',
77-
'getLogs',
78-
0,
79-
null,
80-
null,
81-
null,
82-
ArgumentAddingScope::SCOPE_METHOD_CALL
83-
),
84-
new ArgumentAdder(
85-
'Symfony\Bridge\Monolog\Processor\DebugProcessor',
86-
'countErrors',
87-
0,
88-
'default_value',
89-
null,
90-
null,
91-
ArgumentAddingScope::SCOPE_METHOD_CALL
92-
),
93-
new ArgumentAdder(
94-
'Symfony\Bridge\Monolog\Logger',
95-
'getLogs',
96-
0,
97-
'default_value',
98-
null,
99-
null,
100-
ArgumentAddingScope::SCOPE_METHOD_CALL
101-
),
102-
new ArgumentAdder(
103-
'Symfony\Bridge\Monolog\Logger',
104-
'countErrors',
105-
0,
106-
'default_value',
107-
null,
108-
null,
109-
ArgumentAddingScope::SCOPE_METHOD_CALL
110-
),
111-
new ArgumentAdder(
112-
'Symfony\Component\Serializer\Normalizer',
113-
'handleCircularReference',
114-
1,
115-
null,
116-
null,
117-
null,
118-
ArgumentAddingScope::SCOPE_METHOD_CALL
119-
),
120-
new ArgumentAdder(
121-
'Symfony\Component\Serializer\Normalizer',
122-
'handleCircularReference',
123-
2,
124-
null,
125-
null,
126-
null,
127-
ArgumentAddingScope::SCOPE_METHOD_CALL
128-
),
129-
]);
130-
131-
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
132-
new MethodCallRename('Symfony\Component\Cache\CacheItem', 'getPreviousTags', 'getMetadata'),
133-
new MethodCallRename('Symfony\Component\Form\AbstractTypeExtension', 'getExtendedType', 'getExtendedTypes'),
134-
]);
135-
136-
$iterableType = new IterableType(new MixedType(), new MixedType());
137-
138-
$rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [
139-
new AddReturnTypeDeclaration(
140-
'Symfony\Component\Form\AbstractTypeExtension',
141-
'getExtendedTypes',
142-
$iterableType
143-
),
144-
]);
145-
146-
$rectorConfig->ruleWithConfiguration(ChangeMethodVisibilityRector::class, [new ChangeMethodVisibility(
147-
'Symfony\Component\Form\AbstractTypeExtension',
148-
'getExtendedTypes',
149-
Visibility::STATIC
150-
),
151-
]);
152-
153-
$rectorConfig->ruleWithConfiguration(
154-
WrapReturnRector::class,
155-
[new WrapReturn('Symfony\Component\Form\AbstractTypeExtension', 'getExtendedTypes', true)]
156-
);
157-
158-
// https://github.com/symfony/symfony/commit/9493cfd5f2366dab19bbdde0d0291d0575454567
159-
$rectorConfig->ruleWithConfiguration(ReplaceArgumentDefaultValueRector::class, [
160-
new ReplaceArgumentDefaultValue(
161-
'Symfony\Component\HttpFoundation\Cookie',
162-
MethodName::CONSTRUCT,
163-
5,
164-
false,
165-
null
166-
),
167-
new ReplaceArgumentDefaultValue(
168-
'Symfony\Component\HttpFoundation\Cookie',
169-
MethodName::CONSTRUCT,
170-
8,
171-
null,
172-
'lax'
173-
),
174-
]);
175-
176-
# https://github.com/symfony/symfony/commit/f5c355e1ba399a1b3512367647d902148bdaf09f
177-
$rectorConfig->ruleWithConfiguration(ArgumentRemoverRector::class, [
178-
new ArgumentRemover(
179-
'Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector',
180-
MethodName::CONSTRUCT,
181-
0,
182-
null
183-
),
184-
new ArgumentRemover(
185-
'Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector',
186-
MethodName::CONSTRUCT,
187-
1,
188-
null
189-
),
190-
]);
10+
$rectorConfig->import(__DIR__ . '/symfony42/symfony42-http-foundation.php');
11+
$rectorConfig->import(__DIR__ . '/symfony42/symfony42-http-kernel.php');
12+
$rectorConfig->import(__DIR__ . '/symfony42/symfony42-framework-bundle.php');
13+
$rectorConfig->import(__DIR__ . '/symfony42/symfony42-translation.php');
14+
$rectorConfig->import(__DIR__ . '/symfony42/symfony42-process.php');
15+
$rectorConfig->import(__DIR__ . '/symfony42/symfony42-config.php');
16+
$rectorConfig->import(__DIR__ . '/symfony42/symfony42-dom-crawler.php');
17+
$rectorConfig->import(__DIR__ . '/symfony42/symfony42-finder.php');
18+
$rectorConfig->import(__DIR__ . '/symfony42/symfony42-monolog-bridge.php');
19+
$rectorConfig->import(__DIR__ . '/symfony42/symfony42-serializer.php');
20+
$rectorConfig->import(__DIR__ . '/symfony42/symfony42-forms.php');
21+
$rectorConfig->import(__DIR__ . '/symfony42/symfony42-cache.php');
19122
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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\Cache\CacheItem', 'getPreviousTags', 'getMetadata'),
12+
]);
13+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Symfony\Symfony42\Rector\New_\RootNodeTreeBuilderRector;
7+
8+
return static function (RectorConfig $rectorConfig): void {
9+
$rectorConfig->rules([
10+
// https://symfony.com/blog/new-in-symfony-4-2-important-deprecations
11+
RootNodeTreeBuilderRector::class,
12+
]);
13+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Arguments\NodeAnalyzer\ArgumentAddingScope;
6+
use Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector;
7+
use Rector\Arguments\ValueObject\ArgumentAdder;
8+
use Rector\Config\RectorConfig;
9+
10+
return static function (RectorConfig $rectorConfig): void {
11+
$rectorConfig->ruleWithConfiguration(ArgumentAdderRector::class, [
12+
new ArgumentAdder(
13+
'Symfony\Component\DomCrawler\Crawler',
14+
'children',
15+
0,
16+
null,
17+
null,
18+
null,
19+
ArgumentAddingScope::SCOPE_METHOD_CALL
20+
),
21+
]);
22+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector;
6+
use Rector\Arguments\ValueObject\ArgumentAdder;
7+
use Rector\Config\RectorConfig;
8+
9+
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->ruleWithConfiguration(ArgumentAdderRector::class, [
11+
new ArgumentAdder(
12+
'Symfony\Component\Finder\Finder',
13+
'sortByName',
14+
0,
15+
null,
16+
false,
17+
null,
18+
\Rector\Arguments\NodeAnalyzer\ArgumentAddingScope::SCOPE_METHOD_CALL
19+
),
20+
]);
21+
};
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PHPStan\Type\MixedType;
6+
use Rector\Config\RectorConfig;
7+
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
8+
use Rector\Renaming\ValueObject\MethodCallRename;
9+
10+
return static function (RectorConfig $rectorConfig): void {
11+
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
12+
new MethodCallRename('Symfony\Component\Form\AbstractTypeExtension', 'getExtendedType', 'getExtendedTypes'),
13+
]);
14+
15+
$iterableType = new \PHPStan\Type\IterableType(new MixedType(), new MixedType());
16+
17+
$rectorConfig->ruleWithConfiguration(
18+
\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class,
19+
[
20+
new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration(
21+
'Symfony\Component\Form\AbstractTypeExtension',
22+
'getExtendedTypes',
23+
$iterableType
24+
),
25+
]
26+
);
27+
28+
$rectorConfig->ruleWithConfiguration(
29+
\Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector::class,
30+
[new \Rector\Visibility\ValueObject\ChangeMethodVisibility(
31+
'Symfony\Component\Form\AbstractTypeExtension',
32+
'getExtendedTypes',
33+
\Rector\ValueObject\Visibility::STATIC
34+
),
35+
]
36+
);
37+
38+
$rectorConfig->ruleWithConfiguration(
39+
\Rector\Transform\Rector\ClassMethod\WrapReturnRector::class,
40+
[
41+
new \Rector\Transform\ValueObject\WrapReturn(
42+
'Symfony\Component\Form\AbstractTypeExtension',
43+
'getExtendedTypes',
44+
true
45+
),
46+
]
47+
);
48+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Renaming\Rector\Name\RenameClassRector;
7+
8+
return static function (RectorConfig $rectorConfig): void {
9+
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
10+
# https://github.com/symfony/symfony/commit/a7e319d9e1316e2e18843f8ce15b67a8693e5bf9
11+
'Symfony\Bundle\FrameworkBundle\Controller\Controller' => 'Symfony\Bundle\FrameworkBundle\Controller\AbstractController',
12+
# https://github.com/symfony/symfony/commit/744bf0e7ac3ecf240d0bf055cc58f881bb0b3ec0
13+
]);
14+
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector;
6+
use Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue;
7+
use Rector\Config\RectorConfig;
8+
use Rector\Transform\Rector\New_\NewToStaticCallRector;
9+
use Rector\Transform\ValueObject\NewToStaticCall;
10+
use Rector\ValueObject\MethodName;
11+
12+
return static function (RectorConfig $rectorConfig): void {
13+
$rectorConfig->ruleWithConfiguration(NewToStaticCallRector::class, [
14+
new NewToStaticCall(
15+
'Symfony\Component\HttpFoundation\Cookie',
16+
'Symfony\Component\HttpFoundation\Cookie',
17+
'create'
18+
),
19+
]);
20+
21+
// https://github.com/symfony/symfony/commit/9493cfd5f2366dab19bbdde0d0291d0575454567
22+
$rectorConfig->ruleWithConfiguration(ReplaceArgumentDefaultValueRector::class, [
23+
new ReplaceArgumentDefaultValue(
24+
'Symfony\Component\HttpFoundation\Cookie',
25+
MethodName::CONSTRUCT,
26+
5,
27+
false,
28+
null
29+
),
30+
new ReplaceArgumentDefaultValue(
31+
'Symfony\Component\HttpFoundation\Cookie',
32+
MethodName::CONSTRUCT,
33+
8,
34+
null,
35+
'lax'
36+
),
37+
]);
38+
};

0 commit comments

Comments
 (0)