Category
bug · php-src-strict · stdlib · min/max / argument unpacking
Problem
Unpacking an array with string keys into max() / min() becomes named arguments. Zend rejects that with ArgumentCountError (max() expects at least 1 argument, 0 given — named keys do not count as positional values). The VM instead hits ext/standard/VmMinMax.php and fatals:
Error: Call to a member function resolveIndirect() on null (after Undefined array key 0).
Verified 2026-07-26 (host Zend 8.2 vs php bin/vm.php):
| Repro |
Zend 8.2+ |
VM (2026-07-26) |
max(...["a"=>1,"b"=>2]) |
ArgumentCountError: max() expects at least 1 argument, 0 given |
Warning Undefined array key 0 in VmMinMax.php:162 then Error: … resolveIndirect() on null |
min(...["a"=>3,"b"=>1]) |
same ArgumentCountError for min |
same VM crash |
max(...["0"=>5,"1"=>9]) (numeric string keys) |
9 |
9 (OK) |
php-src reference
PHP implementation target
ext/standard/VmMinMax.php — collectValues() must not assume calledArgs[0] when string-key unpack left argc inconsistent; throw Zend-compatible ArgumentCountError when no positional values remain
- Shared call/named-arg path in
lib/ if unpack already should reject unknown named params before enter
- PHP-in-PHP only; no new C runtime
Repro
./script/docker-exec.sh -- bash -lc 'cat > /tmp/max_unpack.php <<'"'"'PHP'"'"'
<?php
try {
var_export(max(...["a" => 1, "b" => 2]));
echo "\n";
} catch (Throwable $e) {
echo get_class($e), ":", $e->getMessage(), "\n";
}
PHP
php /tmp/max_unpack.php
php bin/vm.php /tmp/max_unpack.php'
Done when
Category
bug· php-src-strict · stdlib · min/max / argument unpackingProblem
Unpacking an array with string keys into
max()/min()becomes named arguments. Zend rejects that withArgumentCountError(max() expects at least 1 argument, 0 given— named keys do not count as positional values). The VM instead hitsext/standard/VmMinMax.phpand fatals:Error: Call to a member function resolveIndirect() on null(afterUndefined array key 0).Verified 2026-07-26 (host Zend 8.2 vs
php bin/vm.php):max(...["a"=>1,"b"=>2])ArgumentCountError: max() expects at least 1 argument, 0 givenUndefined array key 0inVmMinMax.php:162thenError: … resolveIndirect() on nullmin(...["a"=>3,"b"=>1])ArgumentCountErrorforminmax(...["0"=>5,"1"=>9])(numeric string keys)99(OK)php-src reference
ext/standard/array.c—PHP_FUNCTION(max)/minvariadic handlingext/standard/basic_functions.stub.php—max(mixed $value, mixed ...$values)/min(...)Zend/zend_execute.c/ call machineryPHP implementation target
ext/standard/VmMinMax.php—collectValues()must not assumecalledArgs[0]when string-key unpack left argc inconsistent; throw Zend-compatibleArgumentCountErrorwhen no positional values remainlib/if unpack already should reject unknown named params before enterRepro
Done when
ArgumentCountErrormatching Zend message formax/minstring-key unpack (noresolveIndirectError)max($array)paths still match Zend.phptundertest/compliance/cases/