1.2.1444. Wrong Attribute Configuration¶
A class is attributed to the wrong PHP structure. A class may be an attribute, and it may also be configured to be used with different structures : classes, function, parameters, etc. When an attribute has a configuration, it must be used with the correct structure.
<?php
#[Attribute(Attribute::TARGET_CLASS)]
class ClassAttribute { }
// Wrong
#[ClassAttribute]
function foo () {}
// OK
#[ClassAttribute]
class y {}
?>
See also Declaring Attribute Classes.
1.2.1444.2. Connex PHP features¶
1.2.1444.2.1. Suggestions¶
Remove the attribute from the wrongly attributed structure
Extend the configuration of the attribute with Attribute::TARGET_*
1.2.1444.2.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 |
Available in |