One problem remains and needs to be addressed before version 1.0 of my annotation engine - and before I start integrating this with Yii, which is my eventual goal. I was wondering if any of you might have some ideas?
Take the following example:
class Foo
{
private $values = array(
'bar' => 'hello',
// ...
);
public function __get($name)
{
return $this->values[$name];
}
}
How do you annotate the virtual member $bar ?
I thought I had addressed this problem, and the current implementation does provide a working solution, but I’ve decided I’m still not satisfied with this. It’s currently solved as follows:
/**
* @required
* @property $bar
*
* @table('name'=>'items')
*/
class Test
{
// ...
}
In this example, the @required annotation is applied to the virtual member $bar, because the @property annotation implements a "delegation" interface… annotations can delegate annotations to a virtual member property/method in this way.
Because the @required annotation precedes the @property annotation, it gets delegated to the virtual $bar member.
The extra space means nothing, it’s just there for clarity - any annotations following the @property annotation go where they normally would, in this case to the Test class.
This feature works and does solve the problem, but there is no visible syntax when you apply this feature, and this is where I see a problem.
I think I should add some kind of syntax that makes it clear which annotations get delegated - I have a feeling too many people are otherwise going to have to learn the hard way why annotations seem to "disappear" when using @var and @property etc…
I thought it might look like this:
/**
* @table('name'=>'items')
*
* @property $bar
* @@required
*/
class Test
{
// ...
}
It looks a bit odd, I guess - but it’s at least obvious that something is different here 
Perhaps better would be:
/**
* @table('name'=>'items')
*
* @property $bar {
* @required
* }
*/
class Test
{
// ...
}
Looks a bit odd too, I guess - and could collide (at least visually) with curly braces, if some annotation takes an anonymous function (closure) as argument.
Any thoughts? ideas?