#40492 [Opn->Bgs]: property_exists called in parent class doesn work on private property of subcla
| From: | tony2001@php.net | Date: | Thu, 15 Feb 2007 09:02:37 +0000 |
| Subject: | #40492 [Opn->Bgs]: property_exists called in parent class doesn work on private property of subcla | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-108940@lists.php.net to get a copy of this message | ||
ID: 40492
Updated by: tony2001@php.net
Reported By: rpg at terry-pratchett dot info
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
Operating System: debian sarge
PHP Version: 5.2.1
New Comment:
>If you overload the function in the childclass it
>works, but this is actually not the idea behind OOP
I think inability to access child's private properties from parent's
scope is pretty much OO. This is actually how private properties work,
they cannot be accessed out of the class scope.
Previous Comments:
------------------------------------------------------------------------
[2007-02-15 08:54:26] rpg at terry-pratchett dot info
Description:
------------
The property_exists function returns true on private properties if
called within a class. That doesn't work, if it is called in a function
of a parent class. If you overload the function in the childclass it
works, but this is actually not the idea behind OOP ;-)
Reproduce code:
---------------
<?
class x {
private $x;
public function prop ($p) {
return property_exists($this,$p);
}
}
class y extends x {
private $y;
}
$x = new x;
echo 'prop(x): '.$x->prop('x').'<br>';
$y = new y;
echo 'prop(y): '.$y->prop('y').'<br>';
?>
Expected result:
----------------
you should see
prop(x): 1
prop(y): 1
Actual result:
--------------
prop(x): 1
prop(y):
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40492&edit=1