Skip to content

ReflectionMethod::getPrototype() does not resolve transitively to the originating interface #233

Description

@lisachenko

Pre-existing parity gap surfaced while building the PHP 8.6 test scaffolding (see PR #226's "Finding for a follow-up" section; deliberately not fixed there to keep that PR scoped).

getPrototype() (src/ReflectionMethod.php:281) searches the parent class first and does not resolve transitively, so for:

interface I { public function describe(): string; }
abstract class A implements I { abstract public function describe(): string; }
final class C extends A { public function describe(): string { return ''; } }

(new ReflectionMethod(C::class, 'describe'))->getPrototype() returns the method declared in A, while native reflection returns the one from I (native walks up to the original prototype, preferring the interface that introduced the signature).

Expected: match native getPrototype() resolution, including interface-through-abstract chains.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions