Skip to content

Language: enum case === / == with backing scalar must be false (#5798) - #5802

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-5798-enum-compare-backing-scalar
Jun 4, 2026
Merged

Language: enum case === / == with backing scalar must be false (#5798)#5802
PurHur merged 1 commit into
masterfrom
agent/issue-5798-enum-compare-backing-scalar

Conversation

@PurHur

@PurHur PurHur commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Reject === / == when exactly one operand is an enum case (Variable::identicalTo / equals), matching Zend zend_operators.c — avoids any looseEqual numeric coercion path.
  • Add maintainer repro test/repro-maintainer/parity_enum_strict_identity.php and compliance PHPT enum_compare_backing_scalar.phpt.

php-src reference: Zend/zend_operators.c (compare_function enum case vs scalar).

Verification

./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
vendor/bin/phpunit test/compliance/EnumVMTest.php --filter enum_compare_backing_scalar
'
false (x6 lines — int + string backed enums, === and ==, both directions)
PHPUnit OK (1 test)

Closes #5798

Made with Cursor

Reject === and == between enum cases and non-case operands in Variable
compare helpers so looseEqual cannot coerce backing values. Add maintainer
repro and EnumVMTest PHPT guarding Zend behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Language: backed enum case === / == with backing scalar must be false (zend_operators.c)

1 participant