Re: Class name resolution for \array::class
| From: | Rowan Collins | Date: | Mon, 01 Oct 2018 13:15:41 +0000 |
| Subject: | Re: Class name resolution for \array::class | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-103296@lists.php.net to get a copy of this message | ||
On Mon, 1 Oct 2018 at 13:24, Marcos Passos <marcospassos.com@gmail.com>
wrote:
>
> You can also see it as a language construct that expects a type at the
> left-hand side of the name resolution operator. In that sense, primitive
> types are perfectly valid.
>
While I can see that as an interpretation, it doesn't make a lot of sense:
- the keyword "class" implies that this will always return a class name; it
is the static equivalent of get_class(), which does not support non-objects
- if instead it was resolving a "type", you might expect it to return the
same values as gettype(), which for any object is simply the string "object"
- the main purpose of the feature is to resolve namespace lookups and
aliases, but basic types are not subject to namespaces; in other words,
"int::class" can only ever return "int"
As Marco says, if you have a use case where allowing this is helpful,
please share it, and we can discuss if this, or some new related feature
(e.g. "array::type"), would be worth supporting.
Regards,
--
Rowan Collins
[IMSoP]