Skip to content

Regression: tmpfile/fopen Reflection return resource — Zend untyped (ext/standard/basic_functions.stub.php) #28520

Description

@PurHur

Category

bug · php-src-strict · Reflection return type · ext/standard

Problem

ReflectionFunction('tmpfile') / ReflectionFunction('fopen') advertise return type resource on php-compiler. Zend/php-src stubs leave both untyped (hasReturnType() === false). Probed 2026-08-07 @ cee406e863.

Repro Zend 8.2 (2026-08-07) VM (2026-08-07)
(new ReflectionFunction('tmpfile'))->hasReturnType() false true (resource)
(new ReflectionFunction('fopen'))->hasReturnType() false true (resource)

php-src reference

PHP implementation target

  • Reflection / arginfo for tmpfile and fopen in ext/standard — drop invented resource return type to match stubs

Repro

./script/docker-exec.sh -- bash -lc "php -r \"\$r=new ReflectionFunction('tmpfile'); var_export([\$r->hasReturnType(), \$r->hasReturnType()?(string)\$r->getReturnType():null]);\""
./script/docker-exec.sh -- bash -lc "php bin/vm.php -r \"\$r=new ReflectionFunction('tmpfile'); var_export([\$r->hasReturnType(), \$r->hasReturnType()?(string)\$r->getReturnType():null]);\""
./script/docker-exec.sh -- bash -lc "php -r \"\$r=new ReflectionFunction('fopen'); var_export([\$r->hasReturnType(), \$r->hasReturnType()?(string)\$r->getReturnType():null]);\""
./script/docker-exec.sh -- bash -lc "php bin/vm.php -r \"\$r=new ReflectionFunction('fopen'); var_export([\$r->hasReturnType(), \$r->hasReturnType()?(string)\$r->getReturnType():null]);\""

Done when

  • VM Reflection: tmpfile / fopen have no return type (match Zend)
  • Compliance / unit guard
  • php-src-strict; no php-compiler-strict shortcut

Activity

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

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (issues #28842, #28919, #28483, #28520, #28557)

  3. PurHur commented on Aug 11, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (issues #28483, #28520, #28557) — queued after #28483

  4. PurHur commented on Aug 11, 2026

    @PurHur
    OwnerAuthor

    Merged via https://github.com/PurHur/php-compiler/pull/

    Verification:

    • php bin/vm.php test/repro/issue_28520_tmpfile_fopen_reflection.php → tmpfile untyped / fopen untyped
    • PHPUnit testTmpfileFopen* + TmpfileFopenReflectionVMTest OK (3 tests)

    Next in batch: #28557 (file Reflection → array|false).

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 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