1.2.1307. 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.1307.1. Connex PHP features¶
1.2.1307.1.1. Suggestions¶
Make use of the protected method in the code
Remove the method
1.2.1307.1.2. Specs¶
Short name |
Classes/UnusedProtectedMethods |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Slow (1 hour) |
Precision |
Very high |
Related rule |
|
Available in |