MediaWiki REL1_34
CodeCleanerGlobalsPass.inc
Go to the documentation of this file.
1<?php
36class CodeCleanerGlobalsPass extends \Psy\CodeCleaner\CodeCleanerPass {
37 private static $superglobals = [
38 'GLOBALS', '_SERVER', '_ENV', '_FILES', '_COOKIE', '_POST', '_GET', '_SESSION'
39 ];
40
41 public function beforeTraverse( array $nodes ) {
42 $names = [];
43 foreach ( array_diff( array_keys( $GLOBALS ), self::$superglobals ) as $name ) {
44 array_push( $names, new \PhpParser\Node\Expr\Variable( $name ) );
45 }
46
47 array_unshift( $nodes, new \PhpParser\Node\Stmt\Global_( $names ) );
48
49 return $nodes;
50 }
51}
$GLOBALS['IP']
Prefix the real command with a bunch of 'global $VAR;' commands, one for each global.