1.2.1434. Wrong Attribute Configuration¶
A class is attributed to the wrong PHP structure.
<?php
#[Attribute(Attribute::TARGET_CLASS)]
class ClassAttribute { }
// Wrong
#[ClassAttribute]
function foo () {}
// OK
#[ClassAttribute]
class y {}
?>
See also Declaring Attribute Classes.
1.2.1434.1. Suggestions¶
Remove the attribute from the wrongly attributed structure
Extend the configuration of the attribute with Attribute::TARGET_*
1.2.1434.2. Specs¶
Short name |
Php/WrongAttributeConfiguration |
Rulesets |
|
Exakat since |
2.2.0 |
PHP Version |
With PHP 8.0 and more recent |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Features |
attribute |
Available in |