Skip to content

Bootstrap: scandir() VM — native directory listing without host PHP #5048

Closed

Description

@PurHur

Category

bootstrap · stdlib

Problem

scandir() VM execute calls host PHP \scandir() (ext/standard/scandir.php). JIT defers to VM. Bootstrap inventory includes scandir.php on the bin/vm.php path, so a self-hosted compiler cannot list directories without Zend in the loop (#1492).

#3235 covers opendir/readdir/closedir; this issue wires scandir() to that native iterator (or libc scandir(3) where available).

php-src reference

Repro

<?php
var_export(scandir(__DIR__));
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/scandir_smoke.php 2>/dev/null || php -r "var_export(scandir(\".\"));"
php bin/vm.php -r "var_export(scandir(\".\"));"
'

Zend: string[] listing
VM without host PHP: LogicException or wrong delegation

Scope (this repo)

Area Path
VM ext/standard/scandir.php, ext/standard/VmDir.php (or new helper)
JIT Lower to VM native path or LLVM call once VM is correct
Tests test/compliance/cases/stdlib/scandir.phpt

Done when

  • VM scandir() uses opendir/readdir stack (or scandir(3)) — no \scandir().
  • Sorting flags (SCANDIR_SORT_*) match Zend for ASC/DESC/NONE.
  • php script/bootstrap-inventory.php --check still lists scandir.php as compilable.

Links

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

    @PurHur
    OwnerAuthor

    Merged via #5778. VM scandir() uses VmDir opendir/readdir stack; VmFsGlobTest + VMTest glob_scandir 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-0:FoundationPhase 0 – foundation & DevExphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions