14
14
use PHPStan \Analyser \Scope ;
15
15
use SplFileInfo ;
16
16
use Symplify \Astral \Naming \SimpleNameResolver ;
17
- use Symplify \PHPStanRules \ParentGuard \ParentParamTypeGuard ;
18
17
use Symplify \RuleDocGenerator \Contract \ConfigurableRuleInterface ;
19
18
use Symplify \RuleDocGenerator \ValueObject \CodeSample \ConfiguredCodeSample ;
20
19
use Symplify \RuleDocGenerator \ValueObject \RuleDefinition ;
@@ -35,7 +34,6 @@ final class PreferredClassRule extends AbstractSymplifyRule implements Configura
35
34
*/
36
35
public function __construct (
37
36
private SimpleNameResolver $ simpleNameResolver ,
38
- private ParentParamTypeGuard $ parentParamTypeGuard ,
39
37
private array $ oldToPreferredClasses
40
38
) {
41
39
}
@@ -55,18 +53,18 @@ public function getNodeTypes(): array
55
53
public function process (Node $ node , Scope $ scope ): array
56
54
{
57
55
if ($ node instanceof New_) {
58
- return $ this ->processNew ($ node, $ scope );
56
+ return $ this ->processNew ($ node );
59
57
}
60
58
61
59
if ($ node instanceof Class_) {
62
60
return $ this ->processClass ($ node );
63
61
}
64
62
65
63
if ($ node instanceof StaticCall) {
66
- return $ this ->processStaticCall ($ node, $ scope );
64
+ return $ this ->processStaticCall ($ node );
67
65
}
68
66
69
- return $ this ->processClassName ($ node ->toString (), $ node , $ scope );
67
+ return $ this ->processClassName ($ node ->toString ());
70
68
}
71
69
72
70
public function getRuleDefinition (): RuleDefinition
@@ -107,14 +105,14 @@ public function run()
107
105
/**
108
106
* @return string[]
109
107
*/
110
- private function processNew (New_ $ new, Scope $ scope ): array
108
+ private function processNew (New_ $ new ): array
111
109
{
112
110
$ className = $ this ->simpleNameResolver ->getName ($ new ->class );
113
111
if ($ className === null ) {
114
112
return [];
115
113
}
116
114
117
- return $ this ->processClassName ($ className, $ new , $ scope );
115
+ return $ this ->processClassName ($ className );
118
116
}
119
117
120
118
/**
@@ -149,12 +147,8 @@ private function processClass(Class_ $class): array
149
147
/**
150
148
* @return string[]
151
149
*/
152
- private function processClassName (string $ className, Node $ node , Scope $ scope ): array
150
+ private function processClassName (string $ className ): array
153
151
{
154
- if ($ this ->parentParamTypeGuard ->isRequiredByContract ($ node , $ scope )) {
155
- return [];
156
- }
157
-
158
152
foreach ($ this ->oldToPreferredClasses as $ oldClass => $ prefferedClass ) {
159
153
if ($ className !== $ oldClass ) {
160
154
continue ;
@@ -170,14 +164,14 @@ private function processClassName(string $className, Node $node, Scope $scope):
170
164
/**
171
165
* @return string[]
172
166
*/
173
- private function processStaticCall (StaticCall $ staticCall, Scope $ scope ): array
167
+ private function processStaticCall (StaticCall $ staticCall ): array
174
168
{
175
169
if ($ staticCall ->class instanceof Expr) {
176
170
return [];
177
171
}
178
172
179
173
$ className = (string ) $ staticCall ->class ;
180
174
181
- return $ this ->processClassName ($ className, $ staticCall , $ scope );
175
+ return $ this ->processClassName ($ className );
182
176
}
183
177
}
0 commit comments