1.2.1120. Sidelined Method

A method, defined in a trait, which is overwritten by a class’s method. This makes the trait’s method useless and unreachable.

It is recommended to check if this is not a typo, as the trait may not be able to work correctly.

<?php

trait t {
     function name() : string { return 'abc'; }
     function foo() : string { return 'ddd'; }
}

class x {
     use t;

     // This method
     function name() : string { return 'bca'; }

     //function foo is imported from the trait
}

?>

1.2.1120.1. Suggestions

  • Check the naming of the function in the class

  • Use a ‘as’ expression to rename the trait’s method with another name

1.2.1120.2. Specs

Short name

Traits/SidelinedMethod

Rulesets

All, Class Review

Exakat since

2.5.2

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Available in

Entreprise Edition, Exakat Cloud