From a95b3124acdbfc89cdf5da7719c9bd151af1a626 Mon Sep 17 00:00:00 2001 From: Ronan Giron Date: Fri, 26 Nov 2021 11:08:40 +0100 Subject: [PATCH] Add PHP 8.1 Compatibility --- CHANGELOG.md | 6 ++++++ src/Debug/Atlas.php | 20 +++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c48ee84..5d437a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. This projec to [Semantic Versioning] (http://semver.org/). For change log format, use [Keep a Changelog] (http://keepachangelog.com/). +## [1.0.0-beta3] - 2021-11-26 + +### Added + +- PHP 8.1 Compatibility + ## [1.0.0-beta2] - 2020-11-05 ### Added diff --git a/src/Debug/Atlas.php b/src/Debug/Atlas.php index bac448c..f6eefc5 100644 --- a/src/Debug/Atlas.php +++ b/src/Debug/Atlas.php @@ -109,12 +109,24 @@ public function getTemplateName(): string return '@Berlioz-AtlasPackage/Twig/Debug/atlas.html.twig'; } + public function __serialize(): array + { + return [ + 'queries' => $this->queries + ]; + } + + public function __unserialize(array $data): void + { + $this->queries = $data['queries'] ?? []; + } + /** * @inheritdoc */ public function serialize() { - return serialize(['queries' => $this->queries]); + return serialize($this->__serialize()); } /** @@ -122,9 +134,7 @@ public function serialize() */ public function unserialize($serialized) { - $unserialized = unserialize($serialized); - - $this->queries = $unserialized['queries'] ?? []; + $this->__unserialize(unserialize($serialized)); } /////////////////////////// @@ -134,7 +144,7 @@ public function unserialize($serialized) /** * @inheritdoc */ - public function count() + public function count(): int { return count($this->getQueries()); }