Req #46602 [Opn->Wfx]: Change: Accessing by [] or {} to variables of other type silently returns NULL
| From: | yohgaki@php.net | Date: | Tue, 30 Jul 2013 03:21:26 +0000 |
| Subject: | Req #46602 [Opn->Wfx]: Change: Accessing by [] or {} to variables of other type silently returns NULL | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-180556@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=46602&edit=1
ID: 46602
Updated by: yohgaki@php.net
Reported by: bugs dot php dot net-V29nHf1_z-nsp at cvogt dot org
Summary: Change: Accessing by [] or {} to variables of other
type silently returns NULL
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
PHP Version: 5.2.6
Block user comment: N
Private report: N
New Comment:
I agree that raising error may help debugging.
However, this behavior is not likely to be changed.
1. It breaks many codes.
2. Introducing E_DEBUG or like will create confusion.
Feel free to bring this issue to internals ML, if anyone feel this change in
appropriate.
Previous Comments:
------------------------------------------------------------------------
[2008-11-18 08:55:19] bugs dot php dot net-V29nHf1_z-nsp at cvogt dot org
Description:
------------
As http://bugs.php.net/bug.php?id=41195 requested
http://de2.php.net/language.types.string now
mentions, accessing other types than strings, arrays or objects using the [] operator silently
returns NULL.
This behavior hides bugs. There is no sensible reason to use [] on a other types than mentioned, so
it should result in an error. It would make sense to trigger an E_NOTICE. However, to be gentle to
backwards compatibility it could also trigger an E_STRICT instead.
The "expected result" below is only an example of a possible message.
Reproduce code:
---------------
$o = NULL;
var_dump($o[0]);
Expected result:
----------------
Notice: Undefined offset: 0 for value of type NULL
NULL
Actual result:
--------------
NULL
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=46602&edit=1