From 942fbdef24a8f77162a52489a644396f821ff03e Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Mon, 11 Oct 2021 17:19:42 +0900 Subject: [PATCH] Fix `Serialization of 'DOMDocument' is not allowed --- composer.json | 9 ++++++--- src/Snapshot.php | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 877d697..96c3a23 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,8 @@ { - "name": "sebastian/global-state", + "name": "php5friends/global-state11", "description": "Snapshotting of global state", "keywords": ["global state"], - "homepage": "http://www.github.com/sebastianbergmann/global-state", + "homepage": "http://www.github.com/php5friends/global-state11", "license": "BSD-3-Clause", "authors": [ { @@ -14,7 +14,10 @@ "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "~4.2|~5.0" + "php5friends/phpunit48": "^4.8" + }, + "replace": { + "sebastian/global-state": "*" }, "suggest": { "ext-uopz": "*" diff --git a/src/Snapshot.php b/src/Snapshot.php index 3c8aaa9..0f8e892 100644 --- a/src/Snapshot.php +++ b/src/Snapshot.php @@ -402,6 +402,14 @@ private function setupSuperGlobalArrays() */ private function canBeSerialized($variable) { + if (PHP_VERSION_ID >= 80100) { + try { + serialize($variable); + } catch (\Exception $e) { + return false; + } + } + if (!is_object($variable)) { return !is_resource($variable); }