Maybe I'm missing something but now that you said it's kind of a macro, I think
it would actually be pretty easy to implement, at least when not taking
backwards compatibility or performance into account:
class ClassName {
private $name;
function __construct(string $name) {
$this->name = $name;
}
function__toString()
{
return $name;
}
}
Then make the preprocessor convert Foo::class into `new ClassName(Foo::class)`.
Done. Now you can type hint a function like this:
class DiContainer {
function get(ClassName $klass) {
// ...
}
}
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php