Edit report at http://bugs.php.net/bug.php?id=43936&edit=1

 ID:               43936
 Updated by:       paj...@php.net
 Reported by:      james dot laver at gmail dot com
 Summary:          __empty() magic method
-Status:           Open
+Status:           Assigned
 Type:             Feature/Change Request
-Package:          Feature/Change Request
+Package:          *General Issues
 Operating System: GNU/Linux
 PHP Version:      5.2.5
-Assigned To:      
+Assigned To:      dmitry

 New Comment:

hi Dmitry,



What's your thoughts on this one? Someone asked me about it and we found
this old bug.



A workaround is to implement __isset but that makes little sense (isset
!= empty) and is counter intuitive.


Previous Comments:
------------------------------------------------------------------------
[2008-01-25 14:40:45] james dot laver at gmail dot com

Description:
------------
Using empty() on a variable that would be pulled from __get does not
work, this has been established as 'not a bug' by more bug reports than
anyone cares to remember, however, the documentation's suggestion of
using __isset is not adequate if you wish to implement both isset and
empty functionality.



Thus I propose an __empty() magic method which would overload empty() in
the way that __isset() overrides isset().

Reproduce code:
---------------
public function __empty($value)

{

  return empty($this->_values[$value]);

}

Expected result:
----------------
empty($object->my_empty_value) = true

Actual result:
--------------
.....


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=43936&edit=1

Reply via email to