Category
bug · php-src-strict · language / enums
Problem
Zend treats enum cases as objects with public properties name (unit + backed) and value (backed only). foreach ($case as $k => $v) yields those properties. The VM yields nothing.
| Repro |
Zend 8.2 (2026-07-26) |
VM (2026-07-26) |
unit foreach (E::A as ...) |
name='A' |
(empty) |
backed foreach (S::A as ...) |
name='A',value='x' |
(empty) |
php-src reference
PHP implementation target
- Enum case property table / foreach path in
lib/VM/ (enum support) — expose name and (for backed) value as public iterable props
- Keep
get_object_vars($case) / property read parity with foreach
- No new C
Repro
./script/docker-exec.sh -- bash -lc 'cat >/tmp/repro_enum_foreach.php <<'"'"'PHP'"'"'
<?php
enum E { case A; }
$ks = [];
foreach (E::A as $k => $v) { $ks[] = "$k=" . var_export($v, true); }
echo implode(",", $ks), "\n";
enum S: string { case A = "x"; }
$ks = [];
foreach (S::A as $k => $v) { $ks[] = "$k=" . var_export($v, true); }
echo implode(",", $ks), "\n";
PHP
php /tmp/repro_enum_foreach.php
php bin/vm.php /tmp/repro_enum_foreach.php'
Done when
Category
bug· php-src-strict · language / enumsProblem
Zend treats enum cases as objects with public properties
name(unit + backed) andvalue(backed only).foreach ($case as $k => $v)yields those properties. The VM yields nothing.foreach (E::A as ...)name='A'foreach (S::A as ...)name='A',value='x'php-src reference
Zend/zend_enum.c— enum case object propertiesname/valueZend/zend_object_handlers.c— property iteration for internal objectsPHP implementation target
lib/VM/(enum support) — exposenameand (for backed)valueas public iterable propsget_object_vars($case)/ property read parity with foreachRepro
Done when
.phptundertest/compliance/cases/language/