ext/standard: Deprecate passing integers outside the interval [0, 255] to chr() (#19441)

RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_passing_integers_outside_the_interval_0_255_to_chr
This commit is contained in:
Gina Peter Banyard 2025-08-14 20:48:48 +01:00 committed by GitHub
parent 6009b8a100
commit cab46b27b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 139 additions and 160 deletions

View file

@ -4147,17 +4147,19 @@ static zend_result zend_compile_func_defined(znode *result, zend_ast_list *args)
}
/* }}} */
static zend_result zend_compile_func_chr(znode *result, zend_ast_list *args) /* {{{ */
static zend_result zend_compile_func_chr(znode *result, const zend_ast_list *args) /* {{{ */
{
if (args->children == 1 &&
args->child[0]->kind == ZEND_AST_ZVAL &&
Z_TYPE_P(zend_ast_get_zval(args->child[0])) == IS_LONG) {
zend_long c = Z_LVAL_P(zend_ast_get_zval(args->child[0])) & 0xff;
zval *zint;
if (
args->children == 1
&& args->child[0]->kind == ZEND_AST_ZVAL
&& (zint = zend_ast_get_zval(args->child[0]))
&& Z_TYPE_P(zint) == IS_LONG
&& Z_LVAL_P(zint) >= 0
&& Z_LVAL_P(zint) <= 255
) {
result->op_type = IS_CONST;
ZVAL_CHAR(&result->u.constant, c);
ZVAL_CHAR(&result->u.constant, Z_LVAL_P(zint));
return SUCCESS;
} else {
return FAILURE;