|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-12-12 21:50 UTC] felipe@php.net
[2007-12-13 04:23 UTC] crrodriguez at suse dot de
[2007-12-16 18:33 UTC] johannes@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 02:00:01 2025 UTC |
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.