diff --git a/composer.json b/composer.json index 951fc70..af2d28d 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "symfony/console": "^2.7" }, "require": { - "php": ">=5.6.0" + "php": ">=8.1" }, "autoload": { "files": [ diff --git a/src/Collection.php b/src/Collection.php index f8037a0..087414a 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -8,7 +8,7 @@ use IteratorAggregate; use Traversable; -class Collection implements IteratorAggregate, \Serializable, CollectionInterface +class Collection implements IteratorAggregate, CollectionInterface { use CollectionTrait; @@ -95,7 +95,7 @@ public static function range($start = 0, $end = null, $step = 1) * {@inheritdoc} * @throws InvalidReturnValue */ - public function getIterator() + public function getIterator(): Traversable { if ($this->inputFactory) { $input = call_user_func($this->inputFactory); @@ -131,6 +131,18 @@ function ($value, $key) { ); } + public function __serialize() + { + return toArray( + map( + $this->input, + function ($value, $key) { + return [$key, $value]; + } + ) + ); + } + /** * {@inheritdoc} */ @@ -138,4 +150,9 @@ public function unserialize($serialized) { $this->input = dereferenceKeyValue(unserialize($serialized)); } + + public function __unserialize($data) + { + $this->input = dereferenceKeyValue($data); + } }