|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36434 ReflectionProperty getDeclaringClass
Submitted: 2006-02-17 23:01 UTC Modified: 2006-02-20 16:28 UTC
From: gmarzin at club-internet dot fr Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2006-02-17 (snap) OS: win32
Private report: No CVE-ID: None
 [2006-02-17 23:01 UTC] gmarzin at club-internet dot fr
Before 5.1.3, ReflectionProperty->getDeclaringClass was working ok. Exactly like ReflectionMethod->getDeclaringClass: the reflectionClass could be an ancester.
Actually, with 5.1.3 ReflectionMethod work OK, but ReflectionProperty do not give back the ancesters classes.

Reproduce code:
class ancester
public $ancester = 0;
	function ancester()
		return $this->ancester;
class foo extends ancester
public $bar = "1";
	function foo()
		return $this->bar;

$r = new ReflectionClass('foo');
$prop = $r->GetProperties();
foreach ($prop as $p)
	$owner = $p->getDeclaringClass();
	echo $p->getName(). " <b>". $owner->getName()."</b><br/>";

$methode = $r->GetMethods();
foreach ($methode as $m)
	$owner = $m->getDeclaringClass();
	echo $m->getName(). " <b>". $owner->getName()."</b><br/>";


Expected result:
bar foo
ancester ancester
foo foo
ancester ancester

Actual result:
bar foo
ancester foo      (expecting "ancester")
foo foo
ancester ancester


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-20 16:28 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Feb 29 12:01:27 2024 UTC