Skip to content

Stdlib: ReflectionMethod getNamespaceName()/getShortName()/inNamespace() missing (ext/reflection/php_reflection.c) #22167

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

ReflectionMethod on Zend inherits ReflectionFunctionAbstract namespace helpers. php-compiler already has file/line/docblock on methods, but omits getNamespaceName / getShortName / inNamespace (method_exists false). Sibling #22144 covers the same helpers on ReflectionFunction.

Method Zend 8.2+ (method of DemoNs\C::m) VM (2026-07-22)
getShortName() 'm' missing
getNamespaceName() '' (method itself is not namespaced; class ns via getDeclaringClass()) missing
inNamespace() false missing

php-src reference

PHP implementation target

  • Register the three methods on ReflectionMethod in lib/VM/BuiltinClasses.php / ext/standard/VmReflection.php
  • Match Zend: short name = method name; namespace name empty string; inNamespace() false for class methods
  • Reuse any existing ReflectionClass / ReflectionFunction helpers; PHP-in-PHP only

Repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_reflection_method_namespace_helpers.php'
namespace DemoNs;
class C { public function m() {} }
$rm = new \ReflectionMethod(C::class, 'm');
var_export(method_exists($rm, 'getShortName')); // Zend: true
echo $rm->getShortName(); // m

Done when

  • All three methods exist on ReflectionMethod and match Zend values above
  • Does not regress ReflectionClass / ReflectionFunction helpers
  • 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 #22167 (after merged #22166 / PR #22235)

    Next after this: #22169 → #22173.

  4. PurHur commented on Jul 22, 2026

    @PurHur
    OwnerAuthor

    Merged #22236

    ReflectionMethod::{getShortName,getNamespaceName,inNamespace} match Zend (m / '' / false).

    Next: #22169.

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