|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-01-07 03:52 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Mon Jan 05 02:00:02 2026 UTC |
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.