Hi!

The fix to make $a[0][0] work is good.  No argument here.

Then the rest of the discussion is moot for 5.4, as that's the only change that happened.

The problem arises where programmers wrote code anticipating the
incoming variable is an array but another programmer has passed in a
string.  The inital programmer wrote a validation to see if a sub-sub
key isset/!empty.  If that key wasn't in the array or the array was a
string, the validation fails and appropriate action is taken.  But now
the validation passes and mayhem ensues.

I'm sorry that influences you code, it is unfortunate, but relying on an obscure bug, however convenient, is not a good practice. Exactly because bugs get fixed. If you want to see if something is array or string - provided that data structure that intermixes arrays and strings makes sense - check it.

This is the first time in ten years I heard about string array keys
being converted to integers (all be it in the context of string
offsets).

I'm sorry you didn't hear about it before, but it always worked this way as far as I remember. And there's no such thing as "string array keys" - again, you are confusing operators applied to different types.

If this behavior is going to remain, the conversion is a strong
indicator that unintended behaviors are happening.  We need to follow
the logic of the new array string conversion notice in 5.4 and produce a
notice in this situation so programmers can address the bugs in their
programs rather than being secretly bitten by this bug.

I'm sorry but it's too late for big additions in 5.4, such as introducing new warnings or new semantics. We know it is not a bug, but rather a consequence of a bugfix and code relying on a bug to work. So for 5.4 I think that's where it stands. You are welcome to write an RFC suggesting how to make string offsets (or any other part ;) work better for next versions though.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

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

Reply via email to