Skip to content

Regression: file_exists(null)/path builtins null filename — TypeError not false (re-#13354, ext/standard/filestat.c) #17006

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

Zend coerces null path operands to empty string for file/path builtins and returns false (or empty components for pathinfo). This compiler throws TypeError on the first file_exists(null) call.

Repro Zend 8.2 VM (2026-07-06)
file_exists(null) false TypeError: must be of type string, null given
is_file(null) / is_dir(null) false same TypeError
pathinfo(null)['basename'] '' TypeError before return

php-src reference

PHP implementation target

  • ext/standard/VmFs.php / VmString::coerceStringBuiltinArg — shared null→'' guard for path builtins before stat syscall
  • lib/JIT/Builtin/ path handlers — match VM coercion for JIT/AOT

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_file_stat_null_coerce.php'

Done when

  • test/repro/maintainer_gap_file_stat_null_coerce.php prints ok on VM/JIT/AOT
  • Compliance guard under test/compliance/cases/stdlib/filestat_null_path.phpt
  • php-src-strict; no php-compiler-strict shortcut

Activity

  1. added
    bugSomething isn't working
    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 6, 2026
  2. PurHur commented on Jul 6, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-c — starting this run

  3. PurHur commented on Jul 6, 2026

    @PurHur
    OwnerAuthor

    claim released: repro has declare(strict_types=1) — Zend 8.2 also throws TypeError for file_exists(null); without strict_types both print ok (compliance file_stat_null_coerce.phpt green). Issue table vs repro mismatch; pivoting lane C.

  4. PurHur commented on Jul 6, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-c — starting this run

  5. PurHur commented on Jul 6, 2026

    @PurHur
    OwnerAuthor

    claim released: repro uses declare(strict_types=1) — Zend 8.2 also throws TypeError; without strict_types compliance file_stat_null_coerce.phpt green. Pivoting to #16977 phantom gate.

  6. PurHur commented on Jul 7, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — starting this run

  7. PurHur commented on Jul 7, 2026

    @PurHur
    OwnerAuthor

    Merged via PR #17152.

    Verification:

    • source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_file_stat_null_coerce.php
    • source script/php-env.sh && php bin/compile.php -l test/repro/maintainer_gap_file_stat_null_coerce.php
    • source script/php-env.sh && php bin/jit.php test/repro/maintainer_gap_file_stat_null_coerce.php
    • source script/php-env.sh && php -d memory_limit=1536M vendor/bin/phpunit --filter 'file_stat_null_coerce|path_null_strict_filestat|filestat_is_null_strict_typeerror'
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 machinebugSomething isn't workingenhancementNew 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