ID: 43583
Comment by: crrodriguez at suse dot de
Reported By: michael at dmgx dot com
Status: Open
Bug Type: Variables related
Operating System: Linux
PHP Version: 5.2.5
New Comment:
you have to define __isset magic method.
Previous Comments:
------------------------------------------------------------------------
[2007-12-12 21:50:23] [EMAIL PROTECTED]
In PHP 5.3 it works fine.
------------------------------------------------------------------------
[2007-12-12 19:07:07] michael at dmgx dot com
Description:
------------
Empty returns false whenever a property of an object is accessed
through __get. This problem has been reported before. The answer that
"it's a feature" is entirely bogus - Either return the right value or
throw a damn error but don't do nothing and leave people to wonder what
the Hell is going on with their script. I just lost two full days to
this "feature" and I'm not amused.
empty(someFunction());
throws an error. If this bug is too much trouble to fix set it up so
empty($object->property);
also throws an error when a __get has been set.
Reproduce code:
---------------
class foo
{
protected $data = array();
public function __set($element, $value) { $this->data[$element] =
$value; }
public function __get($element) { return $this->data[$element]; }
}
$bar = new foo();
$bar->cat = 'meow';
empty($bar->cat); // returns false, as expected.
$bar->cat = '';
empty($bar->cat); // returns false, should return true.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43583&edit=1