1.2.678. Method Could Be Private Method¶
The following methods are never used outside their class of definition. Given the analyzed code, they could be set as private. Note that dynamic properties (such as $x->$y) are not taken into account.
<?php
class foo {
public function couldBePrivate() {}
public function cantdBePrivate() {}
function bar() {
// couldBePrivate is used internally.
$this->couldBePrivate();
}
}
class foo2 extends foo {
function bar2() {
// cantdBePrivate is used in a child class.
$this->cantdBePrivate();
}
}
//couldBePrivate() is not used outside
$foo = new foo();
//cantdBePrivate is used outside the class
$foo->cantdBePrivate();
?>
1.2.678.1. Connex PHP features¶
1.2.678.1.1. Specs¶
Short name |
Classes/CouldBePrivateMethod |
Rulesets |
|
Exakat since |
0.12.11 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |