#34396 [Opn->Csd]: Using unset on member variable results in __get and __set being used
| From: | sniper@php.net | Date: | Wed, 07 Sep 2005 09:44:42 +0000 |
| Subject: | #34396 [Opn->Csd]: Using unset on member variable results in __get and __set being used | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-84609@lists.php.net to get a copy of this message | ||
ID: 34396
Updated by: sniper@php.net
Reported By: zeldorblat at gmail dot com
-Status: Open
+Status: Closed
Bug Type: Class/Object related
Operating System: Linux
PHP Version: 5.0.5
New Comment:
See bug #33512
Previous Comments:
------------------------------------------------------------------------
[2005-09-06 19:33:09] zeldorblat at gmail dot com
Description:
------------
If unset() is used on a member variable, subsequent calls to __get and
__set take effect as if the variable was not defined as a property.
This may be a feature, but the behavior was different in 5.0.4.
Reproduce code:
---------------
Class A {
private $foo = 5;
private $x = array();
public function __get($name) {
if(!isset($this->x[$name]))
echo "Property $name is not set!";
else
return $this->x[$name];
}
public function bar() {
unset($this->foo);
return $this->foo;
}
}
$a = new A();
echo $a->bar();
Expected result:
----------------
In PHP 5.0.4:
PHP Notice: Undefined variable: foo
Actual result:
--------------
In PHP 5.0.5:
Property foo is not set!
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34396&edit=1