public function Restorer::restoreGlobalVariables in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/sebastian/global-state/src/Restorer.php \SebastianBergmann\GlobalState\Restorer::restoreGlobalVariables()
Restores all global and super-global variables from a snapshot.
Parameters
Snapshot $snapshot:
File
- vendor/
sebastian/ global-state/ src/ Restorer.php, line 82
Class
- Restorer
- Restorer of snapshots of global state.
Namespace
SebastianBergmann\GlobalStateCode
public function restoreGlobalVariables(Snapshot $snapshot) {
$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) && !$snapshot
->blacklist()
->isGlobalVariableBlacklisted($key)) {
if (isset($globalVariables[$key])) {
$GLOBALS[$key] = $globalVariables[$key];
}
else {
unset($GLOBALS[$key]);
}
}
}
}