Category
stdlib
Problem
Zend treats array_map(null, $array) as the single-array identity form: it returns a copy of $array without invoking a callback. This compiler mis-parses the null callback and raises TypeError: array_map(): Argument #2 ($array) must be of type array, null given (or fatals with no output) — a regression of closed #4539.
php-src reference
ext/standard/array.c — php_array_map() null-callback branch (ZEND_FCI_INITIALIZED guard)
- Tests:
ext/standard/tests/array/array_map_variation*.phpt
Repro
Create test/repro/maintainer_gap_array_map_null.php:
<?php
$out = array_map(null, [1, 2, 3]);
echo implode(',', $out), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_array_map_null.php'
php test/repro/maintainer_gap_array_map_null.php
Zend:
This compiler (VM, 2026-06-17):
PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given
(or empty output when wrapped in other calls)
Multi-array zip must remain unchanged:
<?php
var_export(array_map(null, [1,2], ['a','b'])); // Zend: array([0]=>array(1,'a'), ...)
Scope (this repo)
| Area |
Path |
Action |
| Stdlib |
ext/standard/array_map.php |
Detect null callback + exactly one array → identity copy |
| VM |
builtin dispatch |
No special case in lib/VM.php — fix builtin |
| JIT |
lib/JIT/Builtin/ array_map lowering |
Mirror PHP guard when JIT supports array_map |
PHP-in-PHP: implement in ext/standard/array_map.php; shared guard for JIT if lowered.
Done when (php-src-strict)
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter array_map_null'
Related
Category
stdlibProblem
Zend treats
array_map(null, $array)as the single-array identity form: it returns a copy of$arraywithout invoking a callback. This compiler mis-parses thenullcallback and raisesTypeError: array_map(): Argument #2 ($array) must be of type array, null given(or fatals with no output) — a regression of closed #4539.php-src reference
ext/standard/array.c—php_array_map()null-callback branch (ZEND_FCI_INITIALIZEDguard)ext/standard/tests/array/array_map_variation*.phptRepro
Create
test/repro/maintainer_gap_array_map_null.php:./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_array_map_null.php' php test/repro/maintainer_gap_array_map_null.phpZend:
This compiler (VM, 2026-06-17):
(or empty output when wrapped in other calls)
Multi-array zip must remain unchanged:
Scope (this repo)
ext/standard/array_map.phpnullcallback + exactly one array → identity copylib/VM.php— fix builtinlib/JIT/Builtin/array_map loweringPHP-in-PHP: implement in
ext/standard/array_map.php; shared guard for JIT if lowered.Done when (php-src-strict)
php bin/vm.php test/repro/maintainer_gap_array_map_null.phpprints1,2,3array_map(null, ...)still zips per Zendtest/compliance/cases/stdlib/array_map_null_identity.phptVerification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter array_map_null'Related