You are here

public function Restorer::restoreFunctions in Zircon Profile 8

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

Deletes function definitions that are not defined in a snapshot.

Parameters

Snapshot $snapshot:

Throws

RuntimeException when the uopz_delete() function is not available

See also

https://github.com/krakjoe/uopz

File

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

Class

Restorer
Restorer of snapshots of global state.

Namespace

SebastianBergmann\GlobalState

Code

public function restoreFunctions(Snapshot $snapshot) {
  if (!function_exists('uopz_delete')) {
    throw new RuntimeException('The uopz_delete() function is required for this operation');
  }
  $functions = get_defined_functions();
  foreach (array_diff($functions['user'], $snapshot
    ->functions()) as $function) {
    uopz_delete($function);
  }
}