Skip to content

Language: enum implements interface — interface class constants E::X must resolve (zend_enum.c) #5725

Closed

Description

@PurHur

Category

language

Problem

Enums that implement an interface must inherit interface class constants and resolve E::X like Zend. VM today reports Undefined class constant; Zend returns the interface constant value.

#5719 covers trait use constants only, not implements I.

php-src reference

Repro

<?php
declare(strict_types=1);

interface I {
    public const X = 1;
}

enum E implements I {
    case A;
}

var_export(E::X);
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/parity_enum_interface_const.php
php bin/vm.php test/repro/parity_enum_interface_const.php 2>&1 | grep -v listSpreadRhs
'
Engine Result
Zend 1
VM today Undefined class constant E::X

Scope (this repo)

Area Path
Compiler enum implements — merge interface constants into enum class entry
VM constant lookup E::X on enum with implemented interfaces

PHP-in-PHP — no new runtime/*.c.

Done when

  • Repro prints 1 on VM
  • Compliance .phpt for interface const on unit + backed enums
  • ./script/ci-fast.sh --filter parity_enum_interface_const green

Links

Activity

  1. added
    enhancementNew feature or request
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 4, 2026
  2. PurHur commented on Jun 4, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-c — starting this run

  3. PurHur commented on Jun 4, 2026

    @PurHur
    OwnerAuthor

    Merged via #5746.

    Fix: After enum body materialization, VM calls inheritFromInterfaces(); JIT registers classImplements and calls inheritInterfaceConstants() (same as classes).

    Verification:

    • Repro test/repro/parity_enum_interface_const.php — Zend and VM both print 1 and 'y'
    • vendor/bin/phpunit --filter enum_interface_const — OK (1 test)
  4. added a commit that references this issue on Jun 5, 2026
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