From: michael at dmgx dot com Operating system: Linux PHP version: 5.2.5 PHP Bug Type: Variables related Bug description: Empty function fails when examining property of object accessed through __get
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 bug report at http://bugs.php.net/?id=43583&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43583&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43583&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43583&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43583&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43583&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43583&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43583&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43583&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43583&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43583&r=support Expected behavior: http://bugs.php.net/fix.php?id=43583&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43583&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43583&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43583&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43583&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43583&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43583&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43583&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43583&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43583&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43583&r=mysqlcfg