Category
Regression · php-src-strict · stdlib
Problem
In strict mode, an int needle must match an int haystack element by identity/type — not an enum case with the same backing value. When the matching scalar appears at index 0 before an enum case, Zend returns 0; the VM returns false.
| Repro |
Zend 8.2 |
VM (2026-07-05) |
array_search(1, [1, E::A], true) with enum E: int { case A = 1; } |
0 |
false |
Closed #8886 tracked the inverse ordering; this ordering still diverges after close.
php-src reference
PHP implementation target
ext/standard/ array_search lowering — shared strict equality guard with in_array(); ensure scalar int matches int element before enum-case handling
lib/VM.php / lib/JIT/ — same semantics when both backends are in scope
Repro
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_array_search_strict_scalar_order.php'
./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_gap_array_search_strict_scalar_order.php'
Done when
Category
Regression· php-src-strict · stdlibProblem
In strict mode, an
intneedle must match aninthaystack element by identity/type — not an enum case with the same backing value. When the matching scalar appears at index0before an enum case, Zend returns0; the VM returnsfalse.array_search(1, [1, E::A], true)withenum E: int { case A = 1; }0falseClosed #8886 tracked the inverse ordering; this ordering still diverges after close.
php-src reference
ext/standard/array.c—php_array_search/ strict compare pathPHP implementation target
ext/standard/array_search lowering — shared strict equality guard within_array(); ensure scalarintmatchesintelement before enum-case handlinglib/VM.php/lib/JIT/— same semantics when both backends are in scopeRepro
Done when
0matching Zend for the repro (JIT/AOT if array_search is lowered there).phptguard undertest/compliance/cases/stdlib/