Skip to content

Consider named argument flags:JSON_THROW_ON_ERROR for json_ functions as "Safe" #33

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

Closed
wants to merge 3 commits into from

Conversation

pyrou
Copy link

@pyrou pyrou commented Aug 11, 2022

Since PHP8, named argument allows to pass input data into a function, based on their argument name instead of the argument order.

// PHP 7.3
json_decode($payload, null, 512, JSON_THROW_ON_ERROR);
// PHP 8.0
json_decode($payload, flags: JSON_THROW_ON_ERROR);

Because of this, flags might not be any more always on 4th position. This PR bring support of named argument for json_decode and json_encode JSON_THROW_ON_ERROR flag detection.

Copy link
Contributor

@spawnia spawnia left a comment

Choose a reason for hiding this comment

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

I think this implementation is sound and adds a useful feature, I would love to see it merged and released.

@pyrou
Copy link
Author

pyrou commented Nov 17, 2023

ping @moufmouf @dbrekelmans :)

@dbrekelmans
Copy link
Collaborator

@pyrou if you could resolve the conflict, I'll be happy to merge it

@pyrou pyrou requested a review from dbrekelmans November 23, 2024 19:40
shish added a commit that referenced this pull request Feb 19, 2025
… as "Safe"

Manually rebasing, adding unit tests, and fixing the tests, for #33
shish added a commit that referenced this pull request Feb 19, 2025
… as "Safe"

Manually rebasing, adding unit tests, and fixing the tests, for #33
@shish
Copy link
Collaborator

shish commented Feb 19, 2025

Thank you for this <3 I wanted to get it merged ASAP, but there were merge conflicts and no unit tests, so I did the merge by hand in #56

@shish shish closed this Feb 19, 2025
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 this pull request may close these issues.

4 participants