1.2.265. Could Be Protected Method

Those methods are declared ‘public’, but are never used publicly. They may be made ‘protected’.

These properties may even be made private.

<?php

class foo {
    // Public, and used publicly
    public publicMethod() {}

    // Public, but never used outside the class or its children
    public protectedMethod() {}

    private function bar() {
        $this->protectedMethod();
    }
}

$foo = new Foo();
$foo->publicMethod();

?>

1.2.265.1. Connex PHP features

1.2.265.1.1. Suggestions

  • Use protected visibility with these methods.

1.2.265.1.2. Specs

Short name

Classes/CouldBeProtectedMethod

Rulesets

All, Changed Behavior, Class Review

Exakat since

0.12.11

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Available in

Entreprise Edition, Exakat Cloud