php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76871 get_class_vars() missing shadowed properties
Submitted: 2018-09-12 14:03 UTC Modified: -
From: nikic@php.net Assigned:
Status: Open Package: Scripting Engine problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nikic@php.net
New email:
PHP Version: OS:

 

 [2018-09-12 14:03 UTC] nikic@php.net
Description:
------------
get_class_vars() fails to return in-scope private properties that have been shadowed in a child-class.

This report is essentially the same as bug #46812, which has been incorrectly closed after an tangentially related documentation issue has been fixed.

Test script:
---------------
<?php

class A {
    private $foo = "a";

    public static function getClassVars() {
        var_dump(get_class_vars(B::class));
    }
}
class B extends A {
    private $foo = "b"; // comment me out
}

A::getClassVars();

Expected result:
----------------
array(1) {
  ["foo"]=>
  string(1) "a"
}

Actual result:
--------------
array(0) {
}

Patches

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC