Re: Add support $object::class
| From: | Marco Pivetta | Date: | Thu, 07 May 2015 15:13:53 +0000 |
| Subject: | Re: Add support $object::class | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-86132@lists.php.net to get a copy of this message | ||
On 7 May 2015 at 16:04, Ralph Schindler <ralph@ralphschindler.com> wrote:
>
> 2. Illogically - Bar::class valid syntax, $object::class invalid syntax.
>>>
>>> I'll grant you the consistency argument. I'm all for consistency, but
>> that's the ONLY valid reason you've stated.
>>
>
> Even then I think this part of the argument is fairly weak. In
> Bar::class, the context of Bar is always a class name (either short due to
> do namespace or use statements, or long fully qualified).
>
> $object is not guaranteed to be an object, it could be anything (int,
> string, etc) or nothing (null). using ::class for a variable, I'd argue,
> makes for less consistency. What would the replacement be for non-object
> variables? An error, exception, or false, or string type? At least in
> "Bar::class", you'll always get a string representation of what the fully
> qualified class name resolves to.
>
Hey Ralph,
Please refer to current behavior:
http://3v4l.org/3sgLa
Marco Pivetta
http://twitter.com/Ocramius
http://ocramius.github.com/