#40036 [Opn->Csd]: empty() does not work correctly with ArrayObject when using ARRAY_AS_PROPS
| From: | iliaa@php.net | Date: | Sun, 07 Jan 2007 03:52:52 +0000 |
| Subject: | #40036 [Opn->Csd]: empty() does not work correctly with ArrayObject when using ARRAY_AS_PROPS | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-107256@lists.php.net to get a copy of this message | ||
ID: 40036
Updated by: iliaa@php.net
Reported By: matthew at zend dot com
-Status: Open
+Status: Closed
Bug Type: SPL related
Operating System: Debian GNU/Linux (unstable)
PHP Version: 5.2.0
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2007-01-05 18:33:00] matthew at zend dot com
Description:
------------
When using the ArrayObject::ARRAY_AS_PROPS flag with ArrayObject,
empty() does not work correctly on properties defined using either
array notation or object notation (and not previously declared in the
object). null, false, and empty strings do not return a true value from
empty().
If ARRAY_AS_PROPS is not specified, empty() works fine.
Reproduce code:
---------------
class View extends ArrayObject
{
public function __construct(array $array = array())
{
parent::__construct($array, ArrayObject::ARRAY_AS_PROPS);
}
}
$view = new View();
$view->foo = false;
$view->bar = null;
$view->baz = '';
if (empty($view['foo']) || empty($view->foo)) {
echo "View::foo empty\n";
}
if (empty($view['bar']) || empty($view->bar)) {
echo "View::bar empty\n";
}
if (empty($view['baz']) || empty($view->baz)) {
echo "View::baz empty\n";
}
Expected result:
----------------
View::foo empty
View::bar empty
View::baz empty
Actual result:
--------------
No output received.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40036&edit=1