1.2.26. Already Parents Trait

Trait is already used a parent’s class or trait. There is no use to include it a second time, so one of them can be removed.

<?php

trait ta {
    use tb;
}

trait t1 {
    use ta;
    use tb; // also used by ta
}

class b {
    use t1; // also required by class c
    use ta; // also required by trait t1
}

class c extends b {
    use t1;
}

?>

See also Traits.

1.2.26.1. Suggestions

  • Eliminate the trait in the parent class

  • Eliminate the trait in the child class

1.2.26.2. Specs

Short name

Traits/AlreadyParentsTrait

Rulesets

All, Analyze

Exakat since

1.8.0

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Features

trait

Available in

Entreprise Edition, Exakat Cloud