mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
parent
ced5581eca
commit
2145f80d4b
1
NEWS
1
NEWS
@ -347,6 +347,7 @@ PHP NEWS
|
||||
- JSON:
|
||||
. Fixed bug #81532 (Change of $depth behaviour in json_encode() on PHP 8.1).
|
||||
(Nikita)
|
||||
. Fixed bug GH-8238 (Register JSON_ERROR_NON_BACKED_ENUM constant). (ilutov)
|
||||
|
||||
- LDAP:
|
||||
. Convert resource<ldap link> to object \LDAP\Connection. (Máté)
|
||||
|
@ -26,6 +26,10 @@ enum CustomFoo implements JsonSerializable {
|
||||
function test($value) {
|
||||
var_dump(json_encode($value));
|
||||
echo json_last_error_msg() . "\n";
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
echo json_last_error() . ' === ' . JSON_ERROR_NON_BACKED_ENUM . ":\n";
|
||||
var_dump(json_last_error() === JSON_ERROR_NON_BACKED_ENUM);
|
||||
}
|
||||
|
||||
try {
|
||||
var_dump(json_encode($value, JSON_THROW_ON_ERROR));
|
||||
@ -44,6 +48,8 @@ test(CustomFoo::Bar);
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
Non-backed enums have no default serialization
|
||||
11 === 11:
|
||||
bool(true)
|
||||
JsonException: Non-backed enums have no default serialization
|
||||
string(1) "0"
|
||||
No error
|
||||
|
@ -83,6 +83,7 @@ static PHP_MINIT_FUNCTION(json)
|
||||
PHP_JSON_REGISTER_CONSTANT("JSON_ERROR_UNSUPPORTED_TYPE", PHP_JSON_ERROR_UNSUPPORTED_TYPE);
|
||||
PHP_JSON_REGISTER_CONSTANT("JSON_ERROR_INVALID_PROPERTY_NAME", PHP_JSON_ERROR_INVALID_PROPERTY_NAME);
|
||||
PHP_JSON_REGISTER_CONSTANT("JSON_ERROR_UTF16", PHP_JSON_ERROR_UTF16);
|
||||
PHP_JSON_REGISTER_CONSTANT("JSON_ERROR_NON_BACKED_ENUM", PHP_JSON_ERROR_NON_BACKED_ENUM);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user