Re: Add support $object::class

From: Date: Mon, 27 Apr 2015 17:28:57 +0000
Subject: Re: Add support $object::class
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-85971@lists.php.net to get a copy of this message
> 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

« previous php.internals (#85971) next »