Re: What to do with "$array[foobar]"?
| From: | Guilliam Xavier | Date: | Fri, 10 Jan 2020 13:42:00 +0000 |
| Subject: | Re: What to do with "$array[foobar]"? | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108088@lists.php.net to get a copy of this message | ||
Hi,
On Thu, Jan 9, 2020 at 1:05 PM Nikita Popov <nikita.ppv@gmail.com> wrote:
>
> [...] we already support
> "$string" and "$object->prop", so it is in a way natural that
> "$array['key']" is also supported, as the last of the
> "fundamental"
> variable syntaxes.
What about rather deprecating "$object->prop" too? The current
situation can be surprising:
"$object->foo()" // $object->foo . '()'
"$object->obj->bar" // $object->obj . '->bar'
"$object->arr[qux]" // $object->arr . '[qux]'
"$array[arr][bar]" // $array['arr'] . '[bar]'
"$array[obj]->qux" // $array['obj'] . '->qux'
In any case, I'm +1 for deprecating "$array[key]", and "$array[0]" to
avoid introducing another inconsistency.
--
Guilliam Xavier