Bug #62059 [NEW]: ArrayObject and isset are not friends.
| From: | julien at palard dot fr | Date: | Fri, 18 May 2012 15:22:30 +0000 |
| Subject: | Bug #62059 [NEW]: ArrayObject and isset are not friends. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-170561@lists.php.net to get a copy of this message | ||
From:
Operating system: Linux 2.6.32-5-amd64
PHP version: Irrelevant
Package: SPL related
Bug Type: Bug
Bug description:ArrayObject and isset are not friends.
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 bug report at https://bugs.php.net/bug.php?id=62059&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62059&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62059&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62059&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=62059&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62059&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=62059&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=62059&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=62059&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=62059&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=62059&r=support
Expected behavior: https://bugs.php.net/fix.php?id=62059&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=62059&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=62059&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=62059&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62059&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62059&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=62059&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=62059&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=62059&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=62059&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=62059&r=mysqlcfg