Skip to content

Stdlib: ReflectionFunction hasTentativeReturnType()/getTentativeReturnType() missing (ext/reflection/php_reflection.c) #22169

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

ReflectionMethod already implements hasTentativeReturnType() / getTentativeReturnType() (#18226 / #6597). The same ReflectionFunctionAbstract API is missing on ReflectionFunction (method_exists false), including for internal builtins like strlen (Zend: hasTentativeReturnType() === false, getTentativeReturnType() === null).

Method Zend 8.2+ (ReflectionFunction('strlen')) VM (2026-07-22)
hasTentativeReturnType exists; false missing
getTentativeReturnType exists; null missing
Same on ReflectionMethod exists exists (OK)

php-src reference

PHP implementation target

  • Register both methods on ReflectionFunction in lib/VM/BuiltinClasses.php — reuse ReflectionMethodHasTentativeReturnType / getter logic for function entries
  • Internal builtins without tentative types → false / null
  • PHP-in-PHP only

Repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_reflection_function_tentative_return.php'
$rf = new ReflectionFunction('strlen');
var_export(method_exists($rf, 'hasTentativeReturnType')); // Zend: true
var_export($rf->hasTentativeReturnType()); // false
var_export($rf->getTentativeReturnType()); // null

Done when

  • Both methods exist on ReflectionFunction and match Zend for internal + user functions
  • No regression on ReflectionMethod tentative API
  • Compliance .phpt guard
  • php-src-strict

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

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (issues #22144, #22170, #22171, #22166, #22167, #22169, #22173; sequential PRs)

    Queued after #22144.

  3. PurHur commented on Jul 22, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — starting #22169 (after merged #22167 / PR #22236)

    Next after this: #22173.

  4. PurHur commented on Jul 22, 2026

    @PurHur
    OwnerAuthor

    Merged #22237

    ReflectionFunction::{has,get}TentativeReturnType exist; internals/user funcs → false/null; DateTime::format method tentative path unchanged.

    Next: #22173.

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