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

@ -2665,6 +2665,12 @@ PHP_FUNCTION(chr)
Z_PARAM_LONG(c)
ZEND_PARSE_PARAMETERS_END();
if (UNEXPECTED(c < 0 || c > 255)) {
php_error_docref(NULL, E_DEPRECATED,
"Providing a value not in-between 0 and 255 is deprecated,"
" this is because a byte value must be in the [0, 255] interval."
" The value used will be constrained using %% 256");
}
c &= 0xff;
RETURN_CHAR(c);
}