Skip to content

Regression: getimagesize()/md5_file()/sha1_file() null under strict_types — ValueError not TypeError (ext/standard/image.c, ext/standard/md5.c) #17060

Closed

Description

@PurHur

Category

stdlib · strict null filename · php-src-strict

Problem

Under declare(strict_types=1), Zend rejects null path/filename operands with TypeError. This compiler raises ValueError with message Path cannot be empty (via shared path-string guards) instead of the Zend TypeError wording.

Repro Zend 8.2 VM (2026-07-07)
declare(strict_types=1); getimagesize(null); TypeError ValueError: Path cannot be empty
declare(strict_types=1); md5_file(null); TypeError ValueError: Path cannot be empty
declare(strict_types=1); sha1_file(null); TypeError ValueError: Path cannot be empty

php-src reference

PHP implementation target

  • ext/standard/getimagesize.php, ext/standard/md5.php / hash-file helpers — use VmString::coerceStringBuiltinArg / shared path-arg guard that throws TypeError on null under strict, not ValueError for empty path
  • lib/JIT/Builtin/ counterparts if JIT lowers these builtins directly

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_getimagesize_null_strict.php'
# VM: fail ValueError — Zend: TypeError

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

Done when

  • All three builtins throw TypeError (message matches Zend class) under declare(strict_types=1) with null operand
  • Non-strict null behavior unchanged (still ValueError / empty-path handling per php-src)
  • Compliance .phpt guards under test/compliance/cases/stdlib/
  • 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 7, 2026
  2. PurHur commented on Jul 7, 2026

    @PurHur
    OwnerAuthor

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

  3. PurHur commented on Jul 7, 2026

    @PurHur
    OwnerAuthor

    Merged via #17070

    Verification:

    • php bin/vm.php test/repro/maintainer_gap_getimagesize_null_strict.php — TypeError (not ValueError)
    • php bin/vm.php test/repro/maintainer_gap_md5_file_null_strict.php — TypeError for md5_file + sha1_file
    • ./vendor/bin/phpunit --filter path_null_strict_typeerror test/compliance/VMTest.php test/compliance/JITTest.php — OK (2 tests)
    • Non-strict null still ValueError (hash_file_empty_path compliance green)

    Implementation: VmStreamPath::coerceNonEmptyPathArgForFrame, JitStreamPath::lowerPath in non-empty guard, VmFilestatArg::coerceFilenameArg with frame for md5/sha1.

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