Skip to content

An interface's methods cannot be reflected: hasMethod() is false and getMethod() throws #196

Closed

Description

@blacktrs

Summary

An interface's methods cannot be reflected: hasMethod() is false and getMethod() throws.

Repro

<?php
interface Speaks { public function speak(): string; }
class Dog implements Speaks { public function speak(): string { return 'woof'; } }
$r = new ReflectionClass('Speaks');
var_dump($r->hasMethod('speak'));
echo $r->getMethod('speak')->class, "\n";

Expected (php)

bool(true)
Speaks

Actual (manticore 320b47ff, Darwin arm64)

bool(false)
[exit code 255]
PHP Fatal error:  Uncaught ReflectionException: Method speak does not exist

Tracking

Known-bug repro: tests/aot/repro/wrong/reflection_interface_methods_not_reflectable.php — bash tests/aot/xfail.sh -k reflection_interface_methods_not_reflectable reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

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

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions