[php-src] Issue #8238: Expose new constant for JSON_ERROR_NON_BACKED_ENUM

From: Date: Tue, 22 Mar 2022 04:38:20 +0000
Subject: [php-src] Issue #8238: Expose new constant for JSON_ERROR_NON_BACKED_ENUM
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-240450@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8238 Author: lcdennison ### Description When a non-backed enum is part of the data given to json_encode(), an integer error code (11) will be generated that is not currently available via JSON_ERROR_* constants. This error code seems to be internally recognized and supported (e.g. has a message) within PHP: https://github.com/php/php-src/blob/ec53e17adf4f1669411334750a1d47954e2bc8e3/ext/json/json.c#L190-L191 However, it seems that a public constant is not available as it is not currently included in the list of defined constants: https://github.com/php/php-src/blob/ec53e17adf4f1669411334750a1d47954e2bc8e3/ext/json/json.c#L74-L85 My "feature request" is simply that this constant (JSON_ERROR_NON_BACKED_ENUM?) be added so we do not have to rely on the integer 11 to handle this error case. -- Side note, it seems the 11 code is simply a result of that internal PHP_JSON_ERROR_NON_BACKED_ENUM being the 12th item (thus 11 index) in this enum list: https://github.com/php/php-src/blob/ec53e17adf4f1669411334750a1d47954e2bc8e3/ext/json/php_json.h#L42-L56

« previous php.bugs (#240450) next »