Skip to content

Stdlib: glob() enum pattern operand — TypeError not silent empty array (ext/standard/dir.c) #5732

Description

@PurHur

Category

stdlib

Problem

glob() accepts an enum case as the pattern argument on VM and returns array() (no match) instead of TypeError like Zend. Operand validation must reject TYPE_ENUM_CASE / enum objects before calling VmFsGlob::glob().

php-src reference

Repro (verified 2026-06-04)

<?php
enum E { case A; }
try {
    var_export(glob(E::A));
    echo "\n";
} catch (Throwable $e) {
    echo $e::class, ': ', $e->getMessage(), "\n";
}
docker info >/dev/null
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php repro.php
php bin/vm.php repro.php
'
Runtime Result
Zend PHP 8.2 TypeError: glob(): Argument #1 ($pattern) must be of type string, E given
bin/vm.php array ()

Scope (PHP-in-PHP)

Layer Path
VM ext/standard/glob_.php — use shared zend_string_param / enum guard (see #5673 chr pattern)
Core lib/VM/BuiltinArgCheck.php or EnumCaseSupport::rejectObjectOperand()
JIT/AOT ext/standard/JitFsGlob.php — same TypeError before native __phpc_glob_vec
C shrink After VM parity, complete #5459 (delete phpc_fs_dir.c glob path)

Done when

  • Repro throws TypeError on VM (message matches Zend shape)
  • No silent coercion of enum case name to pattern string
  • ./script/ci-fast.sh --filter glob_enum_pattern 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