Skip to content

Commit 6de3184

Browse files
authored
[split symfony60] Extract symfony-return-types.php into symfony60* per package (#756)
* [split symfony60] Extract symfony-return-types.php into symfony60* per types * add security-http * add console * add dependeny injection * add security-core * add browser-kit * add browser-kit * celan up * add http-kernel * add validator * add form * add translation * add property-access * rollback property-info * add property-info * add more config * add routing * add templating * clean * clean * add event-dispatcher * add expression-language * add options-resolver * add options-resolver
1 parent 3234dd8 commit 6de3184

21 files changed

Lines changed: 1026 additions & 586 deletions

config/sets/symfony/symfony6/symfony-return-types.php

Lines changed: 0 additions & 584 deletions
This file was deleted.

config/sets/symfony/symfony6/symfony60.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,21 @@
99
return static function (RectorConfig $rectorConfig): void {
1010
// $rectorConfig->sets([SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES]);
1111

12-
$rectorConfig->import(__DIR__ . '/symfony-return-types.php'); // todo: extract this as well
13-
12+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-serializer.php');
13+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-security-http.php');
14+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-console.php');
15+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-browser-kit.php');
16+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-http-kernel.php');
17+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-validator.php');
18+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-form.php');
19+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-translation.php');
20+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-property-access.php');
21+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-property-info.php');
22+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-routing.php');
23+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-templating.php');
24+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-event-dispatcher.php');
25+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-expression-language.php');
26+
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-options-resolver.php');
1427
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-dependency-injection.php');
1528
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-contracts.php');
1629
$rectorConfig->import(__DIR__ . '/symfony60/symfony60-config.php');
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 PHPStan\Type\ObjectType;
6+
use PHPStan\Type\ObjectWithoutClassType;
7+
use Rector\Config\RectorConfig;
8+
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
9+
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
10+
11+
// https://github.com/symfony/symfony/blob/6.1/UPGRADE-6.0.md
12+
// @see https://github.com/symfony/symfony/blob/6.1/.github/expected-missing-return-types.diff
13+
14+
return static function (RectorConfig $rectorConfig): void {
15+
$browserKitResponseType = new ObjectType('Symfony\Component\BrowserKit\Response');
16+
$rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [
17+
new AddReturnTypeDeclaration(
18+
'Symfony\Component\BrowserKit\AbstractBrowser',
19+
'doRequestInProcess',
20+
new ObjectWithoutClassType()
21+
),
22+
new AddReturnTypeDeclaration(
23+
'Symfony\Component\BrowserKit\AbstractBrowser',
24+
'doRequest',
25+
new ObjectWithoutClassType()
26+
),
27+
new AddReturnTypeDeclaration(
28+
'Symfony\Component\BrowserKit\AbstractBrowser',
29+
'filterRequest',
30+
new ObjectWithoutClassType()
31+
),
32+
new AddReturnTypeDeclaration(
33+
'Symfony\Component\BrowserKit\AbstractBrowser',
34+
'filterResponse',
35+
$browserKitResponseType
36+
),
37+
]);
38+
};

config/sets/symfony/symfony6/symfony60/symfony60-config.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55
use PHPStan\Type\MixedType;
66
use Rector\Config\RectorConfig;
77
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
8+
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
89
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;
10+
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
11+
use PHPStan\Type\BooleanType;
12+
use PHPStan\Type\ObjectType;
13+
use PHPStan\Type\StringType;
14+
use PHPStan\Type\UnionType;
15+
use PHPStan\Type\ArrayType;
916

1017
return static function (RectorConfig $rectorConfig): void {
1118
$rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [
@@ -22,4 +29,47 @@
2229
new MixedType(true)
2330
),
2431
]);
32+
33+
$arrayType = new ArrayType(new MixedType(), new MixedType());
34+
35+
$rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [
36+
new AddReturnTypeDeclaration('Symfony\Component\Config\Loader\LoaderInterface', 'load', new MixedType()),
37+
new AddReturnTypeDeclaration('Symfony\Component\Config\Loader\Loader', 'import', new MixedType()),
38+
new AddReturnTypeDeclaration(
39+
'Symfony\Component\Config\Definition\ConfigurationInterface',
40+
'getConfigTreeBuilder',
41+
new ObjectType('Symfony\Component\Config\Definition\Builder\TreeBuilder')
42+
),
43+
new AddReturnTypeDeclaration('Symfony\Component\Config\FileLocator', 'locate', new UnionType([
44+
new StringType(),
45+
$arrayType,
46+
])),
47+
new AddReturnTypeDeclaration('Symfony\Component\Config\FileLocatorInterface', 'locate', new UnionType([
48+
new StringType(),
49+
$arrayType,
50+
])),
51+
new AddReturnTypeDeclaration('Symfony\Component\Config\Loader\FileLoader', 'import', new MixedType()),
52+
new AddReturnTypeDeclaration('Symfony\Component\Config\Loader\Loader', 'import', new MixedType()),
53+
new AddReturnTypeDeclaration('Symfony\Component\Config\Loader\LoaderInterface', 'load', new MixedType()),
54+
new AddReturnTypeDeclaration(
55+
'Symfony\Component\Config\Loader\LoaderInterface',
56+
'supports',
57+
new BooleanType()
58+
),
59+
new AddReturnTypeDeclaration(
60+
'Symfony\Component\Config\Loader\LoaderInterface',
61+
'getResolver',
62+
new ObjectType('Symfony\Component\Config\Loader\LoaderResolverInterface')
63+
),
64+
new AddReturnTypeDeclaration(
65+
'Symfony\Component\Config\ResourceCheckerInterface',
66+
'supports',
67+
new BooleanType()
68+
),
69+
new AddReturnTypeDeclaration(
70+
'Symfony\Component\Config\ResourceCheckerInterface',
71+
'isFresh',
72+
new BooleanType()
73+
),
74+
]);
2575
};
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PHPStan\Type\ArrayType;
6+
use PHPStan\Type\BooleanType;
7+
use PHPStan\Type\IntegerType;
8+
use PHPStan\Type\MixedType;
9+
use PHPStan\Type\NullType;
10+
use PHPStan\Type\ObjectType;
11+
use PHPStan\Type\StringType;
12+
use PHPStan\Type\UnionType;
13+
use Rector\Config\RectorConfig;
14+
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
15+
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
16+
17+
// https://github.com/symfony/symfony/blob/6.1/UPGRADE-6.0.md
18+
// @see https://github.com/symfony/symfony/blob/6.1/.github/expected-missing-return-types.diff
19+
20+
return static function (RectorConfig $rectorConfig): void {
21+
$arrayType = new ArrayType(new MixedType(), new MixedType());
22+
$commandType = new ObjectType('Symfony\Component\Console\Command\Command');
23+
24+
$rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [
25+
// @see https://github.com/symfony/symfony/pull/43028/files
26+
new AddReturnTypeDeclaration(
27+
'Symfony\Component\Console\Helper\HelperInterface',
28+
'getName',
29+
new StringType()
30+
),
31+
32+
new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'doRun', new IntegerType()),
33+
new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'getLongVersion', new StringType()),
34+
new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'add', new UnionType([
35+
new NullType(),
36+
$commandType,
37+
])),
38+
new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'get', $commandType),
39+
new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'find', $commandType),
40+
new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'all', $arrayType),
41+
new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'doRunCommand', new IntegerType()),
42+
new AddReturnTypeDeclaration('Symfony\Component\Console\Command\Command', 'isEnabled', new BooleanType()),
43+
new AddReturnTypeDeclaration('Symfony\Component\Console\Command\Command', 'execute', new IntegerType()),
44+
new AddReturnTypeDeclaration(
45+
'Symfony\Component\Console\Helper\HelperInterface',
46+
'getName',
47+
new StringType()
48+
),
49+
new AddReturnTypeDeclaration(
50+
'Symfony\Component\Console\Input\InputInterface',
51+
'getParameterOption',
52+
new MixedType()
53+
),
54+
new AddReturnTypeDeclaration(
55+
'Symfony\Component\Console\Input\InputInterface',
56+
'getArgument',
57+
new MixedType()
58+
),
59+
new AddReturnTypeDeclaration(
60+
'Symfony\Component\Console\Input\InputInterface',
61+
'getOption',
62+
new MixedType()
63+
),
64+
]);
65+
};

config/sets/symfony/symfony6/symfony60/symfony60-dependency-injection.php

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@
66
use Rector\Config\RectorConfig;
77
use Rector\Symfony\Symfony60\Rector\FuncCall\ReplaceServiceArgumentRector;
88
use Rector\Symfony\ValueObject\ReplaceServiceArgument;
9+
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
10+
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
11+
use PHPStan\Type\Constant\ConstantBooleanType;
12+
use PHPStan\Type\MixedType;
13+
use PHPStan\Type\NullType;
14+
use PHPStan\Type\ObjectType;
15+
use PHPStan\Type\ObjectWithoutClassType;
16+
use PHPStan\Type\StringType;
17+
use PHPStan\Type\UnionType;
18+
use PHPStan\Type\ArrayType;
19+
use PHPStan\Type\BooleanType;
20+
use PHPStan\Type\FloatType;
21+
use PHPStan\Type\IntegerType;
922

1023
return static function (RectorConfig $rectorConfig): void {
1124
$rectorConfig->ruleWithConfiguration(ReplaceServiceArgumentRector::class, [
@@ -15,4 +28,74 @@
1528
new String_('service_container')
1629
),
1730
]);
31+
32+
$configurationType = new ObjectType('Symfony\Component\Config\Definition\ConfigurationInterface');
33+
34+
$arrayType = new ArrayType(new MixedType(), new MixedType());
35+
$scalarTypes = [
36+
$arrayType,
37+
new BooleanType(),
38+
new StringType(),
39+
new IntegerType(),
40+
new FloatType(),
41+
new NullType(),
42+
];
43+
44+
$rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [
45+
new AddReturnTypeDeclaration(
46+
'Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass',
47+
'processValue',
48+
new MixedType()
49+
),
50+
new AddReturnTypeDeclaration(
51+
'Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface',
52+
'getConfiguration',
53+
new UnionType([new NullType(), $configurationType])
54+
),
55+
new AddReturnTypeDeclaration(
56+
'Symfony\Component\DependencyInjection\Extension\Extension',
57+
'getXsdValidationBasePath',
58+
new UnionType([new StringType(), new ConstantBooleanType(false)])
59+
),
60+
new AddReturnTypeDeclaration(
61+
'Symfony\Component\DependencyInjection\Extension\Extension',
62+
'getNamespace',
63+
new StringType()
64+
),
65+
new AddReturnTypeDeclaration(
66+
'Symfony\Component\DependencyInjection\Extension\Extension',
67+
'getConfiguration',
68+
new UnionType([new NullType(), $configurationType])
69+
),
70+
new AddReturnTypeDeclaration(
71+
'Symfony\Component\DependencyInjection\Extension\ExtensionInterface',
72+
'getNamespace',
73+
new StringType()
74+
),
75+
new AddReturnTypeDeclaration(
76+
'Symfony\Component\DependencyInjection\Extension\ExtensionInterface',
77+
'getXsdValidationBasePath',
78+
new UnionType([new StringType(), new ConstantBooleanType(false)])
79+
),
80+
new AddReturnTypeDeclaration(
81+
'Symfony\Component\DependencyInjection\Extension\ExtensionInterface',
82+
'getAlias',
83+
new StringType()
84+
),
85+
new AddReturnTypeDeclaration(
86+
'Symfony\Component\DependencyInjection\LazyProxy\Instantiator\InstantiatorInterface',
87+
'instantiateProxy',
88+
new ObjectWithoutClassType()
89+
),
90+
new AddReturnTypeDeclaration(
91+
'Symfony\Component\DependencyInjection\Container',
92+
'getParameter',
93+
new UnionType($scalarTypes)
94+
),
95+
new AddReturnTypeDeclaration(
96+
'Symfony\Component\DependencyInjection\ContainerInterface',
97+
'getParameter',
98+
new UnionType($scalarTypes)
99+
),
100+
]);
18101
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PHPStan\Type\ArrayType;
6+
use PHPStan\Type\MixedType;
7+
use Rector\Config\RectorConfig;
8+
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
9+
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
10+
11+
// https://github.com/symfony/symfony/blob/6.1/UPGRADE-6.0.md
12+
// @see https://github.com/symfony/symfony/blob/6.1/.github/expected-missing-return-types.diff
13+
14+
return static function (RectorConfig $rectorConfig): void {
15+
$arrayType = new ArrayType(new MixedType(), new MixedType());
16+
17+
$rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [
18+
new AddReturnTypeDeclaration(
19+
'Symfony\Component\EventDispatcher\EventSubscriberInterface',
20+
'getSubscribedEvents',
21+
$arrayType
22+
),
23+
]);
24+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PHPStan\Type\ArrayType;
6+
use PHPStan\Type\MixedType;
7+
use Rector\Config\RectorConfig;
8+
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
9+
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
10+
11+
// https://github.com/symfony/symfony/blob/6.1/UPGRADE-6.0.md
12+
// @see https://github.com/symfony/symfony/blob/6.1/.github/expected-missing-return-types.diff
13+
14+
return static function (RectorConfig $rectorConfig): void {
15+
$arrayType = new ArrayType(new MixedType(), new MixedType());
16+
17+
$rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [
18+
new AddReturnTypeDeclaration(
19+
'Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface',
20+
'getFunctions',
21+
$arrayType
22+
),
23+
]);
24+
};

0 commit comments

Comments
 (0)