Category
language
Problem
Zend emits E_WARNING and yields 1 (legacy object-to-int) when casting a backed enum case with (int) / (float) — not the backing value. #5714 was closed, but VM still prints 42 for (int) E::A with case A = 42.
php-src reference
Repro
test/repro/parity_enum_int_cast.php:
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php8.2 test/repro/parity_enum_int_cast.php 2>&1 | tail -2
php bin/vm.php test/repro/parity_enum_int_cast.php 2>&1 | tail -2'
| Runtime |
stdout (after warning) |
| Zend |
1 |
| VM |
42 |
Scope
Done when
Related
Category
languageProblem
Zend emits E_WARNING and yields
1(legacy object-to-int) when casting a backed enum case with(int)/(float)— not the backing value. #5714 was closed, but VM still prints42for(int) E::Awithcase A = 42.php-src reference
Zend/zend_operators.c—zend_cast_to_longon enum objectsZend/zend_enum.cRepro
test/repro/parity_enum_int_cast.php:142Scope
lib/VM/EnumCaseSupport.php—scalarCastEnumCase/ int&float cast paths (Language: (int)/(float) cast on backed enum case uses backing value — Zend warns and yields 1 (zend_operators.c) #5714)lib/JIT/+lib/VM/CastSupport.phpif casts compile to backing readtest/compliance/cases/language/int_cast_backed_enum.phptDone when
1for(int) E::A(not backing42)(float)same legacy1.0behavior./script/ci-fast.sh --filter int_cast_backed_enumgreenRelated
test/repro/parity_enum_int_cast.php