1.2.101. Can’t Extend Final Class

It is not possible to extend final classes.

Since PHP fails with a fatal error, this means that the extending class is probably not used in the rest of the code. Check for dead code.

In a separate file :

<?php
    // File Foo
    final class foo {
        public final function bar() {
            // doSomething
        }
    }
?>

See also Final Keyword.

1.2.101.2. Connex PHP features

1.2.101.2.1. Suggestions

  • Remove the final keyword

  • Remove the extending class

1.2.101.2.2. Specs

Short name

Classes/CantExtendFinal

Rulesets

All, Analyze, Changed Behavior, Dead code

Exakat since

0.8.4

PHP Version

All

Severity

Critical

Time To Fix

Instant (5 mins)

Precision

Medium

Available in

Entreprise Edition, Exakat Cloud