Skip to content

Child's private method is shown with overwrites A annotation in reflection #9409

Closed
@KapitanOczywisty

Description

@KapitanOczywisty

Description

Child's private method is shown with overwrites A annotation, which is misleading https://3v4l.org/dm3Y9

<?php
class A
{
    private function privateMethod() {}
}
class C extends A {
    private function privateMethod() {}
    private function otherMethod() {}
}

$class = new ReflectionClass('C');
echo (string)$class->getMethod('privateMethod');
echo (string)$class->getMethod('otherMethod');

Resulted in this output:

Method [ <user, overwrites A> private method privateMethod ] {
  @@ /in/dm3Y9 7 - 7
}
Method [ <user> private method otherMethod ] {
  @@ /in/dm3Y9 8 - 8
}

But I expected this output instead:

Method [ <user> private method privateMethod ] {
  @@ /in/dm3Y9 7 - 7
}
Method [ <user> private method otherMethod ] {
  @@ /in/dm3Y9 8 - 8
}

/cc @damianwadley

PHP Version

8.0 - 8.2

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions