Category
language · php-src-strict
Problem
Comparing two distinct backed enum cases must use enum identity rules: == / === are false for different cases; <=> compares backing values. VM coerces cases to backing scalars and returns wrong results (E::A == E::B is true, <=> is 0).
Verified 2026-06-16: Zend PHP 8.2 vs php bin/vm.php.
php-src reference
Repro
test/repro/maintainer_gap_enum_identity_comparison.php:
<?php
enum E: int { case A = 1; case B = 2; }
var_export(E::A < E::B); echo "\n";
var_export(E::A == E::B); echo "\n";
var_export(E::A === E::B); echo "\n";
var_export(E::A <=> E::B); echo "\n";
php bin/vm.php test/repro/maintainer_gap_enum_identity_comparison.php
Zend PHP 8.2:
VM today:
Scope
Done when (php-src-strict)
Category
language· php-src-strictProblem
Comparing two distinct backed enum cases must use enum identity rules:
==/===are false for different cases;<=>compares backing values. VM coerces cases to backing scalars and returns wrong results (E::A == E::Bistrue,<=>is0).Verified 2026-06-16: Zend PHP 8.2 vs
php bin/vm.php.php-src reference
Zend/zend_enum.c—zend_compare_enums,zend_enum_object_handlers.compareZend/zend_operators.c— compare dispatch forIS_ENUMRepro
test/repro/maintainer_gap_enum_identity_comparison.php:Zend PHP 8.2:
VM today:
Scope
==/===, backing compare for</<=/<=>only when cases differDone when (php-src-strict)
===true, different-case===false,<=>by backingswitch (E::A) { case E::B: ... }does not match incorrectly