Bug #62059 [Com]: ArrayObject and isset are not friends.
| From: | roberts at x0 dot lv | Date: | Tue, 23 Oct 2012 23:05:34 +0000 |
| Subject: | Bug #62059 [Com]: ArrayObject and isset are not friends. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-174253@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62059&edit=1
ID: 62059
Comment by: roberts at x0 dot lv
Reported by: julien at palard dot fr
Summary: ArrayObject and isset are not friends.
Status: Open
Type: Bug
Package: SPL related
Operating System: Linux 2.6.32-5-amd64
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Confirmed present in 5.3.3-7 and 5.4.7-7, and 5.4.8-1
Previous Comments:
------------------------------------------------------------------------
[2012-05-18 15:22:30] julien at palard dot fr
Description:
------------
The doc state that isset() is not a function, so that it can do weird things
like deep inspection, without raising a NOTICE about 'b' being undefined :
$a = array();
isset($a['b']['c']);
But if $a is an ArrayObject, the deep inspection does not work and a "Undefined
index 'b'" NOTICE is triggered.
But I found a __isset() in the documentation,
(http://www.php.net/manual/en/language.oop5.overloading.php#object.isset) it
have a very concise documentation but it seems a sufficient convention to make
this work :
I think that isset should call __isset() from left to right returning FALSE at
the 1st non set member, like this :
$a = SomeObject();
isset($a['b']['c']['d']['e']);
should call :
$a->__isset('b'), that should return FALSE, and stop here, wihout NOTICE.
Test script:
---------------
echo "isset on array, work without notice\n";
$array = array();
var_dump(isset($array['a']['b']));
echo "isset on arrayobject, should work as ArrayObject implements __isset\n";
$arrayobject = new ArrayObject();
var_dump(isset($arrayobject['a']['b']));
Expected result:
----------------
isset on array, work without notice
bool(false)
isset on arrayobject, should work as ArrayObject implements __isset
bool(false)
Actual result:
--------------
isset on array, work without notice
bool(false)
isset on arrayobject, should work as ArrayObject implements __isset
PHP Notice: Undefined index: a in test.php on line 10
Notice: Undefined index: a in test.php on line 10
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62059&edit=1