From 03bd54786d852a778d4f129aab57f8de7f8541ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Venu=C5=A1?= Date: Wed, 24 Nov 2021 12:35:04 +0100 Subject: [PATCH 1/3] Fix "Serializable interface is deprecated" in PHP 8.1 https://php.watch/versions/8.1/serializable-deprecated --- src/Collection.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Collection.php b/src/Collection.php index f8037a0..9f27bf2 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -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); + } } From f65c74ed0597464bc311acdd0864517cc833101f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Venu=C5=A1?= Date: Wed, 24 Nov 2021 12:36:03 +0100 Subject: [PATCH 2/3] Fix missing return type for getIterator method in PHP 8.1 --- src/Collection.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Collection.php b/src/Collection.php index 9f27bf2..467b2b7 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -95,6 +95,7 @@ public static function range($start = 0, $end = null, $step = 1) * {@inheritdoc} * @throws InvalidReturnValue */ + #[\ReturnTypeWillChange] public function getIterator() { if ($this->inputFactory) { From 3714e64a976ee2e3febcc64e15ca6c9cf61e4b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Venu=C5=A1?= Date: Tue, 30 Aug 2022 12:40:56 +0200 Subject: [PATCH 3/3] Change package name --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 951fc70..67faec8 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "dusank/knapsack", + "name": "martinvenus/knapsack", "license": "MIT", "type": "library", "description": "Collection library for PHP",