Hey everybody,
I've been following this list for a while (1-2 years) and this is the
first message I'm sending.
In my oppinion, annotations in docblocks are a bit(a lot) hacky and
making it even worse by adding them to core is not the best idea.
This is how I think annotations have to look like if implemented in
core (I've taken on of the annotation classes in Doctrine and
transformed it).
Declaration:
namespace Doctrine\ORM\Mapping;
use SplAnnotation, SplAnnotationInterface;
@Target({'PROPERTY', 'ANNOTATION'})
class JoinColumn implements SplAnnotation
{
@SplAnnotation\String
private $name;
@SplAnnotation\Boolean
private $unique;
@SplAnnotation\Mixed
private $onDelete;
@SplAnnotation\String
private $referencedColumn = 'id';
}
Usage:
<?php
use Lib\Mapping\ORM as ORM;
@ORM\Table()
@ORM\Entity()
class User {
@ORM\Column(name="name", type="string")
private $name;
@ORM\OneToMany(targetEntity="Group", mappedBy="user")
@ORM\JoinColumn(onDelete="CASCADE")
private $groups;
}
Of course the syntax and interfaces are just an example for you to get
the concept.
I'm not very familiar with the internals of the language, so if this
is hard(not really possible) to implement, just ignore it.
However, I think that parsing annotations as a part of the syntax of
the language would be much faster (and less of a mess) and reliable
than
parsing strings in docblocks.
Bottomline, my idea is:
A native syntax outside docblocks that doesn't suck :)
Cheers,
Vladislav