ID: 30337 Updated by: [EMAIL PROTECTED] Reported By: jorma dot tuomainen at softera dot fi Status: Open Bug Type: Documentation problem Operating System: Solaris PHP Version: 5.0.1 Assigned To: andi New Comment:
It's covered under http://php.net/migration5 Perhaps this deserves a note on the empty() page, perhaps not. Previous Comments: ------------------------------------------------------------------------ [2004-10-23 16:15:27] [EMAIL PROTECTED] "As far as the new OO model is concerned objects are always handles, they are always true and they aren't empty." (c) Andi Making it a documentation problem then. ------------------------------------------------------------------------ [2004-10-11 20:48:41] [EMAIL PROTECTED] <?php function empty_object($obj){ return count((array)$obj)==0; } class foo{var $a=1;} $std=new stdclass; $foo=new foo; var_dump(empty_object($obj), empty_object($foo)); ?> bool(true) bool(false) ------------------------------------------------------------------------ [2004-10-08 13:38:29] th at zirkonium dot net I find this bug pretty irritating too. In my opinion empty() shouldn't behave this way, or at least like Jorma said, it should be mentioned in docs or some other way to check if objects are empty. ------------------------------------------------------------------------ [2004-10-07 16:39:17] jorma dot tuomainen at softera dot fi No, I'm not using compatibility mode. If this is wanted behaviour it should least be mentioned in the documentation. I still don't understand why empty() have to behave that way. Since that makes perfectly good function for a good purpose go to waste on objects. Is there going to be some function for checking empty objects(no methods or properties) or do I need to implement that myself? ------------------------------------------------------------------------ [2004-10-06 22:05:06] [EMAIL PROTECTED] Does this also happen in zend.ze1_compatibility_mode? This was changed for non-compatibility mode with the change of moving objects to handles. As far as the new OO model is concerned objects are always handles, they are always true and they aren't empty. This is due to objects being an entity of their own now and not just a different syntax for accessing an array like structure. Just an example of why empty() might not make sense with objects is how you'd expect it to work with private/public/protected members. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/30337 -- Edit this bug report at http://bugs.php.net/?id=30337&edit=1
