On Tue, Jun 16, 2020 at 1:34 PM Nikita Popov <nikita....@gmail.com> wrote:

> On Tue, Jun 16, 2020 at 10:28 PM Davey Shafik <da...@php.net> wrote:
>
>>
>>
>> On Tue, Jun 16, 2020 at 1:52 AM Nikita Popov <nikita....@gmail.com>
>> wrote:
>>
>>> Hi internals,
>>>
>>> Inspired by the recent discussion on reserved keyword reservation, I'd
>>> like
>>> to propose the following RFC:
>>>
>>> https://wiki.php.net/rfc/namespaced_names_as_token
>>>
>>> This RFC makes two related changes: Treat namespaced names as a single
>>> token, which enables use of reserved keywords inside them. And remove
>>> reserved keyword restrictions from various declarations.
>>>
>>> The RFC comes with a small backwards compatibility break related to names
>>> that include whitespace, but will hopefully reduce the backwards
>>> compatibility impact of future reserved keyword additions.
>>>
>>> Regards,
>>> Nikita
>>>
>>
>> The only issue I have with this RFC is this:
>>
>> use Foo as KEYWORD;
>>
>> While this might be _technically_ correct, it is unusable. That is:
>>
>> use Foo as List;
>>
>> class Bar extends List { } // this will not work
>>
>
> That's correct. However, "class Bar extends List\FooBar" will work.
>

Hadn't considered this! Good point.


>
> I mainly allow this because "use Foo\Bar" is the same as "use Foo\Bar as
> Bar". If "use Foo\List" is allowed, it makes little sense to forbid the
> equivalent "use Foo\List as List".
>
> Given this, I think this specific syntax should be an error, unless I'm
>> missing something?
>>
>
Looks like I was, consider my concern assuaged :)


>
>> Also, does this mean we can alias to fully namespaced names now?
>>
>> use \My\Foo as \Bar\Foo;
>> class Bat extends \Bar\Foo { } // now actually extends \My\Foo, not
>> \Bar\Foo (no autoload would happen?)
>>
>
> No, this continues to be not allowed. "As" does not accept a namespaced
> name, it accepts a single identifier.
>

But now the namespace _is_ a single identifier. Or at least, it creates
some (minimal) confusion here IMO.

- Davey

Reply via email to