Bug #71400 [Com]: null assignment as array strange results
Edit report at https://bugs.php.net/bug.php?id=71400&edit=1
ID: 71400
Comment by: amir dot rajs at gmail dot com
Reported by: rav dot janisz at gmail dot com
Summary: null assignment as array strange results
Status: Open
Type: Bug
Package: Arrays related
Operating System: linux
PHP Version: 5.5.31
Block user comment: N
Private report: N
New Comment:
This bug needs to be fixed ASAP. The fact that PHP 7 doesn't throw error when trying to access
a null or numeric value as an associative array with string index is bit outdated. It should first
check if the value is array, and throw error if accessing non-array as an array.
Previous Comments:
------------------------------------------------------------------------
[2016-01-17 22:57:07] rav dot janisz at gmail dot com
wrong summary
------------------------------------------------------------------------
[2016-01-17 22:39:57] rav dot janisz at gmail dot com
Description:
------------
null assignment to a variable and refer to it as an array element does not return any errors
after assign null to variable var_dump return null and isset return false, but why in line 5 assign
first element of $zonk variable(which is don't array and don't should exists at all) to
next variable doesnt't return any errors
Test script:
---------------
$zonk = null; //1
var_dump($zonk); //2 return null
var_dump(isset($zonk)); //3 return false
$beret = $zonk[0]; //5 don't throw nothing ???
var_dump($beret); //6 return null
var_dump(isset($beret)); //7 return false
Expected result:
----------------
is line 6 don't should throw something to output error or notice?
or if it is good behavior then in line 3 isset should return true?
or if i'm wrong explain why? becouse i can't figured it out
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71400&edit=1
Thread (4 messages)