Skip to content

Stdlib: array_combine() with enum case keys — Error not backed int keys (ext/standard/array.c) #5538

Closed

Description

@PurHur

Category

stdlib

Problem

array_combine([E::A, E::B], [...]) must throw Error: Object of class E could not be converted to string when keys are enum cases (Zend). VM coerces backed enum cases to integers and builds array(1 => 10, 2 => 20).

php-src reference

Repro

test/repro-maintainer/parity_array_combine_enum_keys.php

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/parity_array_combine_enum_keys.php
php bin/vm.php test/repro-maintainer/parity_array_combine_enum_keys.php'
Runtime Result
Zend Uncaught Error (enum not stringifiable)
VM today array(1 => 10, 2 => 20)

Scope (this repo)

Layer Path
VM ext/standard/array_combine.php (or shared array builtin helper)
Tests test/compliance/cases/stdlib/array_combine_enum_keys.phpt

Done when

  • Repro throws same Error on VM as Zend
  • Normal array_combine(['a','b'], [1,2]) unchanged
  • ./script/ci-fast.sh --filter array_combine_enum green

Related

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 Jun 4, 2026
  2. PurHur commented on Jun 11, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — starting this run

  3. PurHur commented on Jun 11, 2026

    @PurHur
    OwnerAuthor

    Merged via #8018.

    Verification

    • VM repro: php bin/vm.php test/repro-maintainer/parity_array_combine_enum_keys.php → Error: Object of class E could not be converted to string
    • vendor/bin/phpunit --filter array_combine_enum → OK (3 tests)
    • vendor/bin/phpunit --filter array_combine → OK (17 tests)

    VM + JIT + AOT fixtures green; enum case keys no longer coerce to backing ints.

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