From 2a30e9c3b9d29403d42e3e2aefbc18fd60be160d Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Sat, 13 Nov 2021 18:13:22 +0100 Subject: [PATCH 1/2] Revert "Merge pull request #103 from alexander-schranz/patch-1" This reverts commit 3653cd16e406a3d3ec254d656d2768038827ff24, reversing changes made to 3e1dc95fa59863b98a2639c045b6ba43232716a6. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ec582a5..ff86b64 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ }, "extra": { "branch-alias": { - "dev-master": "3.x-dev" + "dev-master": "2.x-dev" } } } From 30a38936d04a8bed64a0ebb70127af30fef89b9b Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Sat, 13 Nov 2021 18:21:17 +0100 Subject: [PATCH 2/2] backward compatible support for the new __serialize and __unserialize methods --- src/ClassMetadata.php | 36 ++++++++++++++++++------------------ src/MethodMetadata.php | 12 ++++++------ src/PropertyMetadata.php | 18 +++++++++--------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/ClassMetadata.php b/src/ClassMetadata.php index 983132f..d96d2e5 100644 --- a/src/ClassMetadata.php +++ b/src/ClassMetadata.php @@ -82,7 +82,13 @@ public function isFresh(?int $timestamp = null): bool */ public function serialize() { - return serialize($this->__serialize()); + return serialize([ + $this->name, + $this->methodMetadata, + $this->propertyMetadata, + $this->fileResources, + $this->createdAt, + ]); } /** @@ -96,34 +102,28 @@ public function serialize() */ public function unserialize($str) { - $this->__unserialize((array) unserialize((string) $str)); + [ + $this->name, + $this->methodMetadata, + $this->propertyMetadata, + $this->fileResources, + $this->createdAt, + ] = unserialize($str); } /** - * @return array + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification */ public function __serialize(): array { - return [ - $this->name, - $this->methodMetadata, - $this->propertyMetadata, - $this->fileResources, - $this->createdAt, - ]; + return [$this->serialize()]; } /** - * @param array $data + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification */ public function __unserialize(array $data): void { - [ - $this->name, - $this->methodMetadata, - $this->propertyMetadata, - $this->fileResources, - $this->createdAt, - ] = $data; + $this->unserialize($data[0]); } } diff --git a/src/MethodMetadata.php b/src/MethodMetadata.php index 6865538..df5b555 100644 --- a/src/MethodMetadata.php +++ b/src/MethodMetadata.php @@ -55,7 +55,7 @@ public function invoke(object $obj, array $args = []) */ public function serialize() { - return serialize($this->__serialize()); + return serialize([$this->class, $this->name]); } /** @@ -69,23 +69,23 @@ public function serialize() */ public function unserialize($str) { - $this->__unserialize((array) unserialize((string) $str)); + [$this->class, $this->name] = unserialize($str); } /** - * @return array + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification */ public function __serialize(): array { - return [$this->class, $this->name]; + return [$this->serialize()]; } /** - * @param array $data + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification */ public function __unserialize(array $data): void { - [$this->class, $this->name] = $data; + $this->unserialize($data[0]); } /** diff --git a/src/PropertyMetadata.php b/src/PropertyMetadata.php index 519d3aa..f5ccd3a 100644 --- a/src/PropertyMetadata.php +++ b/src/PropertyMetadata.php @@ -39,7 +39,10 @@ public function __construct(string $class, string $name) */ public function serialize() { - return serialize($this->__serialize()); + return serialize([ + $this->class, + $this->name, + ]); } /** @@ -53,25 +56,22 @@ public function serialize() */ public function unserialize($str) { - $this->__unserialize((array) unserialize((string) $str)); + [$this->class, $this->name] = unserialize($str); } /** - * @return array + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification */ public function __serialize(): array { - return [ - $this->class, - $this->name, - ]; + return [$this->serialize()]; } /** - * @param array $data + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification */ public function __unserialize(array $data): void { - [$this->class, $this->name] = $data; + $this->unserialize($data[0]); } }