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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 07:01:29 2024 UTC