Skip to content

Compliance: in_array/array_search enum identity parity (#5851, #5592, #5668) - #7920

Merged
PurHur merged 1 commit into
masterfrom
agent/runtime-php-in-array-enum-5851
Jun 10, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/runtime-php-in-array-enum-5851

Conversation

@PurHur

@PurHur PurHur commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add VM + JIT compliance PHPTs for backed-enum in_array() strict/loose and array_search() strict identity rules (php-src-strict).
  • Behavior was already implemented in PHP (ext/standard/in_array.php, ext/standard/array_search.php, lib/VM/Variable.php::identicalTo() / equals()); this run locks regression coverage requested by the issues.

Closes #5851
Closes #5592
Closes #5668

php-src reference

  • ext/standard/array.c — php_in_array, php_array_search with strict flag
  • Zend/zend_operators.c — enum case vs backing scalar never equal (strict or loose)

PHP implementation (existing)

Path Role
ext/standard/in_array.php VM strict via identicalTo, loose via looseEquals
ext/standard/array_search.php VM strict path
lib/VM/Variable.php Enum-aware identicalTo / equals (#5798)
lib/JIT/ArrayBuiltinHelper.php JIT inArray / arraySearch lowering

C runtime shrink

No new C. lib/AOT/runtime/ remains phpc_progress.c only.

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "enum E:int{case A=1;case B=2;} var_export(in_array(1,[E::A,E::B],true)); echo PHP_EOL; var_export(in_array(E::A,[1,2],true)); echo PHP_EOL;"
php bin/jit.php -r "enum E:int{case A=1;case B=2;} var_export(in_array(1,[E::A],false)); echo PHP_EOL;"'

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter "in_array_strict_enum|in_array_enum_loose|array_search_enum_strict"'

Output:

false
false
false

OK (7 tests, 7 assertions)

Made with Cursor

Closes #5851, #5592, and #5668 — behavior already implemented in
ext/standard and lib/VM/Variable.php; this run locks VM+JIT coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 9591ccc into master Jun 10, 2026
@PurHur
PurHur deleted the agent/runtime-php-in-array-enum-5851 branch June 10, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant