summaryrefslogtreecommitdiff
path: root/vendor/sebastian/global-state
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sebastian/global-state')
-rw-r--r--vendor/sebastian/global-state/ChangeLog.md79
-rw-r--r--vendor/sebastian/global-state/LICENSE33
-rw-r--r--vendor/sebastian/global-state/README.md20
-rw-r--r--vendor/sebastian/global-state/composer.json51
-rw-r--r--vendor/sebastian/global-state/src/CodeExporter.php109
-rw-r--r--vendor/sebastian/global-state/src/ExcludeList.php119
-rw-r--r--vendor/sebastian/global-state/src/Restorer.php143
-rw-r--r--vendor/sebastian/global-state/src/Snapshot.php443
-rw-r--r--vendor/sebastian/global-state/src/exceptions/Exception.php16
-rw-r--r--vendor/sebastian/global-state/src/exceptions/RuntimeException.php14
10 files changed, 0 insertions, 1027 deletions
diff --git a/vendor/sebastian/global-state/ChangeLog.md b/vendor/sebastian/global-state/ChangeLog.md
deleted file mode 100644
index a27a5cf16..000000000
--- a/vendor/sebastian/global-state/ChangeLog.md
+++ /dev/null
@@ -1,79 +0,0 @@
-# Changes in sebastian/global-state
-
-All notable changes in `sebastian/global-state` are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
-
-## [5.0.5] - 2022-02-14
-
-### Fixed
-
-* [#34](https://github.com/sebastianbergmann/global-state/pull/34): Uninitialised typed static properties are not handled correctly
-
-## [5.0.4] - 2022-02-10
-
-### Fixed
-
-* The `$includeTraits` parameter of `SebastianBergmann\GlobalState\Snapshot::__construct()` is not respected
-
-## [5.0.3] - 2021-06-11
-
-### Changed
-
-* `SebastianBergmann\GlobalState\CodeExporter::globalVariables()` now generates code that is compatible with PHP 8.1
-
-## [5.0.2] - 2020-10-26
-
-### Fixed
-
-* `SebastianBergmann\GlobalState\Exception` now correctly extends `\Throwable`
-
-## [5.0.1] - 2020-09-28
-
-### Changed
-
-* Changed PHP version constraint in `composer.json` from `^7.3 || ^8.0` to `>=7.3`
-
-## [5.0.0] - 2020-08-07
-
-### Changed
-
-* The `SebastianBergmann\GlobalState\Blacklist` class has been renamed to `SebastianBergmann\GlobalState\ExcludeList`
-
-## [4.0.0] - 2020-02-07
-
-### Removed
-
-* This component is no longer supported on PHP 7.2
-
-## [3.0.2] - 2022-02-10
-
-### Fixed
-
-* The `$includeTraits` parameter of `SebastianBergmann\GlobalState\Snapshot::__construct()` is not respected
-
-## [3.0.1] - 2020-11-30
-
-### Changed
-
-* Changed PHP version constraint in `composer.json` from `^7.2` to `>=7.2`
-
-## [3.0.0] - 2019-02-01
-
-### Changed
-
-* `Snapshot::canBeSerialized()` now recursively checks arrays and object graphs for variables that cannot be serialized
-
-### Removed
-
-* This component is no longer supported on PHP 7.0 and PHP 7.1
-
-[5.0.5]: https://github.com/sebastianbergmann/global-state/compare/5.0.4...5.0.5
-[5.0.4]: https://github.com/sebastianbergmann/global-state/compare/5.0.3...5.0.4
-[5.0.3]: https://github.com/sebastianbergmann/global-state/compare/5.0.2...5.0.3
-[5.0.2]: https://github.com/sebastianbergmann/global-state/compare/5.0.1...5.0.2
-[5.0.1]: https://github.com/sebastianbergmann/global-state/compare/5.0.0...5.0.1
-[5.0.0]: https://github.com/sebastianbergmann/global-state/compare/4.0.0...5.0.0
-[4.0.0]: https://github.com/sebastianbergmann/global-state/compare/3.0.2...4.0.0
-[3.0.2]: https://github.com/sebastianbergmann/phpunit/compare/3.0.1...3.0.2
-[3.0.1]: https://github.com/sebastianbergmann/phpunit/compare/3.0.0...3.0.1
-[3.0.0]: https://github.com/sebastianbergmann/phpunit/compare/2.0.0...3.0.0
-
diff --git a/vendor/sebastian/global-state/LICENSE b/vendor/sebastian/global-state/LICENSE
deleted file mode 100644
index 240190bd3..000000000
--- a/vendor/sebastian/global-state/LICENSE
+++ /dev/null
@@ -1,33 +0,0 @@
-sebastian/global-state
-
-Copyright (c) 2001-2022, Sebastian Bergmann <sebastian@phpunit.de>.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- * Neither the name of Sebastian Bergmann nor the names of his
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
diff --git a/vendor/sebastian/global-state/README.md b/vendor/sebastian/global-state/README.md
deleted file mode 100644
index af15bedde..000000000
--- a/vendor/sebastian/global-state/README.md
+++ /dev/null
@@ -1,20 +0,0 @@
-# sebastian/global-state
-
-[![CI Status](https://github.com/sebastianbergmann/global-state/workflows/CI/badge.svg)](https://github.com/sebastianbergmann/global-state/actions)
-[![Type Coverage](https://shepherd.dev/github/sebastianbergmann/global-state/coverage.svg)](https://shepherd.dev/github/sebastianbergmann/global-state)
-
-Snapshotting of global state, factored out of PHPUnit into a stand-alone component.
-
-## Installation
-
-You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
-
-```
-composer require sebastian/global-state
-```
-
-If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
-
-```
-composer require --dev sebastian/global-state
-```
diff --git a/vendor/sebastian/global-state/composer.json b/vendor/sebastian/global-state/composer.json
deleted file mode 100644
index 0fef446a6..000000000
--- a/vendor/sebastian/global-state/composer.json
+++ /dev/null
@@ -1,51 +0,0 @@
-{
- "name": "sebastian/global-state",
- "description": "Snapshotting of global state",
- "keywords": ["global state"],
- "homepage": "http://www.github.com/sebastianbergmann/global-state",
- "license": "BSD-3-Clause",
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "prefer-stable": true,
- "config": {
- "platform": {
- "php": "7.3.0"
- },
- "optimize-autoloader": true,
- "sort-packages": true
- },
- "require": {
- "php": ">=7.3",
- "sebastian/object-reflector": "^2.0",
- "sebastian/recursion-context": "^4.0"
- },
- "require-dev": {
- "ext-dom": "*",
- "phpunit/phpunit": "^9.3"
- },
- "suggest": {
- "ext-uopz": "*"
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "autoload-dev": {
- "classmap": [
- "tests/_fixture/"
- ],
- "files": [
- "tests/_fixture/SnapshotFunctions.php"
- ]
- },
- "extra": {
- "branch-alias": {
- "dev-master": "5.0-dev"
- }
- }
-}
diff --git a/vendor/sebastian/global-state/src/CodeExporter.php b/vendor/sebastian/global-state/src/CodeExporter.php
deleted file mode 100644
index 71cdbf504..000000000
--- a/vendor/sebastian/global-state/src/CodeExporter.php
+++ /dev/null
@@ -1,109 +0,0 @@
-<?php declare(strict_types=1);
-/*
- * This file is part of sebastian/global-state.
- *
- * (c) Sebastian Bergmann <sebastian@phpunit.de>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-namespace SebastianBergmann\GlobalState;
-
-use const PHP_EOL;
-use function is_array;
-use function is_scalar;
-use function serialize;
-use function sprintf;
-use function var_export;
-
-/**
- * Exports parts of a Snapshot as PHP code.
- */
-final class CodeExporter
-{
- public function constants(Snapshot $snapshot): string
- {
- $result = '';
-
- foreach ($snapshot->constants() as $name => $value) {
- $result .= sprintf(
- 'if (!defined(\'%s\')) define(\'%s\', %s);' . "\n",
- $name,
- $name,
- $this->exportVariable($value)
- );
- }
-
- return $result;
- }
-
- public function globalVariables(Snapshot $snapshot): string
- {
- $result = <<<'EOT'
-call_user_func(
- function ()
- {
- foreach (array_keys($GLOBALS) as $key) {
- unset($GLOBALS[$key]);
- }
- }
-);
-
-
-EOT;
-
- foreach ($snapshot->globalVariables() as $name => $value) {
- $result .= sprintf(
- '$GLOBALS[%s] = %s;' . PHP_EOL,
- $this->exportVariable($name),
- $this->exportVariable($value)
- );
- }
-
- return $result;
- }
-
- public function iniSettings(Snapshot $snapshot): string
- {
- $result = '';
-
- foreach ($snapshot->iniSettings() as $key => $value) {
- $result .= sprintf(
- '@ini_set(%s, %s);' . "\n",
- $this->exportVariable($key),
- $this->exportVariable($value)
- );
- }
-
- return $result;
- }
-
- private function exportVariable($variable): string
- {
- if (is_scalar($variable) || null === $variable ||
- (is_array($variable) && $this->arrayOnlyContainsScalars($variable))) {
- return var_export($variable, true);
- }
-
- return 'unserialize(' . var_export(serialize($variable), true) . ')';
- }
-
- private function arrayOnlyContainsScalars(array $array): bool
- {
- $result = true;
-
- foreach ($array as $element) {
- if (is_array($element)) {
- $result = $this->arrayOnlyContainsScalars($element);
- } elseif (!is_scalar($element) && null !== $element) {
- $result = false;
- }
-
- if ($result === false) {
- break;
- }
- }
-
- return $result;
- }
-}
diff --git a/vendor/sebastian/global-state/src/ExcludeList.php b/vendor/sebastian/global-state/src/ExcludeList.php
deleted file mode 100644
index 5631f1186..000000000
--- a/vendor/sebastian/global-state/src/ExcludeList.php
+++ /dev/null
@@ -1,119 +0,0 @@
-<?php declare(strict_types=1);
-/*
- * This file is part of sebastian/global-state.
- *
- * (c) Sebastian Bergmann <sebastian@phpunit.de>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-namespace SebastianBergmann\GlobalState;
-
-use function in_array;
-use function strpos;
-use ReflectionClass;
-
-final class ExcludeList
-{
- /**
- * @var array
- */
- private $globalVariables = [];
-
- /**
- * @var string[]
- */
- private $classes = [];
-
- /**
- * @var string[]
- */
- private $classNamePrefixes = [];
-
- /**
- * @var string[]
- */
- private $parentClasses = [];
-
- /**
- * @var string[]
- */
- private $interfaces = [];
-
- /**
- * @var array
- */
- private $staticAttributes = [];
-
- public function addGlobalVariable(string $variableName): void
- {
- $this->globalVariables[$variableName] = true;
- }
-
- public function addClass(string $className): void
- {
- $this->classes[] = $className;
- }
-
- public function addSubclassesOf(string $className): void
- {
- $this->parentClasses[] = $className;
- }
-
- public function addImplementorsOf(string $interfaceName): void
- {
- $this->interfaces[] = $interfaceName;
- }
-
- public function addClassNamePrefix(string $classNamePrefix): void
- {
- $this->classNamePrefixes[] = $classNamePrefix;
- }
-
- public function addStaticAttribute(string $className, string $attributeName): void
- {
- if (!isset($this->staticAttributes[$className])) {
- $this->staticAttributes[$className] = [];
- }
-
- $this->staticAttributes[$className][$attributeName] = true;
- }
-
- public function isGlobalVariableExcluded(string $variableName): bool
- {
- return isset($this->globalVariables[$variableName]);
- }
-
- public function isStaticAttributeExcluded(string $className, string $attributeName): bool
- {
- if (in_array($className, $this->classes, true)) {
- return true;
- }
-
- foreach ($this->classNamePrefixes as $prefix) {
- if (strpos($className, $prefix) === 0) {
- return true;
- }
- }
-
- $class = new ReflectionClass($className);
-
- foreach ($this->parentClasses as $type) {
- if ($class->isSubclassOf($type)) {
- return true;
- }
- }
-
- foreach ($this->interfaces as $type) {
- if ($class->implementsInterface($type)) {
- return true;
- }
- }
-
- if (isset($this->staticAttributes[$className][$attributeName])) {
- return true;
- }
-
- return false;
- }
-}
diff --git a/vendor/sebastian/global-state/src/Restorer.php b/vendor/sebastian/global-state/src/Restorer.php
deleted file mode 100644
index 1633fcc11..000000000
--- a/vendor/sebastian/global-state/src/Restorer.php
+++ /dev/null
@@ -1,143 +0,0 @@
-<?php declare(strict_types=1);
-/*
- * This file is part of sebastian/global-state.
- *
- * (c) Sebastian Bergmann <sebastian@phpunit.de>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-namespace SebastianBergmann\GlobalState;
-
-use function array_diff;
-use function array_key_exists;
-use function array_keys;
-use function array_merge;
-use function function_exists;
-use function get_defined_functions;
-use function in_array;
-use function is_array;
-use ReflectionClass;
-use ReflectionProperty;
-
-/**
- * Restorer of snapshots of global state.
- */
-class Restorer
-{
- /**
- * Deletes function definitions that are not defined in a snapshot.
- *
- * @throws RuntimeException when the uopz_delete() function is not available
- *
- * @see https://github.com/krakjoe/uopz
- */
- public function restoreFunctions(Snapshot $snapshot): void
- {
- 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);
- }
- }
-
- /**
- * Restores all global and super-global variables from a snapshot.
- */
- public function restoreGlobalVariables(Snapshot $snapshot): void
- {
- $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, true) &&
- !$snapshot->excludeList()->isGlobalVariableExcluded($key)) {
- if (array_key_exists($key, $globalVariables)) {
- $GLOBALS[$key] = $globalVariables[$key];
- } else {
- unset($GLOBALS[$key]);
- }
- }
- }
- }
-
- /**
- * Restores all static attributes in user-defined classes from this snapshot.
- */
- public function restoreStaticAttributes(Snapshot $snapshot): void
- {
- $current = new Snapshot($snapshot->excludeList(), false, false, false, false, true, false, false, false, false);
- $newClasses = array_diff($current->classes(), $snapshot->classes());
-
- unset($current);
-
- foreach ($snapshot->staticAttributes() as $className => $staticAttributes) {
- foreach ($staticAttributes as $name => $value) {
- $reflector = new ReflectionProperty($className, $name);
- $reflector->setAccessible(true);
- $reflector->setValue($value);
- }
- }
-
- foreach ($newClasses as $className) {
- $class = new ReflectionClass($className);
- $defaults = $class->getDefaultProperties();
-
- foreach ($class->getProperties() as $attribute) {
- if (!$attribute->isStatic()) {
- continue;
- }
-
- $name = $attribute->getName();
-
- if ($snapshot->excludeList()->isStaticAttributeExcluded($className, $name)) {
- continue;
- }
-
- if (!isset($defaults[$name])) {
- continue;
- }
-
- $attribute->setAccessible(true);
- $attribute->setValue($defaults[$name]);
- }
- }
- }
-
- /**
- * Restores a super-global variable array from this snapshot.
- */
- private function restoreSuperGlobalArray(Snapshot $snapshot, string $superGlobalArray): void
- {
- $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]);
- }
- }
- }
- }
-}
diff --git a/vendor/sebastian/global-state/src/Snapshot.php b/vendor/sebastian/global-state/src/Snapshot.php
deleted file mode 100644
index e33264eb0..000000000
--- a/vendor/sebastian/global-state/src/Snapshot.php
+++ /dev/null
@@ -1,443 +0,0 @@
-<?php declare(strict_types=1);
-/*
- * This file is part of sebastian/global-state.
- *
- * (c) Sebastian Bergmann <sebastian@phpunit.de>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-namespace SebastianBergmann\GlobalState;
-
-use const PHP_VERSION_ID;
-use function array_keys;
-use function array_merge;
-use function array_reverse;
-use function func_get_args;
-use function get_declared_classes;
-use function get_declared_interfaces;
-use function get_declared_traits;
-use function get_defined_constants;
-use function get_defined_functions;
-use function get_included_files;
-use function in_array;
-use function ini_get_all;
-use function is_array;
-use function is_object;
-use function is_resource;
-use function is_scalar;
-use function serialize;
-use function unserialize;
-use ReflectionClass;
-use SebastianBergmann\ObjectReflector\ObjectReflector;
-use SebastianBergmann\RecursionContext\Context;
-use Throwable;
-
-/**
- * A snapshot of global state.
- */
-class Snapshot
-{
- /**
- * @var ExcludeList
- */
- private $excludeList;
-
- /**
- * @var array
- */
- private $globalVariables = [];
-
- /**
- * @var array
- */
- private $superGlobalArrays = [];
-
- /**
- * @var array
- */
- private $superGlobalVariables = [];
-
- /**
- * @var array
- */
- private $staticAttributes = [];
-
- /**
- * @var array
- */
- private $iniSettings = [];
-
- /**
- * @var array
- */
- private $includedFiles = [];
-
- /**
- * @var array
- */
- private $constants = [];
-
- /**
- * @var array
- */
- private $functions = [];
-
- /**
- * @var array
- */
- private $interfaces = [];
-
- /**
- * @var array
- */
- private $classes = [];
-
- /**
- * @var array
- */
- private $traits = [];
-
- /**
- * Creates a snapshot of the current global state.
- */
- public function __construct(ExcludeList $excludeList = null, bool $includeGlobalVariables = true, bool $includeStaticAttributes = true, bool $includeConstants = true, bool $includeFunctions = true, bool $includeClasses = true, bool $includeInterfaces = true, bool $includeTraits = true, bool $includeIniSettings = true, bool $includeIncludedFiles = true)
- {
- $this->excludeList = $excludeList ?: new ExcludeList;
-
- if ($includeConstants) {
- $this->snapshotConstants();
- }
-
- if ($includeFunctions) {
- $this->snapshotFunctions();
- }
-
- if ($includeClasses || $includeStaticAttributes) {
- $this->snapshotClasses();
- }
-
- if ($includeInterfaces) {
- $this->snapshotInterfaces();
- }
-
- if ($includeGlobalVariables) {
- $this->setupSuperGlobalArrays();
- $this->snapshotGlobals();
- }
-
- if ($includeStaticAttributes) {
- $this->snapshotStaticAttributes();
- }
-
- if ($includeIniSettings) {
- $this->iniSettings = ini_get_all(null, false);
- }
-
- if ($includeIncludedFiles) {
- $this->includedFiles = get_included_files();
- }
-
- if ($includeTraits) {
- $this->traits = get_declared_traits();
- }
- }
-
- public function excludeList(): ExcludeList
- {
- return $this->excludeList;
- }
-
- public function globalVariables(): array
- {
- return $this->globalVariables;
- }
-
- public function superGlobalVariables(): array
- {
- return $this->superGlobalVariables;
- }
-
- public function superGlobalArrays(): array
- {
- return $this->superGlobalArrays;
- }
-
- public function staticAttributes(): array
- {
- return $this->staticAttributes;
- }
-
- public function iniSettings(): array
- {
- return $this->iniSettings;
- }
-
- public function includedFiles(): array
- {
- return $this->includedFiles;
- }
-
- public function constants(): array
- {
- return $this->constants;
- }
-
- public function functions(): array
- {
- return $this->functions;
- }
-
- public function interfaces(): array
- {
- return $this->interfaces;
- }
-
- public function classes(): array
- {
- return $this->classes;
- }
-
- public function traits(): array
- {
- return $this->traits;
- }
-
- /**
- * Creates a snapshot user-defined constants.
- */
- private function snapshotConstants(): void
- {
- $constants = get_defined_constants(true);
-
- if (isset($constants['user'])) {
- $this->constants = $constants['user'];
- }
- }
-
- /**
- * Creates a snapshot user-defined functions.
- */
- private function snapshotFunctions(): void
- {
- $functions = get_defined_functions();
-
- $this->functions = $functions['user'];
- }
-
- /**
- * Creates a snapshot user-defined classes.
- */
- private function snapshotClasses(): void
- {
- foreach (array_reverse(get_declared_classes()) as $className) {
- $class = new ReflectionClass($className);
-
- if (!$class->isUserDefined()) {
- break;
- }
-
- $this->classes[] = $className;
- }
-
- $this->classes = array_reverse($this->classes);
- }
-
- /**
- * Creates a snapshot user-defined interfaces.
- */
- private function snapshotInterfaces(): void
- {
- foreach (array_reverse(get_declared_interfaces()) as $interfaceName) {
- $class = new ReflectionClass($interfaceName);
-
- if (!$class->isUserDefined()) {
- break;
- }
-
- $this->interfaces[] = $interfaceName;
- }
-
- $this->interfaces = array_reverse($this->interfaces);
- }
-
- /**
- * Creates a snapshot of all global and super-global variables.
- */
- private function snapshotGlobals(): void
- {
- $superGlobalArrays = $this->superGlobalArrays();
-
- foreach ($superGlobalArrays as $superGlobalArray) {
- $this->snapshotSuperGlobalArray($superGlobalArray);
- }
-
- foreach (array_keys($GLOBALS) as $key) {
- if ($key !== 'GLOBALS' &&
- !in_array($key, $superGlobalArrays, true) &&
- $this->canBeSerialized($GLOBALS[$key]) &&
- !$this->excludeList->isGlobalVariableExcluded($key)) {
- /* @noinspection UnserializeExploitsInspection */
- $this->globalVariables[$key] = unserialize(serialize($GLOBALS[$key]));
- }
- }
- }
-
- /**
- * Creates a snapshot a super-global variable array.
- */
- private function snapshotSuperGlobalArray(string $superGlobalArray): void
- {
- $this->superGlobalVariables[$superGlobalArray] = [];
-
- if (isset($GLOBALS[$superGlobalArray]) && is_array($GLOBALS[$superGlobalArray])) {
- foreach ($GLOBALS[$superGlobalArray] as $key => $value) {
- /* @noinspection UnserializeExploitsInspection */
- $this->superGlobalVariables[$superGlobalArray][$key] = unserialize(serialize($value));
- }
- }
- }
-
- /**
- * Creates a snapshot of all static attributes in user-defined classes.
- */
- private function snapshotStaticAttributes(): void
- {
- foreach ($this->classes as $className) {
- $class = new ReflectionClass($className);
- $snapshot = [];
-
- foreach ($class->getProperties() as $attribute) {
- if ($attribute->isStatic()) {
- $name = $attribute->getName();
-
- if ($this->excludeList->isStaticAttributeExcluded($className, $name)) {
- continue;
- }
-
- $attribute->setAccessible(true);
-
- if (PHP_VERSION_ID >= 70400 && !$attribute->isInitialized()) {
- continue;
- }
-
- $value = $attribute->getValue();
-
- if ($this->canBeSerialized($value)) {
- /* @noinspection UnserializeExploitsInspection */
- $snapshot[$name] = unserialize(serialize($value));
- }
- }
- }
-
- if (!empty($snapshot)) {
- $this->staticAttributes[$className] = $snapshot;
- }
- }
- }
-
- /**
- * Returns a list of all super-global variable arrays.
- */
- private function setupSuperGlobalArrays(): void
- {
- $this->superGlobalArrays = [
- '_ENV',
- '_POST',
- '_GET',
- '_COOKIE',
- '_SERVER',
- '_FILES',
- '_REQUEST',
- ];
- }
-
- private function canBeSerialized($variable): bool
- {
- if (is_scalar($variable) || $variable === null) {
- return true;
- }
-
- if (is_resource($variable)) {
- return false;
- }
-
- foreach ($this->enumerateObjectsAndResources($variable) as $value) {
- if (is_resource($value)) {
- return false;
- }
-
- if (is_object($value)) {
- $class = new ReflectionClass($value);
-
- if ($class->isAnonymous()) {
- return false;
- }
-
- try {
- @serialize($value);
- } catch (Throwable $t) {
- return false;
- }
- }
- }
-
- return true;
- }
-
- private function enumerateObjectsAndResources($variable): array
- {
- if (isset(func_get_args()[1])) {
- $processed = func_get_args()[1];
- } else {
- $processed = new Context;
- }
-
- $result = [];
-
- if ($processed->contains($variable)) {
- return $result;
- }
-
- $array = $variable;
- $processed->add($variable);
-
- if (is_array($variable)) {
- foreach ($array as $element) {
- if (!is_array($element) && !is_object($element) && !is_resource($element)) {
- continue;
- }
-
- if (!is_resource($element)) {
- /** @noinspection SlowArrayOperationsInLoopInspection */
- $result = array_merge(
- $result,
- $this->enumerateObjectsAndResources($element, $processed)
- );
- } else {
- $result[] = $element;
- }
- }
- } else {
- $result[] = $variable;
-
- foreach ((new ObjectReflector)->getAttributes($variable) as $value) {
- if (!is_array($value) && !is_object($value) && !is_resource($value)) {
- continue;
- }
-
- if (!is_resource($value)) {
- /** @noinspection SlowArrayOperationsInLoopInspection */
- $result = array_merge(
- $result,
- $this->enumerateObjectsAndResources($value, $processed)
- );
- } else {
- $result[] = $value;
- }
- }
- }
-
- return $result;
- }
-}
diff --git a/vendor/sebastian/global-state/src/exceptions/Exception.php b/vendor/sebastian/global-state/src/exceptions/Exception.php
deleted file mode 100644
index 94432008e..000000000
--- a/vendor/sebastian/global-state/src/exceptions/Exception.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php declare(strict_types=1);
-/*
- * This file is part of sebastian/global-state.
- *
- * (c) Sebastian Bergmann <sebastian@phpunit.de>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-namespace SebastianBergmann\GlobalState;
-
-use Throwable;
-
-interface Exception extends Throwable
-{
-}
diff --git a/vendor/sebastian/global-state/src/exceptions/RuntimeException.php b/vendor/sebastian/global-state/src/exceptions/RuntimeException.php
deleted file mode 100644
index 79f02a114..000000000
--- a/vendor/sebastian/global-state/src/exceptions/RuntimeException.php
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php declare(strict_types=1);
-/*
- * This file is part of sebastian/global-state.
- *
- * (c) Sebastian Bergmann <sebastian@phpunit.de>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-namespace SebastianBergmann\GlobalState;
-
-final class RuntimeException extends \RuntimeException implements Exception
-{
-}