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

[DowngradePhp73] Add DowngradePhp73JsonConstRector #1782

Merged
merged 6 commits into from
Feb 8, 2022

Conversation

samsonasik
Copy link
Member

Add DowngradePhp73JsonConstRector for downgrade JSON_THROW_ON_ERROR constant.

Fixes rectorphp/rector#6931

@samsonasik
Copy link
Member Author

/cc @rs-ubaldi

@samsonasik samsonasik force-pushed the add-downgradephp73-json branch from b7371ea to 64131c0 Compare February 8, 2022 21:28
@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I think it is ready.

@samsonasik
Copy link
Member Author

I am merging it ;)

@samsonasik samsonasik merged commit 78a42c7 into main Feb 8, 2022
@samsonasik samsonasik deleted the add-downgradephp73-json branch February 8, 2022 22:12
@samsonasik
Copy link
Member Author

samsonasik commented Feb 8, 2022

It seems we need to handling constant exists check, like:

2) vendor/clue/ndjson-react/src/Decoder.php:36
    ---------- begin diff ----------
@@ @@
             throw new \BadMethodCallException('Options parameter is only supported on PHP 5.4+');
         }
         if (\defined('JSON_THROW_ON_ERROR')) {
-            $options = $options & ~\JSON_THROW_ON_ERROR;
+            $options = $options & ~0;
         }

on current scoped downgrade, ref rectorphp/rector@adcb702#diff-5296e05dc788634e5de6fe389ae1bb99dd50ad8da693877b91bfde3ecf96c41a

@TomasVotruba
Copy link
Member

Thanks 👏 😎

@rs-ubaldi
Copy link

This is awesome thank you guys for finalizing this :-)

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.

Downgrade to PHP 7.2 and json_encode doesn't work well with JSON_THROW_ON_ERROR
4 participants