#50810 [Opn]: property_exists does not work for private

From: Date: Wed, 20 Jan 2010 23:17:55 +0000
Subject: #50810 [Opn]: property_exists does not work for private
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-146836@lists.php.net to get a copy of this message
 ID:               50810
 User updated by:  gaboto at gmail dot com
 Reported By:      gaboto at gmail dot com
 Status:           Open
 Bug Type:         Reflection related
 Operating System: Windows
 PHP Version:      5.3.1
 New Comment:

I'm sorry, the example was wrong, this is the right example:
<?php
class ExampleSuperclass
{
private $foo;
function propertyExists()
{
return property_exists($this, 'foo');
}
}

class ExampleSubclass extends ExampleSuperclass
{

}

$example = new ExampleSubclass();
var_dump($example->propertyExists());
?>


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

[2010-01-20 21:09:20] gaboto at gmail dot com

Description:
------------
property_exists does not work for private property defined in a
superclass.

Reproduce code:
---------------
<?php
class ExampleSuperclass
{
	private $foo;
} 

class ExampleSubclass extends ExampleSuperclass
{
	function methodExists()
	{
		return method_exists($this, 'foo');
	}
}

$example = new  ExampleSubclass();
var_dump($example->methodExists());

?>

Expected result:
----------------
it must print bool(true)

Actual result:
--------------
it prints bool(false)


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


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



Thread (5 messages)

« previous php.bugs (#146836) next »