<?php
declare(strict_types=1);
enum E: int { case A = 1; case B = 2; }
var_export(in_array(E::A, [E::A, E::B]));
var_export(in_array(E::A, [E::A, E::B], true));
var_export(array_search(E::A, [E::A, E::B]));
var_export(in_array(1, [E::A], false));
./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_in_array_search_enum.php'
# Zend: true / true / 0 / true
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_in_array_search_enum.php'
# VM: Fatal TypeError haystack null on first in_array()
Category
stdlib· php-src-strict · regressionProblem
#8796 closed with enum needle/haystack parity, but VM regressed:
in_array(E::A, [E::A, E::B])and related calls now fatal withhaystacknull instead of returning booleans/keys. Zend still returnstrue/0as expected.php-src reference
ext/standard/array.c—php_in_array,php_array_searchZend/zend_enum.c— enum case comparison in arraysRepro
test/repro/maintainer_in_array_search_enum.php:in_array(E::A, [E::A, E::B])truein_array(E::A, ..., true)truearray_search(E::A, ...)0in_array(1, [E::A], false)true(loose backing)Coordinate with #8898 for loose scalar-vs-case semantics once haystack wiring is restored.
Scope (this repo)
ext/standard/in_array.php,array_search.php, shared array search helpersDone when
./script/ci-fast.sh --filter InArrayor compliance PHPT guardRelated