Hi,

The following part of the proposal is problematic: Allow keywords in definition 
of classes, functions, const, etc.

class KEYWORD {}
interface KEYWORD {}
trait KEYWORD {}
function KEYWORD() {}
const KEYWORD = 0;
use Foo as KEYWORD;
Under your proposal, the following code will compile without notice, but will 
have a different behaviour from what the programmer intended:

```php
class Int { }

const PRINT = 2;
const YIELD = 3;

function foo(Int $b) {
    return PRINT + YIELD;
}
```

If it is important to allow to define classes, etc. with a keyword as name, I 
suggest to force the programmer to say explicitly “Yes, it is really what I 
want”. For example, something like the following:

```php
class namespace\Int { }

const namespace\PRINT = 2;
```

Another point which is problematic, is to allow `namespace` as a namespace 
parts, since `namespace\foo`, although interpreted as a namespace-relative 
name, could be intended to be a qualified name by the programmer.

—Claude




> Le 16 juin 2020 à 10:52, Nikita Popov <nikita....@gmail.com> a écrit :
> 
> 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

Reply via email to