43 $globalVars = array_diff( array_keys( $GLOBALS ), self::$superglobals );
44 $validGlobalVars = array_filter( $globalVars,
static function (
string $name ) {
46 return preg_match(
'/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $name );
49 if ( $validGlobalVars ) {
50 $globalCommand = new \PhpParser\Node\Stmt\Global_( array_map(
static function (
string $name ) {
51 return new \PhpParser\Node\Expr\Variable( $name );
52 }, $validGlobalVars ) );
53 array_unshift( $nodes, $globalCommand );