Skip to content

Stdlib: usort()/uasort()/uksort() — named array:/callback: rejected (ext/standard/array.c) #10048

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

Zend accepts PHP 8+ named arguments on user-sort builtins: usort(array: $a, callback: ...), uasort(...), uksort(...).

This compiler rejects callback: / array: with Error: Unknown named parameter at runtime. Enum key preservation in sort callbacks is tracked separately in #8867 / #9075.

php-src reference

Repro (failure today)

<?php
$a = [3, 1, 2];
usort(array: $a, callback: fn ($x, $y) => $x <=> $y);
var_export($a);

$b = ['b' => 2, 'a' => 1];
uasort(array: $b, callback: fn ($x, $y) => $x <=> $y);
var_export($b);

Also: test/repro/named_uasort.php, test/repro/maintainer_probe_named_params.php (usort probe)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/named_uasort.php'
# Fatal: Unknown named parameter $callback
Call Zend PHP 8+ VM today
usort(array: $a, callback: $fn) sorted array Unknown named parameter ❌
usort($a, $fn) positional sorted array OK ✅

Scope (this repo)

Path Work
ext/standard/usort.php, uasort.php, uksort.php Builtin arginfo / named aliases
lib/Compiler.php named-arg binding Wire array (by-ref) + callback slots
Tests compliance PHPTs for named array/callback on each sort builtin

PHP-in-PHP first — no new runtime/*.c.

Done when

  • Repro green under VM (php-src-strict)
  • By-ref array: binding preserves Zend write-back semantics

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/named_uasort.php'

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

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-b — batch (issues #9646, #10048) — compiler BuiltinParamNames named-arg registration; not ext/standard runtime scope despite stdlib label

  3. PurHur commented on Jun 24, 2026

    @PurHur
    OwnerAuthor

    Merged via #11090

    Fix: BuiltinParamNames maps usort/uasort/uksort to array + callback (not flags).

    Verification: test/repro/named_uasort.php + usort_named_callback.phpt green in Docker.

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 appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions