1.2.1377. Useless Abstract Class

Those classes are marked ‘abstract’ and they are never extended. This way, they won’t be instantiated nor used.

Abstract classes that have only static methods are omitted here : one usage of such classes are Utilities classes, which only offer static methods.

<?php

// Never extended class : this is useless
abstract class foo {}

// Extended class
abstract class bar {
    public function barbar() {}
}

class bar2 extends bar {}

// Utility class : omitted here
abstract class bar {
    public static function barbar() {}
}

?>

1.2.1377.1. Suggestions

  • Drop the abstract keyword

  • Extends the abstract class, more than once

  • If the class is extended, merge the class in the child

1.2.1377.2. Specs

Short name

Classes/UselessAbstract

Rulesets

All, Analyze, Changed Behavior

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Slow (1 hour)

Precision

Very high

Features

abstract

Available in

Entreprise Edition, Exakat Cloud