diff vendor/sebastian/global-state/src/Restorer.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children
line wrap: on
line diff
--- a/vendor/sebastian/global-state/src/Restorer.php	Mon Apr 23 09:33:26 2018 +0100
+++ b/vendor/sebastian/global-state/src/Restorer.php	Mon Apr 23 09:46:53 2018 +0100
@@ -1,6 +1,6 @@
 <?php
 /*
- * This file is part of the GlobalState package.
+ * This file is part of sebastian/global-state.
  *
  * (c) Sebastian Bergmann <sebastian@phpunit.de>
  *
@@ -8,6 +8,8 @@
  * file that was distributed with this source code.
  */
 
+declare(strict_types=1);
+
 namespace SebastianBergmann\GlobalState;
 
 use ReflectionProperty;
@@ -20,27 +22,25 @@
     /**
      * Deletes function definitions that are not defined in a snapshot.
      *
-     * @param  Snapshot         $snapshot
      * @throws RuntimeException when the uopz_delete() function is not available
+     *
      * @see    https://github.com/krakjoe/uopz
      */
     public function restoreFunctions(Snapshot $snapshot)
     {
-        if (!function_exists('uopz_delete')) {
+        if (!\function_exists('uopz_delete')) {
             throw new RuntimeException('The uopz_delete() function is required for this operation');
         }
 
-        $functions = get_defined_functions();
+        $functions = \get_defined_functions();
 
-        foreach (array_diff($functions['user'], $snapshot->functions()) as $function) {
+        foreach (\array_diff($functions['user'], $snapshot->functions()) as $function) {
             uopz_delete($function);
         }
     }
 
     /**
      * Restores all global and super-global variables from a snapshot.
-     *
-     * @param Snapshot $snapshot
      */
     public function restoreGlobalVariables(Snapshot $snapshot)
     {
@@ -52,11 +52,11 @@
 
         $globalVariables = $snapshot->globalVariables();
 
-        foreach (array_keys($GLOBALS) as $key) {
+        foreach (\array_keys($GLOBALS) as $key) {
             if ($key != 'GLOBALS' &&
-                !in_array($key, $superGlobalArrays) &&
+                !\in_array($key, $superGlobalArrays) &&
                 !$snapshot->blacklist()->isGlobalVariableBlacklisted($key)) {
-                if (isset($globalVariables[$key])) {
+                if (\array_key_exists($key, $globalVariables)) {
                     $GLOBALS[$key] = $globalVariables[$key];
                 } else {
                     unset($GLOBALS[$key]);
@@ -67,13 +67,12 @@
 
     /**
      * Restores all static attributes in user-defined classes from this snapshot.
-     *
-     * @param Snapshot $snapshot
      */
     public function restoreStaticAttributes(Snapshot $snapshot)
     {
         $current    = new Snapshot($snapshot->blacklist(), false, false, false, false, true, false, false, false, false);
-        $newClasses = array_diff($current->classes(), $snapshot->classes());
+        $newClasses = \array_diff($current->classes(), $snapshot->classes());
+
         unset($current);
 
         foreach ($snapshot->staticAttributes() as $className => $staticAttributes) {
@@ -111,19 +110,16 @@
 
     /**
      * Restores a super-global variable array from this snapshot.
-     *
-     * @param Snapshot $snapshot
-     * @param $superGlobalArray
      */
-    private function restoreSuperGlobalArray(Snapshot $snapshot, $superGlobalArray)
+    private function restoreSuperGlobalArray(Snapshot $snapshot, string $superGlobalArray)
     {
         $superGlobalVariables = $snapshot->superGlobalVariables();
 
         if (isset($GLOBALS[$superGlobalArray]) &&
-            is_array($GLOBALS[$superGlobalArray]) &&
+            \is_array($GLOBALS[$superGlobalArray]) &&
             isset($superGlobalVariables[$superGlobalArray])) {
-            $keys = array_keys(
-                array_merge(
+            $keys = \array_keys(
+                \array_merge(
                     $GLOBALS[$superGlobalArray],
                     $superGlobalVariables[$superGlobalArray]
                 )