Skip to content

MIR1600

InvalidAttribute

An attribute is applied to a target (class, method, property, parameter, etc.) that the attribute does not allow, or the arguments passed to the attribute do not match its constructor signature. PHP validates attribute targets at runtime; mir reports these violations statically.

<?php
#[\Attribute(\Attribute::TARGET_METHOD)]
class MethodOnly {}
#[MethodOnly] // applied to a class, but only METHOD is allowed
class MyClass {}

Apply the attribute only to the targets listed in its \Attribute declaration, and ensure the arguments match the attribute class constructor.