@@ -38,22 +38,27 @@ public function processNode(Node $node, Scope $scope): array
3838 'class ' ,
3939 );
4040
41- $ classReflection = $ scope ->getClassReflection ();
41+ $ classReflection = $ node ->getClassReflection ();
4242 if (
43- $ classReflection !== null
44- && ($ classReflection ->isReadOnly () || $ classReflection ->isEnum () || $ classReflection ->isInterface ())
43+ $ classReflection ->isReadOnly ()
44+ || $ classReflection ->isEnum ()
45+ || $ classReflection ->isInterface ()
4546 ) {
46- $ message = 'Attribute class AllowDynamicProperties cannot be used with readonly classes. ' ;
47+ $ typeName = 'readonly class ' ;
48+ $ identifier = 'class.allowDynamicPropertiesReadonly ' ;
4749 if ($ classReflection ->isEnum ()) {
48- $ message = 'Attribute class AllowDynamicProperties cannot be used with enums. ' ;
50+ $ typeName = 'enum ' ;
51+ $ identifier = 'class.allowDynamicPropertiesEnum ' ;
4952 }
5053 if ($ classReflection ->isInterface ()) {
51- $ message = 'Attribute class AllowDynamicProperties cannot be used with interface. ' ;
54+ $ typeName = 'interface ' ;
55+ $ identifier = 'class.allowDynamicPropertiesInterface ' ;
5256 }
5357
5458 if (count ($ classReflection ->getNativeReflection ()->getAttributes ('AllowDynamicProperties ' )) > 0 ) {
55- $ errors [] = RuleErrorBuilder::message ($ message )
56- ->identifier ('class.allowDynamicPropertiesReadonly ' )
59+ $ errors [] = RuleErrorBuilder::message (sprintf ('Attribute class AllowDynamicProperties cannot be used with %s. ' , $ typeName ))
60+ ->identifier ($ identifier )
61+ ->nonIgnorable ()
5762 ->build ();
5863 }
5964 }
0 commit comments