Skip to content

Stdlib: get_object_vars() on backed enum case — name/value array not TypeError (ext/standard/var.c) #8804

Description

@PurHur

Category

stdlib

Problem

Zend get_object_vars() on a backed enum case returns the pseudo-properties name and value (strings/scalars). This compiler rejects the call with TypeError because enum cases are still materialized as backing scalars in many paths (#8746).

Framework debug/dump code expects enum cases to behave like objects for introspection.

php-src reference

Repro (failure today)

<?php
enum E: string { case A = 'x'; }
var_export(get_object_vars(E::A));
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php repro.php
php bin/vm.php repro.php 2>&1 | head -4
'
Runtime Output
Zend array ('name' => 'A', 'value' => 'x')
VM TypeError: get_object_vars(): Argument #1 ($object) must be of type object, string given

Scope (this repo)

Area Path
VM ext/standard/get_object_vars.php + enum object path in VmReflection / EnumCaseSupport
Depends Enum case must be TYPE_OBJECT or accepted enum wrapper (#8746)
Tests test/compliance/cases/stdlib/get_object_vars_enum_case.phpt
Matrix script/capability-matrix.php note if VM-only initially

Done when (php-src-strict)

  • Repro var_export matches Zend for backed enums
  • Unit enums: empty array or documented parity per php-src version in Docker image
  • ./script/ci-fast.sh --filter GetObjectVarsEnum green
  • No LogicException for user-facing TypeError mistakes

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions