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

added both the JSON_THROW_ON_ERROR and JSON_INVALID_UTF8_IGNORE flag #1065

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

simkoc
Copy link

@simkoc simkoc commented Jan 23, 2025

My proposed PR to address #1064. All tests are passing:

PHP-Parser$> ./vendor/phpunit/phpunit/phpunit
PHPUnit 9.6.20 by Sebastian Bergmann and contributors.

.............................................................   61 / 1794 (  3%)
.............................................................  122 / 1794 (  6%)
.............................................................  183 / 1794 ( 10%)
.............................................................  244 / 1794 ( 13%)
.............................................................  305 / 1794 ( 17%)
.............................................................  366 / 1794 ( 20%)
.............................................................  427 / 1794 ( 23%)
.............................................................  488 / 1794 ( 27%)
.............................................................  549 / 1794 ( 30%)
.............................................................  610 / 1794 ( 34%)
.............................................................  671 / 1794 ( 37%)
.............................................................  732 / 1794 ( 40%)
.............................................................  793 / 1794 ( 44%)
.............................................................  854 / 1794 ( 47%)
.............................................................  915 / 1794 ( 51%)
.............................................................  976 / 1794 ( 54%)
............................................................. 1037 / 1794 ( 57%)
............................................................. 1098 / 1794 ( 61%)
............................................................. 1159 / 1794 ( 64%)
............................................................. 1220 / 1794 ( 68%)
............................................................. 1281 / 1794 ( 71%)
............................................................. 1342 / 1794 ( 74%)
............................................................. 1403 / 1794 ( 78%)
............................................................. 1464 / 1794 ( 81%)
............................................................. 1525 / 1794 ( 85%)
............................................................. 1586 / 1794 ( 88%)
............................................................. 1647 / 1794 ( 91%)
............................................................. 1708 / 1794 ( 95%)
............................................................. 1769 / 1794 ( 98%)
.........................                                     1794 / 1794 (100%)

Time: 00:01.055, Memory: 26.00 MB

OK (1794 tests, 2634 assertions)

@@ -82,7 +82,7 @@ foreach ($files as $file) {
echo $prettyPrinter->prettyPrintFile($stmts), "\n";
} elseif ('json-dump' === $operation) {
fwrite(STDERR, "==> JSON dump:\n");
echo json_encode($stmts, JSON_PRETTY_PRINT), "\n";
echo json_encode($stmts, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE), "\n";
Copy link
Owner

Choose a reason for hiding this comment

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

If we do this, I'd prefer using JSON_INVALID_UTF8_SUBSTITUTE instead, to indicate that the string has been corrupted.

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.

2 participants