|
4 | 4 |
|
5 | 5 | use PhpParser\Node; |
6 | 6 | use PHPStan\Analyser\Scope; |
| 7 | +use PHPStan\Internal\SprintfHelper; |
7 | 8 | use PHPStan\Node\InClassNode; |
8 | 9 | use PHPStan\PhpDoc\Tag\ExtendsTag; |
9 | 10 | use PHPStan\PhpDoc\Tag\ImplementsTag; |
@@ -69,38 +70,40 @@ public function processNode(Node $node, Scope $scope): array |
69 | 70 | $implementsTags = $resolvedPhpDoc->getImplementsTags(); |
70 | 71 | } |
71 | 72 |
|
| 73 | + $escapedClassName = SprintfHelper::escapeFormatString($className); |
| 74 | + |
72 | 75 | $extendsErrors = $this->genericAncestorsCheck->check( |
73 | 76 | $originalNode->extends !== null ? [$originalNode->extends] : [], |
74 | 77 | array_map(static function (ExtendsTag $tag): Type { |
75 | 78 | return $tag->getType(); |
76 | 79 | }, $extendsTags), |
77 | | - sprintf('Class %s @extends tag contains incompatible type %%s.', $className), |
78 | | - sprintf('Class %s has @extends tag, but does not extend any class.', $className), |
79 | | - sprintf('The @extends tag of class %s describes %%s but the class extends %%s.', $className), |
| 80 | + sprintf('Class %s @extends tag contains incompatible type %%s.', $escapedClassName), |
| 81 | + sprintf('Class %s has @extends tag, but does not extend any class.', $escapedClassName), |
| 82 | + sprintf('The @extends tag of class %s describes %%s but the class extends %%s.', $escapedClassName), |
80 | 83 | 'PHPDoc tag @extends contains generic type %s but class %s is not generic.', |
81 | 84 | 'Generic type %s in PHPDoc tag @extends does not specify all template types of class %s: %s', |
82 | 85 | 'Generic type %s in PHPDoc tag @extends specifies %d template types, but class %s supports only %d: %s', |
83 | 86 | 'Type %s in generic type %s in PHPDoc tag @extends is not subtype of template type %s of class %s.', |
84 | 87 | 'PHPDoc tag @extends has invalid type %s.', |
85 | | - sprintf('Class %s extends generic class %%s but does not specify its types: %%s', $className), |
86 | | - sprintf('in extended type %%s of class %s', $className) |
| 88 | + sprintf('Class %s extends generic class %%s but does not specify its types: %%s', $escapedClassName), |
| 89 | + sprintf('in extended type %%s of class %s', $escapedClassName) |
87 | 90 | ); |
88 | 91 |
|
89 | 92 | $implementsErrors = $this->genericAncestorsCheck->check( |
90 | 93 | $originalNode->implements, |
91 | 94 | array_map(static function (ImplementsTag $tag): Type { |
92 | 95 | return $tag->getType(); |
93 | 96 | }, $implementsTags), |
94 | | - sprintf('Class %s @implements tag contains incompatible type %%s.', $className), |
95 | | - sprintf('Class %s has @implements tag, but does not implement any interface.', $className), |
96 | | - sprintf('The @implements tag of class %s describes %%s but the class implements: %%s', $className), |
| 97 | + sprintf('Class %s @implements tag contains incompatible type %%s.', $escapedClassName), |
| 98 | + sprintf('Class %s has @implements tag, but does not implement any interface.', $escapedClassName), |
| 99 | + sprintf('The @implements tag of class %s describes %%s but the class implements: %%s', $escapedClassName), |
97 | 100 | 'PHPDoc tag @implements contains generic type %s but interface %s is not generic.', |
98 | 101 | 'Generic type %s in PHPDoc tag @implements does not specify all template types of interface %s: %s', |
99 | 102 | 'Generic type %s in PHPDoc tag @implements specifies %d template types, but interface %s supports only %d: %s', |
100 | 103 | 'Type %s in generic type %s in PHPDoc tag @implements is not subtype of template type %s of interface %s.', |
101 | 104 | 'PHPDoc tag @implements has invalid type %s.', |
102 | | - sprintf('Class %s implements generic interface %%s but does not specify its types: %%s', $className), |
103 | | - sprintf('in implemented type %%s of class %s', $className) |
| 105 | + sprintf('Class %s implements generic interface %%s but does not specify its types: %%s', $escapedClassName), |
| 106 | + sprintf('in implemented type %%s of class %s', $escapedClassName) |
104 | 107 | ); |
105 | 108 |
|
106 | 109 | foreach ($this->crossCheckInterfacesHelper->check($classReflection) as $error) { |
|
0 commit comments