Skip to content

Language: UnitEnum::cases() static call — regression vs closed #5462 (zend_enum.c) #5507

Description

@PurHur

Category

language | stdlib

Problem

Regression vs closed #5462 / #3308: Backed enum E::cases() must be callable statically like Zend (zend_enum.c). VM throws Error: Non-static method E::cases() cannot be called statically, breaking array spread and any direct E::cases() use.

php-src reference

Repro

<?php
enum E: int { case A = 1; case B = 2; }
var_export(E::cases());
echo "\n";
var_export([...E::cases()]);
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php repro.php
php bin/vm.php repro.php
'
Runtime Output
Zend array( E::A, E::B ) then spread of cases
VM today fatal: Non-static method E::cases() cannot be called statically

Scope (this repo)

Layer Path
VM dispatch lib/VM.php — enum/static method resolution for cases() / from() / tryFrom()
Compiler lib/Compiler.php — enum builtin method table if compile-time
Tests test/compliance/cases/language/enum_cases_static.phpt, spread smoke

Done when

  • Repro matches Zend on VM (static cases() + spread)
  • ./script/ci-fast.sh --filter enum_cases green

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && ./script/ci-fast.sh --filter enum_cases'

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions