Edit report at https://bugs.php.net/bug.php?id=46602&edit=1

 ID:                 46602
 Updated by:         yohg...@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

Reply via email to