Yasuo Ohgaki wrote:

> I fully agree that current behavior could be used meaningful ways. However,
> 
>  <?php
>  $foo = 42;
>  $foo['bar']; // => NULL
>  $v = NULL;
>  $v[0][1][2][3][4][5][6][7][8][9]; // NULL
> 
> this code is semantically wrong and I would like to have error/exception
> for such
> erroneous codes. It's inconsistent with array object, too.
> 
> Raising exception/error is correct behavior for types that aren't array.
> To avoid errors, users should use isset()/is_array()/etc.

I agree that the code is not clean, and that an isset check is
appropriate, particularly as one could do:

  $v = NULL;
  $v[0][1][2][3][4][5][6][7][8][9] ?? NULL; // NULL

> Since we have debate for this PR, this PR would be good for RFC targeting
> PHP 7.1.

It seems to me that raising an exception or throwing an error (instead
of a notice) could be too much of a BC break for a minor version.

-- 
Christoph M. Becker

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to