Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP@master] Reflection method does not exist for private method from parent class #10840

Closed
kubawerlos opened this issue Mar 12, 2023 · 1 comment

Comments

@kubawerlos
Copy link

Description

The following code:

<?php

class C1 { public function t1() {} }
class C2 { protected function t2() {} }
class C3 { private function t3() {} }

$method = new \ReflectionMethod(new class extends C1 {}, 't1'); // this is fine
$method = new \ReflectionMethod(new class extends C2 {}, 't2'); // this is fine
$method = new \ReflectionMethod(new class extends C3 {}, 't3'); // Fatal error: Uncaught ReflectionException: Method C3@anonymous::t3() does not exist

Resulted in this output:

Fatal error: Uncaught ReflectionException: Method C3@anonymous::t3() does not exist in /in/bJ2af:9
Stack trace:
#0 /in/bJ2af(9): ReflectionMethod->__construct(Object(C3@anonymous), 't3')
#1 {main}
  thrown in /in/bJ2af on line 9

Process exited with code 255.

But I expected this output instead:

It happens only on master branch, 8.2.3 is not affected.

https://3v4l.org/bJ2af/rfc#vgit.master

PHP Version

master

Operating System

No response

@damianwadley
Copy link
Member

Private methods only exist on the classes that define them. The fact that it worked before was a bug, and it was fixed with #9470.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants