Category
language · php-src-strict
Problem
When a function/method call has two or more arguments and both the first and second operands are ternary expressions, the VM/JIT lowering evaluates the first operand to the second ternary’s chosen value instead of the first ternary’s value. Zend evaluates each operand independently.
| Repro |
Zend 8.2 (2026-07-04) |
VM (2026-07-04) |
pair(true ? 'yes' : 'no', false ? 1 : 2) |
a=yes b=2 |
TypeError: pair(): Argument #1 ($a) must be of type string, int given |
sprintf('%s-%d', true ? 'yes' : 'no', false ? 1 : 2) |
yes-2 |
2-2 |
var_dump($x === false ? 'false' : 'array', is_array($x) ? count($x) : null) |
string(5) "array" then int(14) |
int(14) then int(14) |
Root cause is in call argument codegen (not var_dump()-specific) — user-defined typed functions show the same misbinding.
php-src reference
PHP implementation target
lib/Compiler.php — fix multi-arg call lowering when consecutive operands are Expr\Ternary
lib/VM.php / lib/JIT/ — verify VM and JIT agree; no new C runtime branches
Repro
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_call_multiarg_ternary_misbind.php'
php test/repro/maintainer_gap_call_multiarg_ternary_misbind.php
Done when
Category
language· php-src-strictProblem
When a function/method call has two or more arguments and both the first and second operands are ternary expressions, the VM/JIT lowering evaluates the first operand to the second ternary’s chosen value instead of the first ternary’s value. Zend evaluates each operand independently.
pair(true ? 'yes' : 'no', false ? 1 : 2)a=yes b=2TypeError: pair(): Argument #1 ($a) must be of type string, int givensprintf('%s-%d', true ? 'yes' : 'no', false ? 1 : 2)yes-22-2var_dump($x === false ? 'false' : 'array', is_array($x) ? count($x) : null)string(5) "array"thenint(14)int(14)thenint(14)Root cause is in call argument codegen (not
var_dump()-specific) — user-defined typed functions show the same misbinding.php-src reference
Zend/zend_compile.c—zend_compile_call_common/ argument emission orderZend/zend_execute.c—ZEND_CALLframe argument slotsPHP implementation target
lib/Compiler.php— fix multi-arg call lowering when consecutive operands areExpr\Ternarylib/VM.php/lib/JIT/— verify VM and JIT agree; no new C runtime branchesRepro
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_call_multiarg_ternary_misbind.php' php test/repro/maintainer_gap_call_multiarg_ternary_misbind.phpDone when
pair(),sprintf(), andvar_dump()repro outputs match Zend on VM.phptguard undertest/compliance/cases/language/