Skip to content

Regression: file/path builtins null filename — TypeError not empty-string coerce (re-#13354, ext/standard/filestat.c) #15067

Closed

Description

@PurHur

Category

stdlib · php-src-strict · regression (closed #13354, repro red again)

Problem

Without declare(strict_types=1), Zend coerces null path/filename operands to "" and continues. VM rejects with TypeError on the first call.

Call Zend 8.2 (weak) VM (today)
file_exists(null) false TypeError ❌
is_file(null) / is_dir(null) false TypeError ❌
filesize(null) false + Warning TypeError ❌
rename(null, $to) false + Warning TypeError ❌
pathinfo(null) ['basename'=>'','filename'=>''] TypeError ❌
basename(null) / dirname(null) '' TypeError ❌

Use shared internal-arg coercion (VmString::coerceStringBuiltinArg / JitStringBuiltinArg) — same family as touch(null) regressions (#13343).

php-src reference

PHP implementation target

  • ext/standard/file_exists.php, is_file.php, is_dir.php, filesize.php, rename.php, pathinfo.php, basename.php, dirname.php
  • Reuse existing null→"" guards used by other file builtins

Repro (verified 2026-07-02)

./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_file_stat_null_coerce.php
# TypeError: file_exists(): Argument #1 ($filename) must be of type string, null given

./script/docker-exec.sh -- php test/repro/maintainer_gap_file_stat_null_coerce.php
# ok

Compliance guard: test/compliance/cases/stdlib/file_stat_null_coerce.phpt

Done when

  • All builtins in repro coerce null → "" and match Zend warnings/output
  • file_stat_null_coerce.phpt green on VM (+ JIT guard if applicable)
  • No new C in runtime/ — PHP builtins + shared coercion helpers only

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 Jul 2, 2026
  2. PurHur commented on Jul 2, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issues #15069, #15067)

  3. PurHur commented on Jul 2, 2026

    @PurHur
    OwnerAuthor

    Merged via #15077. VM+JIT compliance file_stat_null_coerce green; repro maintainer_gap_file_stat_null_coerce.php returns ok; AOT lint OK.

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