> On 5 Nov 2014, at 14:02, Marco Pivetta <ocram...@gmail.com> wrote: > > I'm not sure if we need that sort of syntax and opinionated approach: I like > Benjamin's approach better, and it is also simpler and still very easy to use > even in our context (doctrine). > > For example, this alternative approach perfectly fits the current > doctrine/annotations use-case: > > use Doctrine\ORM\Mapping\Entity; > use Doctrine\ORM\Mapping\Table; > use Doctrine\ORM\Mapping\Id; > use Doctrine\ORM\Mapping\GeneratedValue; > use Doctrine\ORM\Mapping\Column; > > [Entity::class => []] > [Table::class => ['name' => 'foo_table']] > class Foo > { > [Id::class => []] > [GeneratedValue::class => [GeneratedValue::UUID]] > [Column::class => ['name' => 'bar_column', 'type' => 'string']] > private $bar; > } > > I did nothing special here, just using plain old associative arrays and > built-in `::class` pseudo-constants: this leaves space for libraries that do > want to use annotations, but not the way doctrine/annotations does it > (calling the constructor of an annotation), and the annotations themselves > can still decide what to do with nested values. > > No autoloading is going on, no code execution, nothing: plain and simple > arrays which may as well be used for phpdocumentor as well, if needed.
If we don’t get Python-style decorators, this would be my favourite approach after that. It’s super-simple, and does no more, and no less, than it needs to. -- Andrea Faulds http://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php