On Wed, 1 Jul 2020 at 18:44, Rowan Tommins <rowan.coll...@gmail.com> wrote:

> Hi George,
>
> On Wed, 1 Jul 2020 at 15:26, G. P. B. <george.bany...@gmail.com> wrote:
>
>>
>>    2. Emit the E_WARNING "Illegal string offset" and evaluate to 0 for
>>    offsets like '2str', and emit the E_WARNING "String offset cast
>>    occurred" for float numeric strings like '2.5'
>
>
>
> I'm not clear how this option fits with the rest of the RFC; there's no
> explicit mention of evaluating values to 0 which would previously have been
> evaluated differently. That would fall into the most significant category
> of BC breaks: working code in version X still works in version Y, but
> produces different results.
>
> At the moment, the "Backward Incompatible Changes" section just says:
>
> > code with liberal use of leading-numerical strings will need to be
> updated
>
> It would be good to expand that with examples of what such code would look
> like, how it would behave before and after, and what updates the user would
> need to make.
>
> Regards,
> --
> Rowan Tommins
> [IMSoP]
>

I've had another thought about while I was implementing this change.
I've updated the RFC to reflect what I think is a more reasonable approach:

> For string offsets accessed using numeric strings the following changes
> will be made:
>
>    - numeric strings which correspond to well formed floats will emit the
>    more usual “String offset cast occurred” warning instead of the “Illegal
>    string offset” one.
>    - leading numeric strings will emit the “Illegal string offset”
>    instead of the “A non well formed numeric value encountered” notice, and
>    continue to evaluate to their respective values.
>    - Non-numeric strings which emmited the “Illegal string offset”
>    warning will throw an “Illegal offset type” TypeError
>
> The only aspect I'm not totally convinced is making well formed float
strings more "legal" than they were in PHP 7.x.

I will also flesh out the RFC with more examples and which code is affected
and how it would need to be updated to produce the previous behaviour.

Best regards

George P. Banyard

Reply via email to