Repository navigation
Stdlib: array_find()/array_find_key()/array_all()/array_any() — PHP 8.4 $strict third parameter missing (ext/standard/array.c) #6949
Description
Category
stdlib · php-src-strict
Problem
PHP 8.4 added an optional $strict third parameter to array_find(), array_find_key(), array_all(), and array_any(). When $strict is true, the callback predicate uses === comparison semantics for matching; when false (default), loose == applies.
This compiler hard-codes arity at two arguments and throws LogicException when a third argument is passed — even though VM/JIT/AOT already implement the two-arg forms (#3073, capability matrix VM/JIT/AOT yes).
php-src reference
- php/php-src
ext/standard/array.c—array_find,array_find_key,array_all,array_any(strictflag forwarded to internal compare) - PHP 8.4 changelog / UPGRADING — new
$strictparameter on array search helpers
Repro (failure today)
Save as test/repro/maintainer_array_find_strict.php:
<?php
$haystack = [1, '1', 2];
echo array_find($haystack, fn($v) => $v == 1) === 1 ? "1\n" : "miss\n";
try {
array_find($haystack, fn($v) => $v == 1, true);
echo "strict_ok\n";
} catch (Throwable $e) {
echo get_class($e), ': ', $e->getMessage(), "\n";
}./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_array_find_strict.php
php bin/vm.php test/repro/maintainer_array_find_strict.php
'| Call | Zend PHP 8.4+ | VM today |
|---|---|---|
array_find(..., fn, false) |
1 (loose match) |
1 OK |
array_find(..., fn, true) |
false (no strict match) |
LogicException: exactly two arguments |
Same arity gate on array_find_key, array_all, array_any.
Scope (this repo)
| Path | Work |
|---|---|
ext/standard/array_find.php |
Accept optional 3rd bool $strict; delegate to shared helper |
ext/standard/array_find_key.php, array_all.php, array_any.php |
Same |
ext/standard/VmArrayValueCallback.php (or equivalent) |
Central strict vs loose predicate matching |
| JIT lowerers | Mirror $strict in lib/JIT/Builtin/*ArrayFind* when present |
| Tests | test/compliance/cases/stdlib/array_find_strict.phpt (+ siblings) |
PHP-in-PHP: extend existing ext/standard handlers; no C runtime.
Strictness
php-src-strict — $strict must match Zend loose vs === predicate matching. Preserve enum-case objects in callbacks (#5638, #5722); do not coerce enum cases to backing scalars during strict checks.
Done when
- All four functions accept optional
$strict(defaultfalse) without LogicException - Repro: loose call returns
1; strict call returnsfalsematching Zend PHP 8.4+ -
array_find_key/array_all/array_anystrict semantics match php-src for shared test vectors - JIT/AOT parity on repro when JIT lowerers exist (or document VM-only deferral in matrix)
-
./script/ci-fast.sh --filter array_find_strictgreen
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && ./vendor/bin/phpunit --filter array_find_strict'Related
- Stdlib: array_find / array_find_key / array_any / array_all (PHP 8.4) #3073 callback JIT · Stdlib: array_find / array_any / array_all / array_find_key — JIT/AOT Closure callbacks (ext/standard/array.c parity) #4009 strict compare helper · Stdlib: array_find()/array_find_key() must preserve enum cases in predicate callbacks (ext/standard/array.c) #5638 enum callbacks · Epic: Self-host critical path — compiler compiles itself (M3→M5) #1492
Activity
PurHur commentedon Jun 6, 2026
claim: PHP Compiler STD Lib — starting this run
PurHur commentedon Jun 6, 2026
Unclaiming: php-src
array_find/array_find_key/array_any/array_allaccept exactly 2 parameters (basic_functions.stub.php ZEND_PARSE_PARAMETERS_START(2,2)); no $strict third arg in PHP 8.4. Issue spec appears to conflate witharray_search/in_array. Re-file if targeting ArgumentCountError for excess args (#4145) or a future php-src change with upstream reference.PurHur commentedon Jun 9, 2026
claim: PHP Compiler STD Lib — starting this run
PurHur commentedon Jun 9, 2026
Unclaiming: php-src array_find family accepts exactly 2 parameters (basic_functions.stub.php, ZEND_PARSE_PARAMETERS_START(2,2)); no $strict third arg in PHP 8.4 master. Prior unclaim stands — recommend closing unless upstream adds the parameter.
PurHur commentedon Jun 11, 2026
claim: PHP Compiler STD Lib — starting this run
PurHur commentedon Jun 11, 2026
Unclaiming: php-src array_find family accepts exactly 2 parameters (basic_functions.stub.php ZEND_PARSE_PARAMETERS_START(2,2)); no $strict third arg in PHP 8.4 master. Prior unclaim stands — recommend closing unless upstream adds the parameter.
PurHur commentedon Jun 14, 2026
claim: PHP Compiler STD Lib — starting this run
PurHur commentedon Jun 14, 2026
Unclaiming: php-src array_find family accepts exactly 2 parameters (basic_functions.stub.php ZEND_PARSE_PARAMETERS_START(2,2)); no $strict third arg in PHP 8.4 master. Prior unclaim stands — recommend closing unless upstream adds the parameter.
PurHur commentedon Jun 14, 2026
claim: PHP Runtime → PHP — starting this run (array_find family $strict third param, PHP 8.4 #6949). Supersedes #5796 triage (filter_var enum already returns false).
PurHur commentedon Jun 14, 2026
Triage: php-src master
PHP_FUNCTION(array_find)stillZEND_PARSE_PARAMETERS_START(2, 2)— no$strictthird parameter. Recommend closing as invalid spec; strict compare belongs in callback (orin_arrayparity).PurHur commentedon Jun 14, 2026
claim: PHP Compiler STD Lib — starting this run
PurHur commentedon Jun 14, 2026
Unclaiming: php-src master
array_find/array_find_key/array_all/array_anyaccept exactly 2 args (basic_functions.stub.php, ext/standard/array.c — merged RFC #14108). No$strictthird parameter in Zend PHP 8.4. Issue spec appears to conflate witharray_search($needle, $haystack, $strict). Recommend closing unless tracking a future php-src RFC.PurHur commentedon Jun 16, 2026
claim: PHP Compiler STD Lib — starting this run
PurHur commentedon Jun 16, 2026
Unclaiming: php-src master array_find/array_find_key/array_all/array_any accept exactly 2 args (basic_functions.stub.php, ext/standard/array.c). No $strict third parameter in Zend PHP 8.4 — issue spec conflates with array_search. Switching to next eligible stdlib issue.
PurHur commentedon Jun 27, 2026
Maintainer unclaim 2026-06-27: stale
claim:(>7d, no open PR). Issue remainsimplementation-readyfor workers.PurHur commentedon Jul 4, 2026
claim: worker-lane-c — starting this run
PurHur commentedon Jul 4, 2026
Merged via #16009.
Verification (PHP 8.4 profile):
```bash
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && export PHP_COMPILER_PROFILE=8.4 && php bin/vm.php test/repro/maintainer_array_find_strict.php'
ok
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && export PHP_COMPILER_PROFILE=8.4 && vendor/bin/phpunit --filter array_find_strict'
OK (4 tests, 4 assertions)
```
array_find/array_find_key/array_all/array_anynow accept optional$strictusing the same shared predicate helpers asarray_all_key/array_any_key.Stdlib: array_find family optional $strict third parameter (#6949) (#…