On 30 April 2013 16:15, Rasmus Schultz <ras...@mindplay.dk> wrote:
> At the risk of starting a separate discussion, the recently added
> ClassName::class constant provides a way to statically reference a class,
> which frankly has very few practical applications in comparison - the need
> to reference properties is usually much more prevalent and repetitive than
> the need to reference a class; assuming your classes have more than one
> property each, heh. The feature as such is also somewhat crippled, since
> what comes out of it is a string and not a class-reference.

I would caution against generalising use cases. Personally, ::class is
something I can use multiple times a day. This I'm not so sure about.

Your use case is not my use case, and vice versa. :)

> I think there is still a pretty strong case for static property-references,
> but since any new language-feature is generally a pretty hard sell around
> here, I'm letting this one go for now.

Why does this have to be a language feature? It obviously already
works in userland, as your own Symfony 2 examples show. One could
write a PropertyReference class right now with literally the only
difference being the lack of a builtin operator (ie new
PropertyReference($obj, 'prop') versus ^$obj->prop): the fact that
nobody seems to have done this in a major framework I know of suggests
that there isn't a strong need for encapsulating the indirection
beyond the $obj->$prop syntax that's worked forever.

Adam

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to