Commit a276f5d6b1a for php
commit a276f5d6b1ab35391714e669cb2002eb7100cb93
Author: Louis-Arnaud <la.catoire@gmail.com>
Date: Fri Oct 9 16:22:05 2026 +0200
ext/standard: name the real parameter in the unpack() offset error (#24215)
The message cross-references argument #2 as $data, a name unpack() lost
in 25f1c405ff when the ext/standard parameters were renamed for 8.0; it
is $string. The same phrasing elsewhere, in substr_count() and friends,
names the real parameter.
diff --git a/ext/standard/pack.c b/ext/standard/pack.c
index c8cbf8613f6..969f5a2db74 100644
--- a/ext/standard/pack.c
+++ b/ext/standard/pack.c
@@ -803,7 +803,7 @@ PHP_FUNCTION(unpack)
if (offset < 0 || offset > inputlen) {
- zend_argument_value_error(3, "must be contained in argument #2 ($data)");
+ zend_argument_value_error(3, "must be contained in argument #2 ($string)");
RETURN_THROWS();
}
diff --git a/ext/standard/tests/strings/unpack_offset.phpt b/ext/standard/tests/strings/unpack_offset.phpt
index a3046c32d6f..36d3f49eb49 100644
--- a/ext/standard/tests/strings/unpack_offset.phpt
+++ b/ext/standard/tests/strings/unpack_offset.phpt
@@ -21,9 +21,17 @@
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
+
+/* the message names argument #2, so that name has to be the real one */
+foreach ((new ReflectionFunction('unpack'))->getParameters() as $parameter) {
+ echo '$', $parameter->getName(), "\n";
+}
?>
--EXPECT--
0x01020304 0x05060708
0x01020304 0x05060708
-ValueError: unpack(): Argument #3 ($offset) must be contained in argument #2 ($data)
-ValueError: unpack(): Argument #3 ($offset) must be contained in argument #2 ($data)
+ValueError: unpack(): Argument #3 ($offset) must be contained in argument #2 ($string)
+ValueError: unpack(): Argument #3 ($offset) must be contained in argument #2 ($string)
+$format
+$string
+$offset