Re: Array dereferencing of scalars
| From: | Christoph Becker | Date: | Tue, 09 Jun 2015 20:16:54 +0000 |
| Subject: | Re: Array dereferencing of scalars | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-86532@lists.php.net to get a copy of this message | ||
Rowan Collins wrote:
> Christoph Becker wrote on 09/06/2015 14:09:
>> I wonder where these coercion rules are described. The manual has a
>> section about "Converting to array"[1] which actually describes casting,
>> and is obviously not what is happening when the subscript operator (as
>> the langspec calls it[2]) is applied to non-null scalars.
>
> There's a manual page on "Type Juggling" which is probably more
> relevant: http://php.net/manual/en/language.types.type-juggling.phpW8fóEMà\\i'
> uÉOˆ
>
> Interestingly, it notes that:
>
>> The behaviour of an automatic conversion to array is currently undefined.
Thanks. I've missed that. It explains the current behavior.
> So, at least as far as that reference point is concerned, any change in
> behaviour could be justified (if agreed by RFC) as defining what was
> previously undefined.
I would welcome that. In my opinion, undefined behavior is better
avoided in a language specification.
--
Christoph M. Becker