> Am 14.01.2024 um 23:58 schrieb Robert Landers <landers.rob...@gmail.com>:
> 
> Hello Internals,
> 
> After much thought and deliberation, I've updated the nameof RFC
> (https://wiki.php.net/rfc/nameof) to reflect most of this discussion
> and refine a few edge cases regarding objects. TL;DR: there are a few
> rules regarding how properties of objects are addressed that I hope a
> few people will like (and would make it much more usable in static
> contexts, like attributes).
> 
> I'm still not fully settled on the syntax, and this is still very much
> a work in progress. So, I'd love feedback in that regard.
> 
> Robert Landers
> Software Engineer
> Utrecht NL

Hey Robert,

In line with ::class, nameof() should never prepend a leading slash.

The leading slash is a compile time concept to distinguish namespace relative 
and global addressing. At runtime everything has a canonical name, without 
leading slash.

Also prepending a slash in code, i.e. '\\'. is much easier than substr(..., 1) 
to remove, if needed.

On the name resolution of things which have a visibility, I wonder whether the 
visibility is checked or not? In e.g. C# it is.

Also, the RFC says a warning will be emitted during compilation. I assume it 
should be rather be the first time the given line is executed at runtime as PHP 
doesn't necessarily have access to all identifiers yet when the code is 
compiled (e.g. referencing something which is included at runtime).
Similarly, how often is static:: checked? On every access? Thanks to late 
static binding it may sometimes exist and sometimes not.

I think parent:: is missing in the list of left-hand allowed exceptions.

Thanks,
Bob
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to