Category
stdlib · compile lowering · php-src-strict
Problem
When a builtin that returns an array is used inline as an argument to another builtin, the nested expression evaluates to null instead of the returned array. Assigning the same call to a variable first works.
Affects array_keys(), array_values(), stream_get_filters(), and similar array-return builtins nested in in_array(), array_map(), etc.
php-src reference
Repro
test/repro/maintainer_gap_nested_array_builtin_arg.php:
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_nested_array_builtin_arg.php
php bin/vm.php test/repro/maintainer_gap_nested_array_builtin_arg.php'
| Call |
Zend |
VM (bug) |
in_array('a', array_keys($src), true) |
true |
TypeError: haystack null |
in_array('string.rot13', stream_get_filters(), true) |
true |
TypeError: haystack null |
$k = array_keys($src); in_array('a', $k, true) (control) |
true |
true |
Scope (PHP-in-PHP)
| Area |
Path |
| VM call lowering |
nested FUNCCALL return slot must survive as callee argument |
| Compiler |
lib/Compiler.php / opcode emission for call-as-argument |
| Stdlib |
no C runtime workaround — fix expression evaluation |
Distinct from #9390 (enum needle + inline haystack + literal strict mis-bind).
Done when (php-src-strict)
Links
North star #1492
Category
stdlib· compile lowering · php-src-strictProblem
When a builtin that returns an array is used inline as an argument to another builtin, the nested expression evaluates to
nullinstead of the returned array. Assigning the same call to a variable first works.Affects
array_keys(),array_values(),stream_get_filters(), and similar array-return builtins nested inin_array(),array_map(), etc.php-src reference
Zend/zend_execute.c—ZEND_CALL/ return-value consumption for nested callsext/standard/array.c—array_keys,array_valuesext/standard/streams.c—stream_get_filtersRepro
test/repro/maintainer_gap_nested_array_builtin_arg.php:in_array('a', array_keys($src), true)truein_array('string.rot13', stream_get_filters(), true)true$k = array_keys($src); in_array('a', $k, true)(control)truetrueScope (PHP-in-PHP)
FUNCCALLreturn slot must survive as callee argumentlib/Compiler.php/ opcode emission for call-as-argumentDistinct from #9390 (enum needle + inline haystack + literal strict mis-bind).
Done when (php-src-strict)
array_keysandstream_get_filterscount(explode(...))and other nested non-array returns stay greentest/compliance/cases/stdlib/nested_array_builtin_arg.phptLinks
North star #1492