Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.1 compatibility #75

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": "martinvenus/knapsack",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinvenus Could we keep please the original author name?

In my humble opinion, unless this package is declared as abandoned or archived, Information like this should be kept the same.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have lost hope that this will be merged someday and have made other changes to my repository. It's been a few years since I did this PR.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you. But maybe this changed line is preventing the author to merge it, we do not know :)

In your fork main branch, you can change the name if desired, if a Pull Request is made against this repository which is considered still mainstream, I would advise otherwise. I guess at some point people will start using your fork if no reaction is noticed, like normally happened with many other open source projects that gets unattended in time.

Thanks for answering and regards!
David

"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);
}
}