1.2.1297. Unused Protected Methods

The following protected methods are unused in children class. As such, they may be considered for being private.

Methods reported by this analysis are not used by children, yet they are protected. No usage of those methods were found.

This analysis is impacted by dynamic method calls.

<?php

class Foo {
    // This method is not used
    protected function unusedBar() {}
    protected function usedInFoo() {}
    protected function usedInFooFoo() {}

    public function bar2() {
        // some code
        $this->usedInFoo();
    }
}

class FooFoo extends Foo {
    protected function bar() {}

    public function bar2() {
        // some code
        $this->usedInFooFoo();
    }
}

class someOtherClass {
    protected function bar() {
        // This is not related to foo.
        $this->unusedbar();
    }
}

?>

1.2.1297.1. Suggestions

  • Make use of the protected method in the code

  • Remove the method

1.2.1297.2. Specs

Short name

Classes/UnusedProtectedMethods

Rulesets

All, Changed Behavior, Dead code

Exakat since

0.8.4

PHP Version

All

Severity

Major

Time To Fix

Slow (1 hour)

Precision

Very high

Features

unused

Related rule

Unused Public Methods

Available in

Entreprise Edition, Exakat Cloud