Skip to content

Stdlib: ReflectionMethod::getTentativeReturnType() missing — hasTentativeReturnType only (ext/reflection/php_reflection.c) #18226

Description

@PurHur

Category

stdlib · php-src-strict

Problem

PHP 8.1+ exposes tentative return types on internal/builtin methods. This compiler wires ReflectionMethod::hasTentativeReturnType() but not the paired getter getTentativeReturnType(), so code expecting a ReflectionNamedType (or null) cannot mirror Zend.

Repro Zend 8.2+ VM (2026-07-12)
method_exists(new ReflectionMethod('DateTime','format'), 'getTentativeReturnType') true false
(new ReflectionMethod('DateTime','format'))->getTentativeReturnType()?->getName() 'string' fatal: undefined method

php-src reference

PHP implementation target

  • lib/VM/Builtin/ReflectionMethodGetTentativeReturnType.php — mirror ReflectionMethodGetReturnType.php / existing ReflectionMethodHasTentativeReturnType.php
  • Share type-object construction with lib/VM/ReflectionSupport.php

Repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_reflection_method_get_tentative_return_type.php'
# fail: getTentativeReturnType missing

Done when

  • test/repro/maintainer_gap_reflection_method_get_tentative_return_type.php prints ok name=string on VM/JIT/AOT
  • Compliance .phpt guard under test/compliance/cases/stdlib/reflection_method_get_tentative_return_type.phpt
  • php-src-strict; no php-compiler-strict shortcut

Activity

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

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (issues #18225, #18226, #18228)

  3. PurHur commented on Jul 12, 2026

    @PurHur
    OwnerAuthor

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

  4. PurHur commented on Jul 12, 2026

    @PurHur
    OwnerAuthor

    Merged in #18233 — VM repro + compliance guards green; bootstrap inventory + spine sync + VM driver probe OK.

  5. PurHur commented on Jul 12, 2026

    @PurHur
    OwnerAuthor

    Merged via #18240

    Verification

    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
    php test/repro/maintainer_gap_reflection_method_get_tentative_return_type.php
    php bin/vm.php test/repro/maintainer_gap_reflection_method_get_tentative_return_type.php'
    # method_yes / name=string / has_yes / user_has_no / user_get_null / ok name=string
    
    vendor/bin/phpunit --filter reflection_method_get_tentative_return_type
    # OK (2 tests)

    Implementation: ReflectionMethod::getTentativeReturnType() VM builtin + BuiltinInternalTentativeReturnInfo Zend 8.2 snapshot (187 internal methods); hasTentativeReturnType() now consults the same table via BuiltinInternalArgInfo::tentativeReturnTypeForClassMethod().

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