24
24
class CallToDeprecatedStaticMethodRule implements Rule
25
25
{
26
26
27
- /** @var ReflectionProvider */
28
- private $ reflectionProvider ;
27
+ private ReflectionProvider $ reflectionProvider ;
29
28
30
- /** @var RuleLevelHelper */
31
- private $ ruleLevelHelper ;
29
+ private RuleLevelHelper $ ruleLevelHelper ;
32
30
33
- /** @var DeprecatedScopeHelper */
34
- private $ deprecatedScopeHelper ;
31
+ private DeprecatedScopeHelper $ deprecatedScopeHelper ;
35
32
36
33
public function __construct (ReflectionProvider $ reflectionProvider , RuleLevelHelper $ ruleLevelHelper , DeprecatedScopeHelper $ deprecatedScopeHelper )
37
34
{
@@ -65,9 +62,7 @@ public function processNode(Node $node, Scope $scope): array
65
62
$ scope ,
66
63
$ node ->class ,
67
64
'' , // We don't care about the error message
68
- static function (Type $ type ) use ($ methodName ): bool {
69
- return $ type ->canCallMethods ()->yes () && $ type ->hasMethod ($ methodName )->yes ();
70
- }
65
+ static fn (Type $ type ): bool => $ type ->canCallMethods ()->yes () && $ type ->hasMethod ($ methodName )->yes (),
71
66
);
72
67
73
68
if ($ classTypeResult ->getType () instanceof ErrorType) {
@@ -96,15 +91,15 @@ static function (Type $type) use ($methodName): bool {
96
91
'Call to method %s() of deprecated %s %s. ' ,
97
92
$ methodReflection ->getName (),
98
93
strtolower ($ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()),
99
- $ methodReflection ->getDeclaringClass ()->getName ()
94
+ $ methodReflection ->getDeclaringClass ()->getName (),
100
95
))->identifier (sprintf ('staticMethod.deprecated%s ' , $ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()))->build ();
101
96
} else {
102
97
$ errors [] = RuleErrorBuilder::message (sprintf (
103
98
"Call to method %s() of deprecated %s %s: \n%s " ,
104
99
$ methodReflection ->getName (),
105
100
strtolower ($ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()),
106
101
$ methodReflection ->getDeclaringClass ()->getName (),
107
- $ classDescription
102
+ $ classDescription,
108
103
))->identifier (sprintf ('staticMethod.deprecated%s ' , $ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()))->build ();
109
104
}
110
105
}
@@ -119,15 +114,15 @@ static function (Type $type) use ($methodName): bool {
119
114
'Call to deprecated method %s() of %s %s. ' ,
120
115
$ methodReflection ->getName (),
121
116
strtolower ($ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()),
122
- $ methodReflection ->getDeclaringClass ()->getName ()
117
+ $ methodReflection ->getDeclaringClass ()->getName (),
123
118
))->identifier ('staticMethod.deprecated ' )->build ();
124
119
} else {
125
120
$ errors [] = RuleErrorBuilder::message (sprintf (
126
121
"Call to deprecated method %s() of %s %s: \n%s " ,
127
122
$ methodReflection ->getName (),
128
123
strtolower ($ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()),
129
124
$ methodReflection ->getDeclaringClass ()->getName (),
130
- $ description
125
+ $ description,
131
126
))->identifier ('staticMethod.deprecated ' )->build ();
132
127
}
133
128
}
0 commit comments