1.2.1247. Undefined Insteadof

Insteadof tries to replace a method with another, but it doesn’t exists. This happens when the replacing class is refactored, and some of its definition are dropped.

Insteadof may replace a non-existing method with an existing one, but not the contrary.

This error is not linted : it only appears at execution time.

<?php

trait A {
    function C (){}
}

trait B {
    function C (){}
}

class Talker {
    use A, B {
        B::C insteadof A;
        B::D insteadof A;
    }
}

new Talker();
?>

See also Traits.

1.2.1247.1. Suggestions

  • Remove the insteadof expression

  • Fix the original method and replace it with an existing method

1.2.1247.2. Specs

Short name

Traits/UndefinedInsteadof

Rulesets

All, Analyze, CE, CI-checks, Changed Behavior, LintButWontExec

Exakat since

1.4.2

PHP Version

All

Severity

Major

Time To Fix

Instant (5 mins)

Precision

High

Features

insteadof, trait, method

Note

This issue may lint but will not run

Available in

Entreprise Edition, Community Edition, Exakat Cloud