Skip to content

Regression: file_get_contents(..., null) $use_include_path under strict_types DEP+read — Zend TypeError (ext/standard/file.c) #31338

Description

@PurHur

Category

stdlib · php-src-strict

Problem

Under declare(strict_types=1), file_get_contents($filename, null) must TypeError because $use_include_path is typed bool. VM soft-nulls via VmMath::parseBoolBuiltinArg (non-ForFrame), emits E_DEPRECATED, and still reads the file.

Repro Zend 8.2.32 (2026-08-15) VM (2026-08-15)
file_get_contents(__FILE__, null) TypeError: … Argument #2 ($use_include_path) must be of type bool, null given Deprecated + successful read

php-src reference

PHP implementation target

  • ext/standard/file_get_contents.php — switch parseBoolBuiltinArgparseBoolBuiltinArgForFrame for arg Php stdlib specs implementation #2 so caller strict_types TypeErrors on null (same pattern as microtime/hrtime peers)
  • JIT JitFileGetContents / bool arg lowering — same guard
  • No new C runtime logic

Repro

./script/docker-exec.sh -- bash -lc 'php -r '\''declare(strict_types=1); try { file_get_contents(__FILE__, null); } catch (Throwable $e) { echo get_class($e), ": ", $e->getMessage(), "\n"; }'\'''
./script/docker-exec.sh -- bash -lc 'php bin/vm.php -r '\''declare(strict_types=1); try { $r = file_get_contents(__FILE__, null); echo "OK len=", strlen((string)$r), "\n"; } catch (Throwable $e) { echo get_class($e), ": ", $e->getMessage(), "\n"; }'\'''

Done when

  • VM/JIT/AOT: null $use_include_path under strict_types → Zend TypeError; omit-arg still false; non-strict may soft-null DEP like Zend
  • Compliance .phpt under test/compliance/cases/stdlib/
  • php-src-strict; no php-compiler-strict shortcut

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:compilerCompiler / CFG / JITarea:vmVirtual machinebugSomething isn't workingimplementation-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