Bug #62059 [Com]: ArrayObject and isset are not friends.

2013-05-23 Thread spneacy at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=62059edit=1

 ID: 62059
 Comment by: spneacy at gmail dot com
 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 in version 5.4.6

When using version 5.4.9, it appears to have been incidentally (or silently) 
fixed.


Previous Comments:

[2012-10-23 23:05:33] roberts at x0 dot lv

Confirmed present in 5.3.3-7 and 5.4.7-7, and 5.4.8-1


[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=62059edit=1


Bug #62059 [Com]: ArrayObject and isset are not friends.

2012-10-23 Thread roberts at x0 dot lv
Edit report at https://bugs.php.net/bug.php?id=62059edit=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=62059edit=1