Re: [RFC] PHP Attributes

From: Date: Thu, 21 Apr 2016 23:09:31 +0000
Subject: Re: [RFC] PHP Attributes
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-92619@lists.php.net to get a copy of this message
> A more robust alternative would be something along the same lines that > Doctrine uses: Make annotations actual classes. Just spitballing here - what if both approaches were supported, but class-based annotations were prefixed with a special character (perhaps "@") to differentiate them? For example: <<ArbitraryAnnotation("Hello world")>> <<@ORM\Entity(table => "foo")>> class Foo { // ... } namespace ORM; class Entity implements \Attribute { // ... } $r = new ReflectionClass('ORM\Entity'); var_dump($r->getAttributes()); ----- array(2) { ["ArbitraryAnnotation"]=> string(11) "Hello world" ["ORM\Entity"] => object(ORM\Entity)#1 (0) { ... } } ----- Again, I'm not necessarily advocating this - just throwing the idea out there for discussion. Regards, Colin

« previous php.internals (#92619) next »