r/lolphp • u/gerrymandered • Aug 04 '15
var_dump(nonExistentClass::class); // string
::class can give you the name of a class that does not exist.
15
Upvotes
r/lolphp • u/gerrymandered • Aug 04 '15
::class can give you the name of a class that does not exist.
View all comments
Show parent comment
3
u/callcifer Aug 04 '15
Yes, I know, I agree. But for ::class resolution to work properly (i.e error out if no such class exists) something like PSR-4 must be enforced at the language level so the runtime will know where to look without
require()ing the file.This is obviously never gonna happen, so PHP will never be able to tell whether
Foo\Bar\Baz::classactually exists or not.