1.2.15. Abstract Or Implements

A class must implements all abstract methods of it parents, or be abstract too.

PHP detect such error when all classes are loaded: in a code source where classes are split by files, such error it won’t be detected until execution, where PHP stops with a Fatal Error : Class BA contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (A\:\:aFoo).

<?php

abstract class Foo {
    abstract function FooBar();
}

// This is in another file : php -l would detect it right away

class FooFoo extends Foo {
    // The method is not defined.
    // The class must be abstract, just like Foo
}

?>

See also Class Abstraction.

1.2.15.1. Suggestions

  • Implements all the abstract methods of the class

  • Make the class abstract

1.2.15.2. Specs

Short name

Classes/AbstractOrImplements

Rulesets

All, Analyze, Changed Behavior, LintButWontExec

Exakat since

1.3.3

PHP Version

All

Severity

Major

Time To Fix

Quick (30 mins)

Precision

Very high

Features

abstract, implements, lazy-loading

Examples

Zurmo

Note

This issue may lint but will not run

Available in

Entreprise Edition, Exakat Cloud