2424class CallToDeprecatedStaticMethodRule implements Rule
2525{
2626
27- /** @var ReflectionProvider */
28- private $ reflectionProvider ;
27+ private ReflectionProvider $ reflectionProvider ;
2928
30- /** @var RuleLevelHelper */
31- private $ ruleLevelHelper ;
29+ private RuleLevelHelper $ ruleLevelHelper ;
3230
33- /** @var DeprecatedScopeHelper */
34- private $ deprecatedScopeHelper ;
31+ private DeprecatedScopeHelper $ deprecatedScopeHelper ;
3532
3633 public function __construct (ReflectionProvider $ reflectionProvider , RuleLevelHelper $ ruleLevelHelper , DeprecatedScopeHelper $ deprecatedScopeHelper )
3734 {
@@ -65,9 +62,7 @@ public function processNode(Node $node, Scope $scope): array
6562 $ scope ,
6663 $ node ->class ,
6764 '' , // 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 (),
7166 );
7267
7368 if ($ classTypeResult ->getType () instanceof ErrorType) {
@@ -96,15 +91,15 @@ static function (Type $type) use ($methodName): bool {
9691 'Call to method %s() of deprecated %s %s. ' ,
9792 $ methodReflection ->getName (),
9893 strtolower ($ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()),
99- $ methodReflection ->getDeclaringClass ()->getName ()
94+ $ methodReflection ->getDeclaringClass ()->getName (),
10095 ))->identifier (sprintf ('staticMethod.deprecated%s ' , $ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()))->build ();
10196 } else {
10297 $ errors [] = RuleErrorBuilder::message (sprintf (
10398 "Call to method %s() of deprecated %s %s: \n%s " ,
10499 $ methodReflection ->getName (),
105100 strtolower ($ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()),
106101 $ methodReflection ->getDeclaringClass ()->getName (),
107- $ classDescription
102+ $ classDescription,
108103 ))->identifier (sprintf ('staticMethod.deprecated%s ' , $ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()))->build ();
109104 }
110105 }
@@ -119,15 +114,15 @@ static function (Type $type) use ($methodName): bool {
119114 'Call to deprecated method %s() of %s %s. ' ,
120115 $ methodReflection ->getName (),
121116 strtolower ($ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()),
122- $ methodReflection ->getDeclaringClass ()->getName ()
117+ $ methodReflection ->getDeclaringClass ()->getName (),
123118 ))->identifier ('staticMethod.deprecated ' )->build ();
124119 } else {
125120 $ errors [] = RuleErrorBuilder::message (sprintf (
126121 "Call to deprecated method %s() of %s %s: \n%s " ,
127122 $ methodReflection ->getName (),
128123 strtolower ($ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()),
129124 $ methodReflection ->getDeclaringClass ()->getName (),
130- $ description
125+ $ description,
131126 ))->identifier ('staticMethod.deprecated ' )->build ();
132127 }
133128 }
0 commit comments