Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ReflectionMethod constructor should not find private parent method #9470

Closed
@iluuu1994

Description

@iluuu1994

Description

Original issue:#9409

Description

Related to#9405 andhttps://bugs.php.net/bug.php?id=64592

It might not be important, but I think this should be fixed at some point, so I've created a new issue. I can also provide PR if you want.

  1. Private methods are accessible through child usingReflectionMethod:
    The following code:https://3v4l.org/Bso8B
<?phpclass A{private$privateProperty =1;privatefunctionprivateMethod() {}}class Bextends A {}try {echo (string)newReflectionMethod('B','privateMethod');}catch(Throwable$e){echo (string)$e;}try {echo (string)newReflectionProperty('B','privateProperty');}catch(Throwable$e){echo (string)$e;}

Resulted in this output:

Method [ <user, inherits A> private method privateMethod ] {  @@ /in/Bso8B 6 - 6}ReflectionException: Property B::$privateProperty does not exist in /in/Bso8B:16Stack trace:#0 /in/Bso8B(16): ReflectionProperty->__construct('B', 'privateProperty')#1 {main}

But I expected this output instead:

ReflectionException: Method B::privateMethod() does not exist in /in/Bso8B:11Stack trace:#0 /in/Bso8B(11): ReflectionMethod->__construct('B', 'privateMethod2')#1 {main}ReflectionException: Property B::$privateProperty does not exist in /in/Bso8B:16Stack trace:#0 /in/Bso8B(16): ReflectionProperty->__construct('B', 'privateProperty')#1 {main}

PHP Version

8.0 - 8.2

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp