For BC purposes with PHP 3, NULL/False and unset creation of array does not emit a warning. I don't think we should change this.
I do understand the argument against breaking BC with the $a = 'foo'; $a['bar']['qux'] = 42; code. I think it's probably best if I revert back to PHP 4 behavior and emit an E_WARNING.


Andi

At 12:20 PM 4/27/2004 +0200, Christian Schneider wrote:
Andi Gutmans wrote:
I made this change back in December.
I guess I could revert back but I think it makes sense to be strict here.

Reevaluating it I noted the following: $a = 'foo'; $a['bar']['qux'] = 42; # error

$a = 42;  $a['bar']['qux'] = 42;        # warning
$a = true;  $a['bar']['qux'] = 42;      # warning

unset($a); $a['bar']['qux'] = 42;       # works
$a = null;  $a['bar']['qux'] = 42;      # works
$a = false;  $a['bar']['qux'] = 42;     # works!

On the other hand
$a = 'foo'; $b = $a['bar']['qux'];      # error

$a = 42; $b = $a['bar']['qux'];         # works
$a = true; $b = $a['bar']['qux'];       # works
unset($a); $b = $a['bar']['qux'];       # works
$a = null; $b = $a['bar']['qux'];       # works
$a = false; $b = $a['bar']['qux'];      # works

Let me ask you one question: What it the *real* benefit of making it fail? Isn't a notice or warning enough safety?

I think this should definitely be more orthogonal, i.e. work (with a notice or warning) in all cases to avoid WTF.

[ $a = 'foo'; $a['bar'] = 42; has an even weirder behaviour: It results in the string '4oo'... ]

- Chris

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



Reply via email to