Doc #62727 [Opn->Csd]: ArrayObject::offsetGet return type/logic error
| From: | krakjoe@php.net | Date: | Wed, 09 Oct 2013 06:26:26 +0000 |
| Subject: | Doc #62727 [Opn->Csd]: ArrayObject::offsetGet return type/logic error | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-10452@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62727&edit=1
ID: 62727
Updated by: krakjoe@php.net
Reported by: sandy at figureone dot com
Summary: ArrayObject::offsetGet return type/logic error
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
Operating System: All
PHP Version: 5.4.5
-Assigned To:
+Assigned To: krakjoe
Block user comment: N
Private report: N
New Comment:
The documentation no longer contains this discrepancy, so closing the bug.
Previous Comments:
------------------------------------------------------------------------
[2012-08-02 17:56:04] sandy at figureone dot com
Description:
------------
The docs for ArrayObject::offsetGet say it will return the value at the passed index or boolean
FALSE.
http://www.php.net/manual/en/arrayobject.offsetget.php
This suggests some sort of graceful failure on an undefined index, returning the default value FALSE
(never mind the possible ambiguity of this return vs. the stored value FALSE).
In actuality, it returns NULL for an undefined index and fires off the "Undefined index"
NOTICE as with regular arrays.
Test script:
---------------
$t = new ArrayObject(array('exists'=>42));
var_dump( $t->offsetGet('non_existent') );
Expected result:
----------------
FALSE
(and no notice)
Actual result:
--------------
NULL
with
PHP Notice: Undefined index: non_existent in /code/2DUpLq on line 4
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62727&edit=1