From:             matthew at zend dot com
Operating system: Debian GNU/Linux (unstable)
PHP version:      5.2.0
PHP Bug Type:     SPL related
Bug description:  empty() does not work correctly with ArrayObject when using 
ARRAY_AS_PROPS

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 bug report at http://bugs.php.net/?id=40036&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40036&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40036&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40036&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=40036&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=40036&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=40036&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=40036&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=40036&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=40036&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=40036&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=40036&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=40036&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=40036&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40036&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=40036&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=40036&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=40036&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40036&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=40036&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=40036&r=mysqlcfg

Reply via email to