1212use PHPStan \Analyser \Scope ;
1313use PHPStan \Broker \Broker ;
1414use PHPStan \Rules \Rule ;
15+ use PHPStan \Rules \RuleError ;
16+ use PHPStan \Rules \RuleErrorBuilder ;
1517
1618/**
1719 * @implements Rule<ClassLike>
@@ -30,23 +32,23 @@ public function getNodeType(): string
3032 return ClassLike::class;
3133 }
3234
33- /** @return string[] */
35+ /** @return list<RuleError> */
3436 public function processNode (Node $ node , Scope $ scope ): array
3537 {
36- $ messages = [];
3738 $ nodeIdentifier = $ node ->name ;
3839 if (null === $ nodeIdentifier ) {
39- return $ messages ;
40+ return [] ;
4041 }
4142 $ name = $ nodeIdentifier ->name ;
4243 if (\str_starts_with ($ name , 'AnonymousClass ' )) {
43- return $ messages ;
44+ return [] ;
4445 }
4546 if (null === $ node ->namespacedName ) {
46- return $ messages ;
47+ return [] ;
4748 }
4849
49- $ fqcn = $ node ->namespacedName ->toString ();
50+ $ messages = [];
51+ $ fqcn = $ node ->namespacedName ->toString ();
5052 if ($ node instanceof Interface_) {
5153 if (! \preg_match ('/Interface$/ ' , $ name )) {
5254 $ messages [] = \sprintf ('Interface %s should end with "Interface" suffix. ' , $ fqcn );
@@ -75,6 +77,8 @@ public function processNode(Node $node, Scope $scope): array
7577 }
7678 }
7779
78- return $ messages ;
80+ return \array_map (static function (string $ message ): RuleError {
81+ return RuleErrorBuilder::message ($ message )->identifier ('classNotation ' )->build ();
82+ }, $ messages );
7983 }
8084}
0 commit comments