Stdlib: json_encode(unit enum) JSON_ERROR_NON_BACKED_ENUM (#22681, #22688)#22726
Merged
Conversation
#22688) Match php-src ext/json: return false with error 11 / Zend message, and never ValueError on forward 8.4 profiles. JSON_THROW_ON_ERROR raises JsonException with the same text. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
VmJson::exportEnumCasenow rejects unit enums withJSON_ERROR_NON_BACKED_ENUM(11) and Zend'sNon-backed enums have no default serializationmessage (php-srcext/json/json_encoder.c).ValueErrorpath (CompilerVersion::jsonEncodeUnitEnumValueError()always false) soPHP_COMPILER_PROFILE=8.4matches Zend 8.2–8.4 (false+ last-error;JsonExceptiononly withJSON_THROW_ON_ERROR).Closes #22681
Closes #22688
php-src reference
ext/json/json_encoder.c— unit enum →JSON_ERROR_NON_BACKED_ENUMext/standard/VmJson.php(shared by VM +JsonEncodeJitHelperJIT/AOT)Verification
AOT note:
bin/compile.phpof a unit-enum encode smoke links viaJsonEncodeJitHelper(same SSOT) but native run currently segfaults on enum materialization (phpc: fatal signal after c:main_before_php) — pre-existing, also seen for backed-enum encode; not introduced by this message/error-code fix. JIT path (same helper) is green.Gate snapshot (pre-change master, this host)
user_release_ready: no—north-star5-faststep 4f-m gen-0 fingerprint (#8713 / PR #22717)Made with Cursor