Skip to content

Stdlib: array_uasort()/array_uksort() — user comparator sort builtins missing (ext/standard/array.c) #5649

Description

@PurHur

Category

stdlib

Problem

Zend provides array_uasort() and array_uksort() — sort array values or keys in-place using a user callable, preserving the opposite dimension (keys vs values). This compiler registers uasort() / uksort() but not the array_* variants; function_exists() is false for both under bin/vm.php.

Distinct from #5644 (assoc diff/intersect + array_udiff family) and from uasort/uksort (already present).

php-src reference

Repro (failure today)

<?php
$a = ['b' => 2, 'a' => 1];
array_uasort($a, fn($x, $y) => $x <=> $y);
var_export($a);

$k = ['b' => 1, 'a' => 2];
array_uksort($k, fn($x, $y) => strcmp((string)$x, (string)$y));
var_export($k);
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php -r "var_dump(function_exists(\"array_uasort\"), function_exists(\"array_uksort\"));"
php bin/vm.php repro.php
'
Runtime Result
Zend PHP 8.x Sorted assoc arrays (values / keys)
vm.php today Call to undefined function array_uasort()

Verified 2026-06-04: function_exists → false / false; uasort/uksort → true.

Scope (this repo)

Area Path
VM builtins ext/standard/array_uasort.php, array_uksort.php (or shared helper with uasort_.php / uksort_.php)
Registration ext/standard/Module.php
Callbacks VM closure + string builtin names (#3086); enum case operands must pass through (#5637)
JIT/AOT phase-2 after VM green (lib/JIT/Builtin/, docs/capabilities.md)

PHP-in-PHP: implement sorting in ext/standard + VM hashtable helpers — do not add new runtime/*.c compare tables.

Done when

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