From 371d64694f2a477e57c650677289878fa7098324 Mon Sep 17 00:00:00 2001 From: Christoph Kempen Date: Mon, 11 May 2026 10:30:30 +0200 Subject: [PATCH] Replace chr() with pack("C") in encodeInt8 to silence PHP 8.5 deprecation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHP 8.5 deprecates chr() with values outside [0, 255] (modulo-256 silent fallback). encodeInt8 is called from MysqlEncodedValue::fromValue for int parameters in [-128, 127] (the Tiny branch), and from encodeInt for length prefixes up to 250, so it routinely receives negative ints that trigger the warning. pack("C", $int) produces the same byte across the full input range and matches the existing pack-family idiom used by encodeInt16/24/32: encodeInt16 → \pack("v", $int) encodeInt24 → \substr(\pack("V", $int), 0, 3) encodeInt32 → \pack("V", $int) encodeInt8 → \pack("C", $int) (this commit) Verified bit-identical to the old chr() output for the full [-128, 255] input range, no behavior change. --- src/MysqlDataType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MysqlDataType.php b/src/MysqlDataType.php index 21ed687..139fa86 100644 --- a/src/MysqlDataType.php +++ b/src/MysqlDataType.php @@ -518,7 +518,7 @@ public static function encodeInt(int $int): string public static function encodeInt8(int $int): string { - return \chr($int); + return \pack("C", $int); } public static function encodeInt16(int $int): string