File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ enum CustomFoo implements JsonSerializable {
2626function test ($ value ) {
2727 var_dump (json_encode ($ value ));
2828 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+ }
2933
3034 try {
3135 var_dump (json_encode ($ value , JSON_THROW_ON_ERROR ));
@@ -44,6 +48,8 @@ test(CustomFoo::Bar);
4448--EXPECT--
4549bool(false)
4650Non-backed enums have no default serialization
51+ 11 === 11:
52+ bool(true)
4753JsonException: Non-backed enums have no default serialization
4854string(1) "0"
4955No error
Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ static PHP_MINIT_FUNCTION(json)
8383 PHP_JSON_REGISTER_CONSTANT ("JSON_ERROR_UNSUPPORTED_TYPE" , PHP_JSON_ERROR_UNSUPPORTED_TYPE );
8484 PHP_JSON_REGISTER_CONSTANT ("JSON_ERROR_INVALID_PROPERTY_NAME" , PHP_JSON_ERROR_INVALID_PROPERTY_NAME );
8585 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 );
8687
8788 return SUCCESS ;
8889}
You can’t perform that action at this time.
0 commit comments