#49719 [Opn->Fbk]: ReflectionClass::hasProperty returns true for a private property in base class

From: Date: Thu, 01 Oct 2009 11:20:59 +0000
Subject: #49719 [Opn->Fbk]: ReflectionClass::hasProperty returns true for a private property in base class
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-143116@lists.php.net to get a copy of this message
 ID:               49719
 Updated by:       sjoerd@php.net
 Reported By:      atblock at gmail dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Scripting Engine problem
 Operating System: Linux
 PHP Version:      5.3SVN-2009-09-30 (snap)
 New Comment:

From the documentation of hasMethod(), it seems that private properties
also count as properties. Why do you think this is a bug? Because the
property is not defined in class B but in class A?


Previous Comments:
------------------------------------------------------------------------

[2009-09-30 01:23:41] atblock at gmail dot com

Description:
------------
I have a class which inherits from another class. The base class has a

private property. When I check if that property exists on the inherited

class, it returns true.

Reproduce code:
---------------
class A {
	private $a;
}
class B extends A {
}
$a = new B;
$ref = new ReflectionClass($a);
var_dump($ref->hasProperty('a'));


Expected result:
----------------
bool(false)

Actual result:
--------------
bool(true)



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=49719&edit=1



Thread (5 messages)

« previous php.bugs (#143116) next »