Skip to content

Regression: dirname()/basename()/pathinfo()/file_exists()/is_* — enum path operands coerce (re-#5944, ext/standard) #8948

Description

@PurHur

Category

stdlib · php-src-strict · regression

Problem

Path and stat builtins with string-typed path operands must throw TypeError when passed an enum case. Issue #5944 was closed with compliance coverage, but VM still accepts enum operands silently by coercing the backing string.

Verified 2026-06-16: Zend PHP 8.2 vs php bin/vm.php.

php-src reference

Repro

test/repro/maintainer_gap_path_stat_enum.php

php test/repro/maintainer_gap_path_stat_enum.php
php bin/vm.php test/repro/maintainer_gap_path_stat_enum.php
Function Zend VM (wrong)
dirname(Ep::A) TypeError returns '/tmp' (coerced)
basename(Ep::A) TypeError returns 'x'
file_exists(Ep::A) TypeError returns false
is_readable(Ep::A) TypeError returns false

Existing compliance (expectations not met on VM): test/compliance/cases/stdlib/pathinfo_enum_type_error.phpt

Scope (PHP-in-PHP)

Path Work
ext/standard/dirname.php, basename.php, pathinfo.php, realpath.php VmString::coerceStringBuiltinArg / TypeError before coercion
ext/standard/file_exists.php, is_file.php, is_dir.php, is_readable.php Same path-operand guard
lib/JIT/Builtin/Standard/* JIT parity
Tests Re-enable/extend pathinfo_enum_type_error.phpt; add maintainer repro to CI filter

Done when

  • All listed functions throw same TypeError as Zend for backed enum operands
  • test/compliance/cases/stdlib/pathinfo_enum_type_error.phpt green on VM
  • No silent backing-string coercion

Related

#5944 (closed, regressed) · #8781 glob enum · #1492

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