You are here

public function Restorer::restoreStaticAttributes in Zircon Profile 8

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

Restores all static attributes in user-defined classes from this snapshot.

Parameters

Snapshot $snapshot:

File

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

Class

Restorer
Restorer of snapshots of global state.

Namespace

SebastianBergmann\GlobalState

Code

public function restoreStaticAttributes(Snapshot $snapshot) {
  foreach ($snapshot
    ->staticAttributes() as $className => $staticAttributes) {
    foreach ($staticAttributes as $name => $value) {
      $reflector = new ReflectionProperty($className, $name);
      $reflector
        ->setAccessible(true);
      $reflector
        ->setValue($value);
    }
  }
}