Skip to content

Commit 5ff23b0

Browse files
authored
[symfony 60] split of configs per package (#740)
* [symfony 60] split of configs per package * add symfony-contracts * add symfony-contracts * add symfony-config * add framework-bundle * add doctrine-bridge * add security core
1 parent b7bb936 commit 5ff23b0

8 files changed

Lines changed: 172 additions & 68 deletions

File tree

config/sets/symfony/symfony6/symfony60.php

Lines changed: 8 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,78 +2,19 @@
22

33
declare(strict_types=1);
44

5-
use PhpParser\Node\Scalar\String_;
6-
use PHPStan\Type\MixedType;
7-
use PHPStan\Type\ObjectType;
85
use Rector\Config\RectorConfig;
9-
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
10-
use Rector\Renaming\Rector\Name\RenameClassRector;
11-
use Rector\Renaming\ValueObject\MethodCallRename;
12-
use Rector\Symfony\Set\SymfonySetList;
13-
use Rector\Symfony\Symfony60\Rector\FuncCall\ReplaceServiceArgumentRector;
14-
use Rector\Symfony\Symfony60\Rector\MethodCall\GetHelperControllerToServiceRector;
15-
use Rector\Symfony\ValueObject\ReplaceServiceArgument;
16-
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
17-
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;
186

197
# https://github.com/symfony/symfony/blob/6.1/UPGRADE-6.0.md
208

219
return static function (RectorConfig $rectorConfig): void {
22-
$rectorConfig->sets([SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES]);
10+
// $rectorConfig->sets([SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES]);
2311

24-
$rectorConfig->import(__DIR__ . '/symfony-return-types.php');
25-
$rectorConfig->ruleWithConfiguration(ReplaceServiceArgumentRector::class, [
26-
new ReplaceServiceArgument('Psr\Container\ContainerInterface', new String_('service_container')),
27-
new ReplaceServiceArgument(
28-
'Symfony\Component\DependencyInjection\ContainerInterface',
29-
new String_('service_container')
30-
),
31-
]);
12+
$rectorConfig->import(__DIR__ . '/symfony-return-types.php'); // todo: extract this as well
3213

33-
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
34-
// @see https://github.com/symfony/symfony/pull/39484
35-
'Symfony\Contracts\HttpClient\HttpClientInterface\RemoteJsonManifestVersionStrategy' => 'Symfony\Component\Asset\VersionStrategy\JsonManifestVersionStrategy',
36-
]);
37-
38-
$rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [
39-
new AddParamTypeDeclaration(
40-
'Symfony\Component\Config\Loader\LoaderInterface',
41-
'load',
42-
0,
43-
new MixedType(true)
44-
),
45-
new AddParamTypeDeclaration(
46-
'Symfony\Component\Config\Loader\LoaderInterface',
47-
'supports',
48-
0,
49-
new MixedType(true)
50-
),
51-
new AddParamTypeDeclaration(
52-
'Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait',
53-
'configureRoutes',
54-
0,
55-
new ObjectType('Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator'),
56-
),
57-
]);
58-
59-
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
60-
// @see https://github.com/symfony/symfony/pull/40403
61-
new MethodCallRename(
62-
'Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface',
63-
'loadUserByUsername',
64-
'loadUserByIdentifier'
65-
),
66-
new MethodCallRename(
67-
'Symfony\Component\Security\Core\User\UserProviderInterface',
68-
'loadUserByUsername',
69-
'loadUserByIdentifier',
70-
),
71-
// @see https://github.com/rectorphp/rector-symfony/issues/112
72-
new MethodCallRename(
73-
'Symfony\Component\Security\Core\User\UserInterface',
74-
'getUsername',
75-
'getUserIdentifier',
76-
),
77-
]);
78-
$rectorConfig->rule(GetHelperControllerToServiceRector::class);
14+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-dependency-injection.php');
15+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-contracts.php');
16+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-config.php');
17+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-framework-bundle.php');
18+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-doctrine-bridge.php');
19+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-security-core.php');
7920
};
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 PHPStan\Type\MixedType;
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+
new AddParamTypeDeclaration(
13+
'Symfony\Component\Config\Loader\LoaderInterface',
14+
'load',
15+
0,
16+
new MixedType(true)
17+
),
18+
new AddParamTypeDeclaration(
19+
'Symfony\Component\Config\Loader\LoaderInterface',
20+
'supports',
21+
0,
22+
new MixedType(true)
23+
),
24+
]);
25+
};
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\Name\RenameClassRector;
7+
8+
return static function (RectorConfig $rectorConfig): void {
9+
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
10+
// @see https://github.com/symfony/symfony/pull/39484
11+
'Symfony\Contracts\HttpClient\HttpClientInterface\RemoteJsonManifestVersionStrategy' => 'Symfony\Component\Asset\VersionStrategy\JsonManifestVersionStrategy',
12+
]);
13+
};
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 PhpParser\Node\Scalar\String_;
6+
use Rector\Config\RectorConfig;
7+
use Rector\Symfony\Symfony60\Rector\FuncCall\ReplaceServiceArgumentRector;
8+
use Rector\Symfony\ValueObject\ReplaceServiceArgument;
9+
10+
return static function (RectorConfig $rectorConfig): void {
11+
$rectorConfig->ruleWithConfiguration(ReplaceServiceArgumentRector::class, [
12+
new ReplaceServiceArgument('Psr\Container\ContainerInterface', new String_('service_container')),
13+
new ReplaceServiceArgument(
14+
'Symfony\Component\DependencyInjection\ContainerInterface',
15+
new String_('service_container')
16+
),
17+
]);
18+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
# https://github.com/symfony/symfony/blob/6.1/UPGRADE-6.0.md
10+
11+
return static function (RectorConfig $rectorConfig): void {
12+
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
13+
// @see https://github.com/symfony/symfony/pull/40403
14+
new MethodCallRename(
15+
'Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface',
16+
'loadUserByUsername',
17+
'loadUserByIdentifier'
18+
),
19+
]);
20+
};
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 PHPStan\Type\ObjectType;
6+
use Rector\Config\RectorConfig;
7+
use Rector\Symfony\Symfony60\Rector\MethodCall\GetHelperControllerToServiceRector;
8+
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
9+
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;
10+
11+
return static function (RectorConfig $rectorConfig): void {
12+
$rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [
13+
new AddParamTypeDeclaration(
14+
'Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait',
15+
'configureRoutes',
16+
0,
17+
new ObjectType('Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator'),
18+
),
19+
]);
20+
$rectorConfig->rule(GetHelperControllerToServiceRector::class);
21+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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(
12+
'Symfony\Component\Security\Core\User\UserProviderInterface',
13+
'loadUserByUsername',
14+
'loadUserByIdentifier',
15+
),
16+
// @see https://github.com/rectorphp/rector-symfony/issues/112
17+
new MethodCallRename(
18+
'Symfony\Component\Security\Core\User\UserInterface',
19+
'getUsername',
20+
'getUserIdentifier',
21+
),
22+
]);
23+
};

src/Set/SetProvider/Symfony6SetProvider.php

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,53 @@ public function provide(): array
1919
return [
2020
new ComposerTriggeredSet(
2121
SetGroup::SYMFONY,
22-
'symfony/*',
22+
'symfony/symfony',
2323
'6.0',
2424
__DIR__ . '/../../../config/sets/symfony/symfony6/symfony60.php'
2525
),
26+
27+
new ComposerTriggeredSet(
28+
SetGroup::SYMFONY,
29+
'symfony/dependency-injection',
30+
'6.0',
31+
__DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-dependency-injection.php'
32+
),
33+
34+
new ComposerTriggeredSet(
35+
SetGroup::SYMFONY,
36+
'symfony/contracts',
37+
'6.0',
38+
__DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-contracts.php'
39+
),
40+
41+
new ComposerTriggeredSet(
42+
SetGroup::SYMFONY,
43+
'symfony/config',
44+
'6.0',
45+
__DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-config.php'
46+
),
47+
48+
new ComposerTriggeredSet(
49+
SetGroup::SYMFONY,
50+
'symfony/framework-bundle',
51+
'6.0',
52+
__DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-framework-bundle.php'
53+
),
54+
55+
new ComposerTriggeredSet(
56+
SetGroup::SYMFONY,
57+
'symfony/doctrine-bridge',
58+
'6.0',
59+
__DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-doctrine-bridge.php'
60+
),
61+
62+
new ComposerTriggeredSet(
63+
SetGroup::SYMFONY,
64+
'symfony/security-core',
65+
'6.0',
66+
__DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-security-core.php'
67+
),
68+
2669
new ComposerTriggeredSet(
2770
SetGroup::SYMFONY,
2871
'symfony/*',

0 commit comments

Comments
 (0)