From 275899216e790302ffbf02c94ce0adf02ee05031 Mon Sep 17 00:00:00 2001 From: Peter Bowyer Date: Fri, 11 Mar 2022 08:20:24 +0000 Subject: [PATCH] Update for PHP 8 --- src/Postcode.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Postcode.php b/src/Postcode.php index 377391b..cfffc2b 100644 --- a/src/Postcode.php +++ b/src/Postcode.php @@ -317,7 +317,7 @@ public function split() * * @return string */ - public function __toString() + public function __toString(): string { return (string) $this->normalise(); } @@ -346,6 +346,24 @@ public function unserialize($serialized) return $this->value; } + /** + * Generates a storable representation of a value + * + */ + public function __serialize(): array + { + return [$this->value]; + } + + /** + * Creates a PHP value from a stored representation + * + */ + public function __unserialize(array $serialized): void + { + $this->value = $serialized[0]; + } + /** * Specify data which should be serialized to JSON @@ -353,6 +371,7 @@ public function unserialize($serialized) * @return mixed data which can be serialized by json_encode, * @link http://php.net/manual/en/jsonserializable.jsonserialize.php */ + #[\ReturnTypeWillChange] public function jsonSerialize() { return [