> Why not? > > Seriously, why not? ::class was added because there was no easy way to > get from the symbol class name to the string representation of it (you > couldn't pass it to a function, etc since it would look like a > constant). So ::class is a purely compile time construct to turn a > literal classname into a string representation. > > However, if you have a variable, there already is a way to do that at > runtime: get_class. What's the problem with that where we need to > further support arbitrary syntax? > > Note: I'm not saying we shouldn't add support. I'm just saying that > it's not the same situation as with Bar::class...
1. get_class($object) - looks bad and long 2. Illogically - Bar::class valid syntax, $object::class invalid syntax. 3. Function call get_class($object) is slower -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php