Skip to content

Stdlib: ReflectionParameter::hasType() true + mixed for untyped params — Zend false (ext/reflection/php_reflection.c) #22064

Closed

Description

@PurHur

Category

Stdlib · php-src-strict · Reflection parameter types

Problem

For untyped parameters, Zend’s ReflectionParameter::hasType() is false (no type object). The VM reports hasType()===true with getType() stringifying as mixed (2026-07-22). Typed / nullable / explicit mixed params already match.

Repro Zend 8.2+ VM (2026-07-22)
function f(int $a, $b, ?string $c, mixed $d){} → $b hasType / type 0 / — 1 / mixed
$a 1 / int 1 / int
$d (explicit mixed) 1 / mixed 1 / mixed
method m(array $x, $y) → $y hasType 0 1

php-src reference

PHP implementation target

  • Parameter reflection stubs: only set a type when the AST/signature has an explicit type; bare $b must leave type absent so hasType() is false
  • Likely lib/VM Reflection parameter builders / ext/standard/VmReflection.php
  • PHP-in-PHP; no new C

Repro

./script/docker-exec.sh -- bash -lc 'cat >/tmp/param_has_type.php <<'"'"'P'"'"'
<?php
function f(int $a, $b, ?string $c = null, mixed $d = null) {}
foreach ((new ReflectionFunction("f"))->getParameters() as $p) {
  echo $p->getName(), " hasType=", $p->hasType()?"1":"0",
    " type=", $p->hasType()?(string)$p->getType():"-", "\n";
}
P
php /tmp/param_has_type.php; php bin/vm.php /tmp/param_has_type.php'

Done when

  • Untyped params: hasType()===false; no synthetic mixed
  • Explicit mixed / nullable / class types unchanged vs Zend
  • Compliance .phpt under reflection/
  • 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 Jul 22, 2026
  2. PurHur commented on Jul 22, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (issues #22127, #22108, #22145, #22064, #22144; sequential PRs)

    Queued: ReflectionParameter::hasType() for untyped params.

  3. PurHur commented on Jul 22, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — starting #22064 after #22145 merged (PR #22156).

    Fixing ReflectionParameter::hasType() for untyped params (php-src-strict).

  4. PurHur commented on Jul 22, 2026

    @PurHur
    OwnerAuthor

    merged: #22157

    Verification: untyped hasType=0; explicit mixed/nullable/int unchanged. phpunit OK.

    Batch remaining (optional next run): #22144 ReflectionFunction location/namespace API

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