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.

Built-in attributes (#[Attribute], #[Override], #[Deprecated], …) on a target PHP rejects at compile time are reported as CompileError with PHP’s message instead.

<?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.