1.2.1384. 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.1384.1. Connex PHP features¶
1.2.1384.1.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.1384.1.2. Specs¶
Short name |
Classes/UselessAbstract |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Slow (1 hour) |
Precision |
Very high |
Available in |