File tree Expand file tree Collapse file tree 3 files changed +8
-0
lines changed Expand file tree Collapse file tree 3 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -347,6 +347,7 @@ PHP NEWS
347
347
- JSON:
348
348
. Fixed bug #81532 (Change of $depth behaviour in json_encode() on PHP 8.1).
349
349
(Nikita)
350
+ . Fixed bug GH-8238 (Register JSON_ERROR_NON_BACKED_ENUM constant). (ilutov)
350
351
351
352
- LDAP:
352
353
. Convert resource<ldap link> to object \LDAP\Connection. (Máté)
Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ enum CustomFoo implements JsonSerializable {
26
26
function test ($ value ) {
27
27
var_dump (json_encode ($ value ));
28
28
echo json_last_error_msg () . "\n" ;
29
+ if (json_last_error () !== JSON_ERROR_NONE ) {
30
+ echo json_last_error () . ' === ' . JSON_ERROR_NON_BACKED_ENUM . ": \n" ;
31
+ var_dump (json_last_error () === JSON_ERROR_NON_BACKED_ENUM );
32
+ }
29
33
30
34
try {
31
35
var_dump (json_encode ($ value , JSON_THROW_ON_ERROR ));
@@ -44,6 +48,8 @@ test(CustomFoo::Bar);
44
48
--EXPECT--
45
49
bool(false)
46
50
Non-backed enums have no default serialization
51
+ 11 === 11:
52
+ bool(true)
47
53
JsonException: Non-backed enums have no default serialization
48
54
string(1) "0"
49
55
No error
Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ static PHP_MINIT_FUNCTION(json)
83
83
PHP_JSON_REGISTER_CONSTANT ("JSON_ERROR_UNSUPPORTED_TYPE" , PHP_JSON_ERROR_UNSUPPORTED_TYPE );
84
84
PHP_JSON_REGISTER_CONSTANT ("JSON_ERROR_INVALID_PROPERTY_NAME" , PHP_JSON_ERROR_INVALID_PROPERTY_NAME );
85
85
PHP_JSON_REGISTER_CONSTANT ("JSON_ERROR_UTF16" , PHP_JSON_ERROR_UTF16 );
86
+ PHP_JSON_REGISTER_CONSTANT ("JSON_ERROR_NON_BACKED_ENUM" , PHP_JSON_ERROR_NON_BACKED_ENUM );
86
87
87
88
return SUCCESS ;
88
89
}
You can’t perform that action at this time.
0 commit comments