1.2.1149. Static Call With Self¶
Avoid using a static call on a non-static method.
PHP allows it inside the class itself. Yet, it makes the code confusing.
<?php
class x {
function foo() {
self::bar();
$this->bar();
}
// non static method
function bar() {
}
}
?>
See also Don’t call instance methods statically.
1.2.1149.1. Suggestions¶
Use the normal method call syntax.
1.2.1149.2. Specs¶
Short name |
Performances/StaticCallWithSelf |
Rulesets |
|
Exakat since |
2.5.3 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Available in |