Skip to content

Commit

Permalink
fix(PHP8): added support for PHP 8
Browse files Browse the repository at this point in the history
  • Loading branch information
tadasalisauskas committed May 15, 2023
1 parent 7189f5b commit 755ebb7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "dusank/knapsack",
"name": "tadasalisauskas/knapsack",
"license": "MIT",
"type": "library",
"description": "Collection library for PHP",
Expand Down
18 changes: 18 additions & 0 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public static function range($start = 0, $end = null, $step = 1)
* {@inheritdoc}
* @throws InvalidReturnValue
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
if ($this->inputFactory) {
Expand Down Expand Up @@ -131,11 +132,28 @@ function ($value, $key) {
);
}

public function __serialize()
{
return toArray(
map(
$this->input,
function ($value, $key) {
return [$key, $value];
}
)
);
}

/**
* {@inheritdoc}
*/
public function unserialize($serialized)
{
$this->input = dereferenceKeyValue(unserialize($serialized));
}

public function __unserialize($data)
{
$this->input = dereferenceKeyValue($data);
}
}

0 comments on commit 755ebb7

Please sign in to comment.