Category
language
Problem
Identity and equality between a enum case object and its backing scalar must be false in PHP 8.1+:
E::A === 1 → false
E::A == 1 → false
This compiler returns true for both (backing coercion in compare).
php-src reference
Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/parity_enum_strict_identity.php
php bin/vm.php test/repro-maintainer/parity_enum_strict_identity.php'
| Engine |
=== |
== |
| Zend |
false |
false |
| VM |
true |
true |
Scope
lib/VM/Variable.php (or compare helpers) — do not equate TYPE_ENUM_CASE to backing int
- JIT/AOT compare lowering (phase 2)
Done when
Related
Category
languageProblem
Identity and equality between a enum case object and its backing scalar must be false in PHP 8.1+:
E::A === 1→ falseE::A == 1→ falseThis compiler returns true for both (backing coercion in compare).
php-src reference
Zend/zend_operators.c—compare_function, enum case handlingRepro
=====falsefalsetruetrueScope
lib/VM/Variable.php(or compare helpers) — do not equateTYPE_ENUM_CASEto backing intDone when
falsefor===and==in reprotest/compliance/cases/language/enum_compare_backing_scalar.phptgreenRelated