Re: [RFC] Generalize support of negative string offsets
| From: | Yasuo Ohgaki | Date: | Mon, 15 Feb 2016 07:10:30 +0000 |
| Subject: | Re: [RFC] Generalize support of negative string offsets | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-91234@lists.php.net to get a copy of this message | ||
Hi Pierre,
On Mon, Feb 15, 2016 at 4:01 PM, Pierre Joye <pierre.php@gmail.com> wrote:
> On Feb 15, 2016 1:15 PM, "Yasuo Ohgaki" <yohgaki@ohgaki.net> wrote:
>>
>> Hi all,
>>
>> On Mon, Feb 15, 2016 at 12:49 PM, Stanislav Malyshev
>> <smalyshev@gmail.com> wrote:
>> >> Another issue mentioned in this thread is the spurious array conversion
>> >> that happens for empty strings. We have an existing bug report for
>> >> this:
>> >> https://bugs.php.net/bug.php?id=53432 I've
>> >> created a PR to fix this
>> >> issue: https://github.com/php/php-src/pull/1764 If
>> >> there are no
>> >> objections, I'll merge this for 7.1 as well.
>> >
>> > This one looks like a bug, converting string to array is really weird.
>> > And one more reason to never use [] for string offsets - clearly, the
>> > bug stems out of confusion between arrays operation (which expects
>> > conversion to array) and string operation (which expects string).
>> > In any case, this needs a note in UPGRADING as behavior change.
>>
>> I fully agree {} and [] usage.
>> - {} only for string
>> - [] only for array
>> Simple is better if it satisfies all of our needs.
>>
>> Since PHP allowed [] for strings, how about allow it, but deprecate it
>> by doc in 7.1, deprecate(Raise error) it in 7.2, then remove it by
>> 7.3?
>
> If anything then it can be removed by 8.
Good enough for me!
--
Yasuo Ohgaki
yohgaki@ohgaki.net