Array key access on non-array values - to be made illegal?

From: Date: Tue, 12 Apr 2016 12:59:15 +0000
Subject: Array key access on non-array values - to be made illegal?
Groups: php.internals 
Request: Send a blank email to internals+get-92222@lists.php.net to get a copy of this message
Hello, I just stumbled upon behavior that seems to "fail silently" regardless of its very questionable validity: <?php $a = 1; var_dump($a[123]); // NULL, no notice https://3v4l.org/b3rDr Are there specific reasons why no notice is thrown? Is it by design? If so, does anyone remember why? I haven't checked if this affects other types too. I know that an assignment to an array key of a non-array would cause a cast of the value to array, but a mere read operation should surely cause a notice to be raised in the above scenario. Cheers, Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/

« previous php.internals (#92222) next »