1.2.1248. Undefined Interfaces

Some typehints or instanceof that are relying on undefined interfaces or classes. They will always return false. Any condition based upon them are dead code.

<?php

class var implements undefinedInterface {
    // If undefinedInterface is undefined, this code lints but doesn't run
}

if ($o instanceof undefinedInterface) {
    // This is silent dead code
}

function foo(undefinedInterface $a) {
    // This is dead code
    // it will probably be discovered at execution
}

?>

See also Object interfaces, Type declarations and Instanceof.

1.2.1248.1. Suggestions

  • Implement the missing interfaces

  • Remove the code governed by the missing interface : the whole method if it is an typehint, the whole if/then if it is a condition.

1.2.1248.2. Specs

Short name

Interfaces/UndefinedInterfaces

Rulesets

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

Exakat since

0.8.4

PHP Version

All

Severity

Major

Time To Fix

Quick (30 mins)

Precision

High

Features

interface

Examples

xataface

Note

This issue may lint but will not run

Available in

Entreprise Edition, Community Edition, Exakat Cloud