Class Is A Valid Type¶
PHP allows to use \class as a class name in a type. This is also the case for interfaces, enums, traits… and it is also valid for some others keywords.
On the other hand, a good number of PHP keywords are forbidden, and yield an error : \self is an invalid class name.
Of course, once this is typed like that, it is not possible to satisfy the type specification, and such code is actually not usable.
See Also¶
Can type class, cannot type self [Try me]