1.2.1158. Static Variable In Namespace¶
Static variables may be declared outside a function scope, but it has no usage. Static variables are persistent between function calls, and there is not such thing as namespace call (including an ‘include’ call).
<?php
namespace A {
// Static has no value here.
static $a = 1;
function foo() {
// One useful static variable
static $static = 2;
}
}
?>
1.2.1158.1. Connex PHP features¶
1.2.1158.1.1. Suggestions¶
Remove the ‘static’ keyword in the code
1.2.1158.1.2. Specs¶
Short name |
Variables/StaticVariableInNamespace |
Rulesets |
|
Exakat since |
2.6.1 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |