function Restorer::restoreGlobalVariables
File
-
vendor/
sebastian/ global-state/ src/ Restorer.php, line 23
Class
Namespace
SebastianBergmann\GlobalStateCode
public function restoreGlobalVariables(Snapshot $snapshot) : void {
$superGlobalArrays = $snapshot->superGlobalArrays();
foreach ($superGlobalArrays as $superGlobalArray) {
$this->restoreSuperGlobalArray($snapshot, $superGlobalArray);
}
$globalVariables = $snapshot->globalVariables();
foreach (array_keys($GLOBALS) as $key) {
if ($key !== 'GLOBALS' && !in_array($key, $superGlobalArrays, true) && !$snapshot->excludeList()
->isGlobalVariableExcluded($key)) {
if (array_key_exists($key, $globalVariables)) {
$GLOBALS[$key] = $globalVariables[$key];
}
else {
unset($GLOBALS[$key]);
}
}
}
}