Skip to content

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

Closed

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

Activity

  1. damianwadley commented on Aug 24, 2022

    @damianwadley
    Member

    Like with 64592, this is probably something that can't be fixed (if that decision is made) until PHP 9.

  2. iluuu1994 commented on Sep 2, 2022

    @iluuu1994
    Member

    Fix for the latter part: #9469

    I'll create a new issue for the former part so we have separate GitHub issue IDs that can be referenced.

  3. changed the title [-]Inconsistency with ReflectionMethod[/-] [+]Child's `private` method is shown with `overwrites A` annotation in reflection[/+] on Sep 2, 2022
  4. added a commit that references this issue on Sep 8, 2022
    1435fc6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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