On 04/22/2016 02:09 AM, Colin O'Dell wrote:
> 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.
Current proposal doen't support this, but this may be a good idea.
1) Attribute names might be not just strings, but also namespace qualified.
2) They may be optionally prefexed by some special character.
To create or not to create attribute objects is the question for next
layer, but the base layer should provide necessary information.
Thanks. Dmitry.
Regards,
Colin