You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think the behavior is intentional. On one hand, ::class is basically accessing a class constant, so generally that can be done on the class name string, regardless of given as literal or variable. However, ::class is resolved during compile time, so supporting variables is generally impossible.
And while I don't see any value in supporting a class name string here, not supporting it would be some arbitrary restriction. Furthermore, changing that would constitute a BC break.
It seems the 'Foo'::class syntax was supported even before https://wiki.php.net/rfc/class_name_literal_on_object. That RFC does mention specifically that dynamic strings aren't allowed, so this seems to be a documentation issue.
Description
This doesn't work (https://3v4l.org/MM1pJ):
But this does (https://3v4l.org/Rb3oU)
Is this intentional? I'd say both or neither should be supported.
PHP Version
Irrelevant
Operating System
N/A
The text was updated successfully, but these errors were encountered: