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

json_decode exception #9568

Closed
sergey144010 opened this issue Jul 4, 2023 · 4 comments · Fixed by phpstan/phpstan-src#2524
Closed

json_decode exception #9568

sergey144010 opened this issue Jul 4, 2023 · 4 comments · Fixed by phpstan/phpstan-src#2524
Labels
Milestone

Comments

@sergey144010
Copy link

Bug report

default option not see

Code snippet that reproduces the problem

https://phpstan.org/r/03c4de29-fba4-4d84-9055-33e182b1d1db

Expected output

I expect to see the default options

Did PHPStan help you today? Did it make you happy in any way?

No response

@stof
Copy link
Contributor

stof commented Jul 12, 2023

If someone customizes the $flags argument, it will not throw though. So this should still be a "maybe" when deciding whether it throws.

@mad-briller
Copy link
Contributor

mad-briller commented Jul 12, 2023

a code workaround is to or the $flags with JSON_THROW_ON_ERROR:

https://phpstan.org/r/00c8943f-528f-4e23-abd5-126c53a9f6e2

this also fixes the issue that the code wont function correctly if someone passes a $flags that doesn't include JSON_THROW_ON_ERROR

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src#2524

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants