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>
@@ -90,18 +92,20 @@ static function (Type $type) use ($methodName): bool {
9092 if ($ class ->isDeprecated ()) {
9193 $ classDescription = $ class ->getDeprecatedDescription ();
9294 if ($ classDescription === null ) {
93- $ errors [] = sprintf (
94- 'Call to method %s() of deprecated class %s. ' ,
95+ $ errors [] = RuleErrorBuilder:: message ( sprintf (
96+ 'Call to method %s() of deprecated %s %s. ' ,
9597 $ methodReflection ->getName (),
98+ strtolower ($ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()),
9699 $ methodReflection ->getDeclaringClass ()->getName ()
97- );
100+ ))-> identifier ( sprintf ( ' staticMethod.deprecated%s ' , $ methodReflection -> getDeclaringClass ()-> getClassTypeDescription ()))-> build () ;
98101 } else {
99- $ errors [] = sprintf (
100- "Call to method %s() of deprecated class %s: \n%s " ,
102+ $ errors [] = RuleErrorBuilder:: message ( sprintf (
103+ "Call to method %s() of deprecated %s %s: \n%s " ,
101104 $ methodReflection ->getName (),
105+ strtolower ($ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()),
102106 $ methodReflection ->getDeclaringClass ()->getName (),
103107 $ classDescription
104- );
108+ ))-> identifier ( sprintf ( ' staticMethod.deprecated%s ' , $ methodReflection -> getDeclaringClass ()-> getClassTypeDescription ()))-> build () ;
105109 }
106110 }
107111
@@ -111,18 +115,20 @@ static function (Type $type) use ($methodName): bool {
111115
112116 $ description = $ methodReflection ->getDeprecatedDescription ();
113117 if ($ description === null ) {
114- $ errors [] = sprintf (
115- 'Call to deprecated method %s() of class %s. ' ,
118+ $ errors [] = RuleErrorBuilder:: message ( sprintf (
119+ 'Call to deprecated method %s() of %s %s. ' ,
116120 $ methodReflection ->getName (),
121+ strtolower ($ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()),
117122 $ methodReflection ->getDeclaringClass ()->getName ()
118- );
123+ ))-> identifier ( ' staticMethod.deprecated ' )-> build () ;
119124 } else {
120- $ errors [] = sprintf (
121- "Call to deprecated method %s() of class %s: \n%s " ,
125+ $ errors [] = RuleErrorBuilder:: message ( sprintf (
126+ "Call to deprecated method %s() of %s %s: \n%s " ,
122127 $ methodReflection ->getName (),
128+ strtolower ($ methodReflection ->getDeclaringClass ()->getClassTypeDescription ()),
123129 $ methodReflection ->getDeclaringClass ()->getName (),
124130 $ description
125- );
131+ ))-> identifier ( ' staticMethod.deprecated ' )-> build () ;
126132 }
127133 }
128134
0 commit comments