I was hit by a bug where a returned DB result was expected to be an array but due to a glitch in the SQL query in one instance the DB wrapper correctly returned null. Unfortunately the code did not expect that (=bug).
However, I was surprised to see PHP did not issue a warning when the null value was accessed as an array. Does anyone know if it's by design or there is an explanation I'm missing?
Example to show what I mean:
$ php -a
Interactive shell
> echo phpversion() . PHP_EOL;
5.4.26
php > echo $test['value'];
PHP Notice: Undefined variable: test in php shell code on line 1
php > $test = 'string';
php > echo $test['value'];
PHP Warning: Illegal string offset 'value' in php shell code on line 1
php > $test = null;
php > echo $test['value'];
I would expect the last statement to generate a warning.