@@ -41,38 +41,40 @@ public function processNode(Node $node, Scope $scope): array
4141 if (!isset ($ args [0 ])) {
4242 return [];
4343 }
44+
45+ $ messages = [];
4446 $ argType = $ scope ->getType ($ args [0 ]->value );
45- if (count ($ argType ->getConstantStrings ()) !== 1 ) {
46- return [];
47- }
48- $ argValue = $ argType ->getConstantScalarValues ()[0 ];
49- if (!in_array ($ argValue , ['parent ' , 'previous ' , 'next ' ], true )) {
50- return [];
51- }
52- if (!$ scope ->isInClass ()) {
53- return [];
54- }
47+ foreach ($ argType ->getConstantStrings () as $ constantString ) {
48+ $ argValue = $ constantString ->getValue ();
49+ if (!in_array ($ argValue , ['parent ' , 'previous ' , 'next ' ], true )) {
50+ continue ;
51+ }
5552
56- $ classReflection = $ scope ->getClassReflection ();
57- $ hasPhpStanInterface = false ;
58- foreach (array_keys ($ classReflection ->getInterfaces ()) as $ interfaceName ) {
59- if (!str_starts_with ($ interfaceName , 'PHPStan \\' )) {
53+ if (!$ scope ->isInClass ()) {
6054 continue ;
6155 }
6256
63- $ hasPhpStanInterface = true ;
64- }
57+ $ classReflection = $ scope ->getClassReflection ();
58+ $ hasPhpStanInterface = false ;
59+ foreach (array_keys ($ classReflection ->getInterfaces ()) as $ interfaceName ) {
60+ if (!str_starts_with ($ interfaceName , 'PHPStan \\' )) {
61+ continue ;
62+ }
6563
66- if (!$ hasPhpStanInterface ) {
67- return [];
68- }
64+ $ hasPhpStanInterface = true ;
65+ }
6966
70- return [
71- RuleErrorBuilder::message (sprintf ('Node attribute \'%s \' is no longer available. ' , $ argValue ))
67+ if (!$ hasPhpStanInterface ) {
68+ continue ;
69+ }
70+
71+ $ messages [] = RuleErrorBuilder::message (sprintf ('Node attribute \'%s \' is no longer available. ' , $ argValue ))
7272 ->identifier ('phpParser.nodeConnectingAttribute ' )
7373 ->tip ('See: https://phpstan.org/blog/preprocessing-ast-for-custom-rules ' )
74- ->build (),
75- ];
74+ ->build ();
75+ }
76+
77+ return $ messages ;
7678 }
7779
7880}
0 commit comments