1.2.247. Could Be A Static Variable

This global is only used in one function or method. It may be transformed into a ‘static’ variable, instead of global. This allows you to keep the value between call to the function, but will not be accessible outside this function.

<?php
function foo( ) {
    static $variableIsReservedForX; // only accessible within foo( ), even between calls.
    global $variableIsGlobal;       //      accessible everywhere in the application
}
?>

1.2.247.1. Connex PHP features

1.2.247.1.1. Specs

Short name

Structures/CouldBeStatic

Rulesets

All, Analyze, Changed Behavior, Class Review

Exakat since

0.8.4

PHP Version

All

Severity

Major

Time To Fix

Quick (30 mins)

Precision

Very high

Examples

Dolphin, Contao

Available in

Entreprise Edition, Exakat Cloud