1.2.1072. Self Using Trait¶
Trait uses itself : this is unnecessary. Traits may use themselves, or be used by other traits, that are using the initial trait itself.
PHP handles the situation quietly, by ignoring all extra use of the same trait, keeping only one valid version.
<?php
// empty, but valid
trait a {}
// obvious self usage
trait b { use b; }
// less obvious self usage
trait c { use d, e, f, g, h, c; }
// level 2 self usage
trait i { use j; }
trait j { use i; }
?>
See also Traits.
1.2.1072.1. Connex PHP features¶
1.2.1072.1.1. Suggestions¶
Remove the extra usage of the trait.
1.2.1072.1.2. Specs¶
Short name |
Traits/SelfUsingTrait |
Rulesets |
|
Exakat since |
1.5.7 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Slow (1 hour) |
Precision |
High |
Available in |