function CodeExporter::globalVariables
File
-
vendor/
sebastian/ global-state/ src/ CodeExporter.php, line 37
Class
Namespace
SebastianBergmann\GlobalStateCode
public function globalVariables(Snapshot $snapshot) : string {
$result = <<<'EOT'
call_user_func(
function ()
{
foreach (array_keys($GLOBALS) as $key) {
unset($GLOBALS[$key]);
}
}
);
EOT;
foreach ($snapshot->globalVariables() as $name => $value) {
$result .= sprintf('$GLOBALS[%s] = %s;' . PHP_EOL, $this->exportVariable($name), $this->exportVariable($value));
}
return $result;
}