@@ -38,22 +38,27 @@ public function processNode(Node $node, Scope $scope): array
38
38
'class ' ,
39
39
);
40
40
41
- $ classReflection = $ scope ->getClassReflection ();
41
+ $ classReflection = $ node ->getClassReflection ();
42
42
if (
43
- $ classReflection !== null
44
- && ($ classReflection ->isReadOnly () || $ classReflection ->isEnum () || $ classReflection ->isInterface ())
43
+ $ classReflection ->isReadOnly ()
44
+ || $ classReflection ->isEnum ()
45
+ || $ classReflection ->isInterface ()
45
46
) {
46
- $ message = 'Attribute class AllowDynamicProperties cannot be used with readonly classes. ' ;
47
+ $ typeName = 'readonly class ' ;
48
+ $ identifier = 'class.allowDynamicPropertiesReadonly ' ;
47
49
if ($ classReflection ->isEnum ()) {
48
- $ message = 'Attribute class AllowDynamicProperties cannot be used with enums. ' ;
50
+ $ typeName = 'enum ' ;
51
+ $ identifier = 'class.allowDynamicPropertiesEnum ' ;
49
52
}
50
53
if ($ classReflection ->isInterface ()) {
51
- $ message = 'Attribute class AllowDynamicProperties cannot be used with interface. ' ;
54
+ $ typeName = 'interface ' ;
55
+ $ identifier = 'class.allowDynamicPropertiesInterface ' ;
52
56
}
53
57
54
58
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 ()
57
62
->build ();
58
63
}
59
64
}
0 commit comments