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

pick should use array_key_exists instead of isset #217

Closed
lorenzomar opened this issue May 13, 2020 · 3 comments · Fixed by #239
Closed

pick should use array_key_exists instead of isset #217

lorenzomar opened this issue May 13, 2020 · 3 comments · Fixed by #239

Comments

@lorenzomar
Copy link

pick source code use isset to check if the given key is present in the collection. This implies that NULL values are not valid but they should be. What about to use array_key_exists?

@lstrojny
Copy link
Owner

The behavior difference would be in case you have a default value other than null specified, right?

@lorenzomar
Copy link
Author

Hey lstrojny, so sorry for the delay.
From a pragmatic point of view you're right but i think that the real difference is more conceptual. isset doesn't consider null as a valid value but there are cases where a collection contains a mix of null values, falsy value, etc and they are all right.
In that cases current implementation of pick fails.

@lstrojny
Copy link
Owner

Makes all sense, should indeed be array_key_exists. Want to open a PR for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants