Skip to content

Stdlib: dirname()/basename()/realpath()/pathinfo() — enum path operands must TypeError (ext/standard) #5944

Description

@PurHur

Category

stdlib (php-src-strict)

Problem

Path builtins accept backed enum case path operands on VM (dirname, basename, realpath succeed; pathinfo throws generic build Error) while Zend throws TypeError on all four.

Distinct from filesystem stat/stream path guards (#5735 covers file_get_contents/fopen/… but not the pathinfo family).

php-src reference

Repro (verified 2026-06-04)

<?php
enum Ep: string { case P = '/tmp/foo/bar.php'; }
foreach (['dirname', 'basename', 'realpath', 'pathinfo'] as $fn) {
    try {
        $fn(Ep::P);
        echo "{$fn} ok\n";
    } catch (Throwable $e) {
        echo $fn, ' ', $e::class, ': ', $e->getMessage(), "\n";
    }
}
docker info >/dev/null
./script/docker-exec.sh -- bash -lc 'php repro.php'
./script/docker-exec.sh -- bash -lc 'php bin/vm.php repro.php'
Function Zend PHP 8.2 VM (today)
dirname TypeError succeeds ❌
basename TypeError succeeds ❌
realpath TypeError succeeds ❌
pathinfo TypeError generic Error message ❌

Scope (PHP-in-PHP)

Layer Path
VM ext/standard/dirname.php, basename.php, realpath.php, pathinfo.php — path arg validator rejecting TYPE_ENUM_CASE
JIT matching Jit* lowerers
Tests test/compliance/cases/stdlib/pathinfo_enum_type_error.phpt

Acceptance

  • All four throw TypeError matching Zend on enum path operands
  • No silent path coercion via backing string
  • ./script/ci-fast.sh --filter pathinfo_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