[php-src] master: ext/standard: name the real parameter in the unpack() offset error (#24215)

From: Date: Fri, 09 Oct 2026 14:22:09 +0000
Subject: [php-src] master: ext/standard: name the real parameter in the unpack() offset error (#24215)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142116@lists.php.net to get a copy of this message
Author: Louis-Arnaud (lacatoire) Committer: GitHub (web-flow) Pusher: LamentXU123 Date: 2026-10-09T22:22:05+08:00 Commit: https://github.com/php/php-src/commit/a276f5d6b1ab35391714e669cb2002eb7100cb93 Raw diff: https://github.com/php/php-src/commit/a276f5d6b1ab35391714e669cb2002eb7100cb93.diff 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. Changed paths: M ext/standard/pack.c M ext/standard/tests/strings/unpack_offset.phpt Diff: diff --git a/ext/standard/pack.c b/ext/standard/pack.c index c8cbf8613f63..969f5a2db742 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 a3046c32d6f9..36d3f49eb495 100644 --- a/ext/standard/tests/strings/unpack_offset.phpt +++ b/ext/standard/tests/strings/unpack_offset.phpt @@ -21,9 +21,17 @@ try { } 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

« previous php.cvs (#142116) next »