Re: Is there an RFC/discussion for ::class being a specific type?

From: Date: Tue, 16 Nov 2021 17:34:14 +0000
Subject: Re: Is there an RFC/discussion for ::class being a specific type?
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-116421@lists.php.net to get a copy of this message
Interesting, but what would such a type actually be? How would PHP check the type? What would be the rules? At the moment, ::class is just a preprocessor macro. It is not part of the runtime. It also doesn't mean the name of the class. It just means "textual representation of the value on the left". For example, this is valid: echo "string"::class; You can use ::class on almost anything that the compiler would treat as a string literal. In the end, it will be compiled down to a string. It is handy to think of ::class as ::text or ::name. I don't think we could enforce class type without actually asking PHP to check if class exists. You can use static analysers for this (see class-string), but I doubt it will be possible in PHP.

« previous php.internals (#116421) next »