Skip to content

Stdlib: get_declared_enums() — list compiled enum classes (ext/standard/basic_functions.c parity) #3538

Closed

Description

@PurHur

Category

stdlib

Problem

get_declared_enums() (PHP 8.1+) is missing. Autoloaders, reflection-style tooling, and enum discovery cannot match Zend behavior.

php-src reference

  • ext/standard/basic_functions.c — PHP_FUNCTION(get_declared_enums)
  • Zend/zend_enum.c — registered enum class entries

Repro (today)

<?php
enum Color: string { case Red = 'r'; case Blue = 'b'; }
enum Size: int { case S = 1; }
var_dump(get_declared_enums());
var_dump(in_array('Color', get_declared_enums(), true));
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'
php repro.php

Zend: non-empty array of enum class name strings including Color and Size.
This compiler: fatal undefined function.

Scope (this repo)

Path Notes
ext/standard/get_declared_enums.php Walk enum registry populated at TYPE_DECLARE_ENUM
ext/standard/Module.php Register
lib/VM.php / enum registry Expose declared enum names (see enum_exists)
test/compliance/cases/stdlib/get_declared_enums.phpt

Related: enum_exists() (present), BackedEnum::from (#3114), UnitEnum::cases() (#3308).

Done when

  • Repro lists user-defined enums declared in the compilation unit / runtime registry
  • Return value is a list of strings (class names), same keys/order semantics as Zend for a single script
  • ./script/ci-fast.sh --filter get_declared_enums green

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter get_declared_enums'

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on May 30, 2026
  2. PurHur commented on May 30, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — starting this run

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-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions