Skip to content

Commit c4e286c

Browse files
committed
More fixes
1 parent 37fd929 commit c4e286c

5 files changed

+29
-33
lines changed

config/sets/type-declaration/eloquent.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<?php
22

33
use PHPStan\Type\ObjectType;
4+
use PHPStan\Type\StringType;
45
use Rector\Config\RectorConfig;
56
use Rector\TypeDeclaration\Rector\FunctionLike\AddParamTypeForFunctionLikeWithinCallLikeArgDeclarationRector;
67
use Rector\TypeDeclaration\ValueObject\AddParamTypeForFunctionLikeWithinCallLikeArgDeclaration;
8+
use RectorLaravel\Util\AddParamTypeForFunctionLikeWithinCallLikeArgDeclarationRectorConfigGenerator;
79

810
return static function (RectorConfig $rectorConfig): void {
911
$rectorConfig->import(__DIR__ . '/../../config.php');
1012

11-
$generator = new \RectorLaravel\Util\AddParamTypeForFunctionLikeWithinCallLikeArgDeclarationRectorConfigGenerator;
13+
$generator = new AddParamTypeForFunctionLikeWithinCallLikeArgDeclarationRectorConfigGenerator;
1214

1315
$builderClass = new ObjectType(
1416
'Illuminate\Contracts\Database\Query\Builder'
@@ -144,7 +146,7 @@
144146
'handleLazyLoadingViolationUsing',
145147
0,
146148
1,
147-
new \PHPStan\Type\StringType,
149+
new StringType,
148150
),
149151
]
150152
);

config/sets/type-declaration/service-container.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@
1919

2020
$ruleConfiguration = [];
2121

22-
foreach ($classesToApplyTo as $targetClass) {
22+
foreach ($classesToApplyTo as $classToApplyTo) {
2323
foreach ([
2424
'bind', 'bindIf', 'singleton', 'singletonIf', 'scoped', 'scopedIf',
2525
] as $method) {
2626
$ruleConfiguration[] = new AddParamTypeForFunctionLikeWithinCallLikeArgDeclaration(
27-
$targetClass,
27+
$classToApplyTo,
2828
$method,
2929
1,
3030
0,
3131
$applicationClass,
3232
);
3333
}
3434
$ruleConfiguration[] = new AddParamTypeForFunctionLikeWithinCallLikeArgDeclaration(
35-
$targetClass,
35+
$classToApplyTo,
3636
'resolving',
3737
1,
3838
1,
3939
$applicationClass,
4040
);
4141
$ruleConfiguration[] = new AddParamTypeForFunctionLikeWithinCallLikeArgDeclaration(
42-
$targetClass,
42+
$classToApplyTo,
4343
'extends',
4444
1,
4545
1,

config/sets/type-declaration/validation.php

+17-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
use PHPStan\Type\MixedType;
4+
use PHPStan\Type\ObjectType;
5+
use PHPStan\Type\StringType;
36
use Rector\Config\RectorConfig;
47
use Rector\TypeDeclaration\Rector\FunctionLike\AddParamTypeForFunctionLikeWithinCallLikeArgDeclarationRector;
58
use Rector\TypeDeclaration\ValueObject\AddParamTypeForFunctionLikeWithinCallLikeArgDeclaration;
@@ -22,21 +25,21 @@
2225
'make',
2326
1,
2427
0,
25-
new \PHPStan\Type\StringType,
28+
new StringType,
2629
),
2730
new AddParamTypeForFunctionLikeWithinCallLikeArgDeclaration(
2831
$targetClass,
2932
'make',
3033
1,
3134
1,
32-
new \PHPStan\Type\MixedType(true),
35+
new MixedType(true),
3336
),
3437
new AddParamTypeForFunctionLikeWithinCallLikeArgDeclaration(
3538
$targetClass,
3639
'make',
3740
1,
3841
2,
39-
new \PHPStan\Type\ObjectType('Closure'),
42+
new ObjectType('Closure'),
4043
),
4144
]
4245
);
@@ -50,21 +53,21 @@
5053
'validate',
5154
0,
5255
0,
53-
new \PHPStan\Type\StringType,
56+
new StringType,
5457
),
5558
new AddParamTypeForFunctionLikeWithinCallLikeArgDeclaration(
5659
'Illuminate\Http\Request',
5760
'validate',
5861
0,
5962
1,
60-
new \PHPStan\Type\MixedType(true),
63+
new MixedType(true),
6164
),
6265
new AddParamTypeForFunctionLikeWithinCallLikeArgDeclaration(
6366
'Illuminate\Http\Request',
6467
'validate',
6568
0,
6669
2,
67-
new \PHPStan\Type\ObjectType('Closure'),
70+
new ObjectType('Closure'),
6871
),
6972
]
7073
);
@@ -77,7 +80,7 @@
7780
'after',
7881
0,
7982
0,
80-
new \PHPStan\Type\ObjectType('Illuminate\Contracts\Validation\Validator'),
83+
new ObjectType('Illuminate\Contracts\Validation\Validator'),
8184
),
8285
]
8386
);
@@ -90,14 +93,14 @@
9093
'sometimes',
9194
2,
9295
0,
93-
new \PHPStan\Type\ObjectType('Illuminate\Support\Fluent'),
96+
new ObjectType('Illuminate\Support\Fluent'),
9497
),
9598
new AddParamTypeForFunctionLikeWithinCallLikeArgDeclaration(
9699
'Illuminate\Contracts\Validation\Validator',
97100
'sometimes',
98101
2,
99102
1,
100-
new \PHPStan\Type\MixedType(true),
103+
new MixedType(true),
101104
),
102105
]
103106
);
@@ -110,14 +113,14 @@
110113
'forEach',
111114
0,
112115
0,
113-
new \PHPStan\Type\MixedType(true),
116+
new MixedType(true),
114117
),
115118
new AddParamTypeForFunctionLikeWithinCallLikeArgDeclaration(
116119
'Illuminate\Validation\Rule',
117120
'forEach',
118121
0,
119122
1,
120-
new \PHPStan\Type\StringType,
123+
new StringType,
121124
),
122125
]
123126
);
@@ -130,21 +133,21 @@
130133
'where',
131134
0,
132135
0,
133-
new \PHPStan\Type\ObjectType('Illuminate\Contracts\Database\Query\Builder'),
136+
new ObjectType('Illuminate\Contracts\Database\Query\Builder'),
134137
),
135138
new AddParamTypeForFunctionLikeWithinCallLikeArgDeclaration(
136139
'Illuminate\Validation\Rules\Exists',
137140
'where',
138141
1,
139142
0,
140-
new \PHPStan\Type\ObjectType('Illuminate\Contracts\Database\Query\Builder'),
143+
new ObjectType('Illuminate\Contracts\Database\Query\Builder'),
141144
),
142145
new AddParamTypeForFunctionLikeWithinCallLikeArgDeclaration(
143146
'Illuminate\Validation\Rules\Exists',
144147
'using',
145148
0,
146149
0,
147-
new \PHPStan\Type\ObjectType('Illuminate\Contracts\Database\Query\Builder'),
150+
new ObjectType('Illuminate\Contracts\Database\Query\Builder'),
148151
),
149152
]
150153
);

src/Rector/Param/AddParamTypeForFunctionLikeWithinCallLikeArgArrayValuesDeclarationRector.php

-9
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,8 @@ class AddParamTypeForFunctionLikeWithinCallLikeArgArrayValuesDeclarationRector e
4646
private $hasChanged = false;
4747

4848
public function __construct(
49-
/**
50-
* @readonly
51-
*/
5249
private readonly TypeComparator $typeComparator,
53-
/**
54-
* @readonly
55-
*/
5650
private readonly PhpVersionProvider $phpVersionProvider,
57-
/**
58-
* @readonly
59-
*/
6051
private readonly StaticTypeMapper $staticTypeMapper
6152
) {
6253
}

src/Util/AddParamTypeForFunctionLikeWithinCallLikeArgDeclarationRectorConfigGenerator.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ public function generate(
1818
array $targetClasses,
1919
int $functionPosition,
2020
string $methodName,
21-
ObjectType $type
21+
ObjectType $objectType
2222
): array {
2323
$configurations = [];
2424

25-
foreach ($callPositionsOrNames as $callPositionsOrName) {
25+
foreach ($callPositionsOrNames as $callPositionOrName) {
2626
foreach ($targetClasses as $targetClass) {
2727
$configurations[] = new AddParamTypeForFunctionLikeWithinCallLikeArgDeclaration(
2828
$targetClass,
2929
$methodName,
30-
$callPositionsOrName,
30+
$callPositionOrName,
3131
$functionPosition,
32-
$type
32+
$objectType
3333
);
3434
}
3535
}

0 commit comments

Comments
 (0)