1.2.544. Implemented Methods Must Be Public

Class methods that are defined in an interface must be public. They cannot be either private, nor protected.

This error is not reported by lint, and is reported at execution time.

<?php

interface i {
    function foo();
}

class X {
    // This method is defined in the interface : it must be public
    protected function foo() {}

    // other methods may be private
    private function bar() {}
}

?>

See also Interfaces and Interfaces - the next level of abstraction.

1.2.544.1. Suggestions

  • Make the implemented method public

1.2.544.2. Specs

Short name

Classes/ImplementedMethodsArePublic

Rulesets

All, Analyze, Changed Behavior, LintButWontExec

Exakat since

0.11.5

PHP Version

All

Severity

Major

Time To Fix

Instant (5 mins)

Precision

Very high

Features

method, visibility

Note

This issue may lint but will not run

Available in

Entreprise Edition, Exakat Cloud