Skip to content

ReflectionClass not return private elements of parent classes #9405

Closed as not planned
@WinterSilence

Description

@WinterSilence

Description

The following code:

<?php
class A
{
    private $privateProperty = 1;
    private function privateMethod() {}
}
class B extends A {}
$class = new ReflectionClass('B');
echo (string) $class;

Resulted in this output:

Class [ <user> class B extends A ] {
  ...

  - Properties [0] {
  }

  - Methods [0] {
  }
}

But I expected this output instead:

Class [ <user> class B extends A ] {
  ...

  - Properties [1] {
    Property [ private $privateProperty = 1 ]
  }

  - Methods [1] {
    Method [ <user, inherits A> private method privateMethod ] {
      @@ ...
    }
  }
}

PHP Version

PHP 8.0.22

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