1.2.142. Class Should Be Final By Ocramius

‘Make your classes always final, if they implement an interface, and no other public methods are defined’.

When a class should be final, as explained by Ocramius (Marco Pivetta).

<?php

interface i1 {
    function i1() ;
}

// Class should final, as its public methods are in an interface
class finalClass implements i1 {
    // public interface
    function i1 () {}

    // private method
    private function a1 () {}
}

?>

See also Final classes by default, why? and When to declare classes final.

1.2.142.1. Connex PHP features

1.2.142.1.1. Specs

Short name

Classes/FinalByOcramius

Rulesets

All, Changed Behavior, Class Review

Exakat since

0.9.4

PHP Version

All

Severity

Minor

Time To Fix

Slow (1 hour)

Precision

High

Available in

Entreprise Edition, Exakat Cloud