Skip to content

Stdlib: array_udiff()/array_uintersect() callbacks must receive enum case objects (ext/standard/array.c) #5637

Description

@PurHur

Category

stdlib

Problem

The array_udiff() / array_uintersect() / array_diff_uassoc() family is missing on the VM (#3129, #4285). When implemented, user compare callbacks must receive enum case objects, not backed scalars. Zend passes objects; coercing to 1/2 breaks identity comparisons and instanceof predicates.

php-src reference

Repro (failure today: undefined function; spec for implementers)

<?php
enum E: int { case A = 1; case B = 2; }
$a = [E::A, E::B];
$b = [E::B];
var_export(array_udiff($a, $b, fn($x, $y) => ($x <=> $y)));
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php repro.php
./phpc run repro.php
'
Runtime Today After implementation
Zend array (0 => E::A) compare fn receives E::A, E::B objects
VM Call to undefined function array_udiff() must match Zend

Scope (this repo)

Area Path
Stdlib ext/standard/array_udiff.php (and uintersect/uassoc siblings)
VM callback invocation — preserve enum tags in lib/VM.php
Blocked on #3129, #4285 registration

Done when

  • array_udiff repro returns one-element array with E::A object
  • Callback test asserts get_debug_type($x) === 'E' inside comparator
  • ./script/ci-fast.sh --filter array_udiff_enum green

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