1111use PHPStan \Reflection \MissingMethodFromReflectionException ;
1212use PHPStan \Reflection \ReflectionProvider ;
1313use PHPStan \Rules \Rule ;
14+ use PHPStan \Rules \RuleErrorBuilder ;
1415use PHPStan \Rules \RuleLevelHelper ;
1516use PHPStan \Type \ErrorType ;
1617use PHPStan \Type \Type ;
1718use function sprintf ;
19+ use function strtolower ;
1820
1921/**
2022 * @implements Rule<StaticCall>
@@ -86,18 +88,20 @@ static function (Type $type) use ($methodName): bool {
8688 if ($ class ->isDeprecated ()) {
8789 $ classDescription = $ class ->getDeprecatedDescription ();
8890 if ($ classDescription === null ) {
89- $ errors [] = sprintf (
90- 'Call to method %s() of deprecated class %s. ' ,
91+ $ errors [] = RuleErrorBuilder:: message ( sprintf (
92+ 'Call to method %s() of deprecated %s %s. ' ,
9193 $ methodReflection ->getName (),
94+ strtolower ($ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()),
9295 $ methodReflection ->getDeclaringClass ()->getName ()
93- );
96+ ))-> identifier ( sprintf ( ' staticMethod.deprecated%s ' , $ methodReflection -> getDeclaringClass ()-> getClassTypeDescription ()))-> build () ;
9497 } else {
95- $ errors [] = sprintf (
96- "Call to method %s() of deprecated class %s: \n%s " ,
98+ $ errors [] = RuleErrorBuilder:: message ( sprintf (
99+ "Call to method %s() of deprecated %s %s: \n%s " ,
97100 $ methodReflection ->getName (),
101+ strtolower ($ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()),
98102 $ methodReflection ->getDeclaringClass ()->getName (),
99103 $ classDescription
100- );
104+ ))-> identifier ( sprintf ( ' staticMethod.deprecated%s ' , $ methodReflection -> getDeclaringClass ()-> getClassTypeDescription ()))-> build () ;
101105 }
102106 }
103107
@@ -107,18 +111,20 @@ static function (Type $type) use ($methodName): bool {
107111
108112 $ description = $ methodReflection ->getDeprecatedDescription ();
109113 if ($ description === null ) {
110- $ errors [] = sprintf (
111- 'Call to deprecated method %s() of class %s. ' ,
114+ $ errors [] = RuleErrorBuilder:: message ( sprintf (
115+ 'Call to deprecated method %s() of %s %s. ' ,
112116 $ methodReflection ->getName (),
117+ strtolower ($ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()),
113118 $ methodReflection ->getDeclaringClass ()->getName ()
114- );
119+ ))-> identifier ( ' staticMethod.deprecated ' )-> build () ;
115120 } else {
116- $ errors [] = sprintf (
117- "Call to deprecated method %s() of class %s: \n%s " ,
121+ $ errors [] = RuleErrorBuilder:: message ( sprintf (
122+ "Call to deprecated method %s() of %s %s: \n%s " ,
118123 $ methodReflection ->getName (),
124+ strtolower ($ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()),
119125 $ methodReflection ->getDeclaringClass ()->getName (),
120126 $ description
121- );
127+ ))-> identifier ( ' staticMethod.deprecated ' )-> build () ;
122128 }
123129 }
124130
0 commit comments