On Thu, Jan 9, 2020 at 9:49 PM Nicolas Grekas <nicolas.grekas+...@gmail.com>
wrote:

>
> >      $fooClass = Foo::class;
>> >      echo $foo::class; // TypeError b/c string?
>>
>> Yes, at least per the current proposal. Whether to allow this is listed as
>> an open question.
>>
>
> I missed that part!
>
> If it could return `string`, that'd be super useful!
> We have tons of lines of code that look like: is_object($foo) ?
> get_class($foo) : gettype($foo)
> Getting rid of them would be very sweet !
>
> Nicolas
>

That's not how it would work, if it were allowed. $string::class would just
return $string, to be consistent with usual behavior of "::CONST_NAME",
which allows objects and class names on the left hand side.

I think it would be pretty nice to have a function for the use case you
mention though, as this is indeed very common for error messages.

Nikita

Reply via email to