php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43054 get_object_vars scope
Submitted: 2007-10-20 19:08 UTC Modified: 2007-10-20 19:42 UTC
From: pdobrigkeit at gmx dot de Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.2.4 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: pdobrigkeit at gmx dot de
New email:
PHP Version: OS:

 

 [2007-10-20 19:08 UTC] pdobrigkeit at gmx dot de
Description:
------------
Inherited Objects call a get_object_vars method in a parent. Scope should be of the type of object actually calling the method, but private members of the child do not recognized.

Reproduce code:
---------------
<?php

class Base {
      function getObjectVars() {
            print_r(get_object_vars($this));
      }
}

class Child extends Base{
	private $varA   = 'VarA';
	protected $varB = 'VarB';
	public $varC    = 'VarC';
	
	function __construct() {	
            $this->getObjectVars();            
	}
}

$child = new Child();

?>

Expected result:
----------------
Array ([varA] => VarA [varB] => VarB [varC] => VarC )

Actual result:
--------------
Array ( [varB] => VarB [varC] => VarC )

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-20 19:35 UTC] felipensp at gmail dot com
This isn't a bug.
See http://br2.php.net/manual/en/language.oop5.visibility.php
 [2007-10-20 19:42 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 11:01:37 2025 UTC