You are here

private function Restorer::restoreSuperGlobalArray in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/sebastian/global-state/src/Restorer.php \SebastianBergmann\GlobalState\Restorer::restoreSuperGlobalArray()

Restores a super-global variable array from this snapshot.

Parameters

Snapshot $snapshot:

$superGlobalArray:

1 call to Restorer::restoreSuperGlobalArray()
Restorer::restoreGlobalVariables in vendor/sebastian/global-state/src/Restorer.php
Restores all global and super-global variables from a snapshot.

File

vendor/sebastian/global-state/src/Restorer.php, line 127

Class

Restorer
Restorer of snapshots of global state.

Namespace

SebastianBergmann\GlobalState

Code

private function restoreSuperGlobalArray(Snapshot $snapshot, $superGlobalArray) {
  $superGlobalVariables = $snapshot
    ->superGlobalVariables();
  if (isset($GLOBALS[$superGlobalArray]) && is_array($GLOBALS[$superGlobalArray]) && isset($superGlobalVariables[$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]);
      }
    }
  }
}