function Restorer::restoreSuperGlobalArray
1 call to Restorer::restoreSuperGlobalArray()
- Restorer::restoreGlobalVariables in vendor/
sebastian/ global-state/ src/ Restorer.php
File
-
vendor/
sebastian/ global-state/ src/ Restorer.php, line 84
Class
Namespace
SebastianBergmann\GlobalStateCode
private function restoreSuperGlobalArray(Snapshot $snapshot, string $superGlobalArray) : void {
$superGlobalVariables = $snapshot->superGlobalVariables();
if (isset($GLOBALS[$superGlobalArray], $superGlobalVariables[$superGlobalArray]) && is_array($GLOBALS[$superGlobalArray])) {
$keys = array_keys(array_merge($GLOBALS[$superGlobalArray], $superGlobalVariables[$superGlobalArray]));
foreach ($keys as $key) {
if (isset($superGlobalVariables[$superGlobalArray][$key])) {
$GLOBALS[$superGlobalArray][$key] = $superGlobalVariables[$superGlobalArray][$key];
}
else {
unset($GLOBALS[$superGlobalArray][$key]);
}
}
}
}