Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

adds JSON_ERROR_NON_BACKED_ENUM to allowed JSON::encode() errors. #1707

Merged
merged 5 commits into from
Feb 27, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Util/JSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public static function encode($data, int $options = 0, int $maxDepth = 512): str
$encodedData = json_encode($data, $options, $maxDepth);

$allowedErrors = [\JSON_ERROR_NONE, \JSON_ERROR_RECURSION, \JSON_ERROR_INF_OR_NAN, \JSON_ERROR_UNSUPPORTED_TYPE];
if (\defined('JSON_ERROR_NON_BACKED_ENUM')) {
$allowedErrors[] = \JSON_ERROR_NON_BACKED_ENUM;
}

$encounteredAnyError = json_last_error() !== \JSON_ERROR_NONE;

Expand Down
Loading