For me, it looks like a bug. Put some debugging code (the following) and see the result:
<?php
class Foo {
private $bar;
function __get($name){
echo "__get(".$name.") is called!
";
debug_print_backtrace();
$x = $this->$name;
return $x;
}
function __unset($name){
unset($this->$name);
echo "Value of ". $name ." After unsetting is
";
echo $this->$name;
echo "
";
}
}
echo "Before
";
$foo = new Foo;
echo "After1
";
unset($foo->bar);
echo "After2
";
echo $foo->bar;
echo "After3
";
echo $foo->not_found;
?>
The result is:
Before
After1
Value of bar After unsetting is
__get(bar) is called!
#0 Foo->__get(bar) called at [E:\temp\t1.php:17]
#1 Foo->__unset(bar) called at [E:\temp\t1.php:24]
PHP Notice: Undefined property: Foo::$bar in E:\temp\t1.php on line 9
After2
__get(bar) is called!
#0 Foo->__get(bar) called at [E:\temp\t1.php:26]
__get(bar) is called!
#0 Foo->__get(bar) called at [E:\temp\t1.php:9]
#1 Foo->__get(bar) called at [E:\temp\t1.php:26]
PHP Notice: Undefined property: Foo::$bar in E:\temp\t1.php on line 9
After3
__get(not_found) is called!
#0 Foo->__get(not_found) called at [E:\temp\t1.php:28]
PHP Notice: Undefined property: Foo::$not_found in E:\temp\t1.php on line 9