1.2.2. $GLOBALS Or global

Usually, PHP projects make a choice between the global keyword, and the $GLOBALS variable. Sometimes, the project has no recommendations.

When your project use a vast majority of one of the convention, then the analyzer will report all remaining inconsistently cased constant.

<?php

global $a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m;

// This access is inconsistent with the previous usage
$GLOBALS['a'] = 2;

?>

1.2.2.1. Specs

Short name

Php/GlobalsVsGlobal

Rulesets

All, Changed Behavior, Preferences

Exakat since

0.9.2

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Features

global

Available in

Entreprise Edition, Exakat Cloud