nextras / orm

Orm with clean object design, smart relationship loading and powerful collections.
https://nextras.org/orm
MIT License
310 stars 57 forks source link

Default enum annotation constants class to self #109

Closed Mikulas closed 9 years ago

Mikulas commented 9 years ago
/*
 * @property string $state {enum STATE_*}
 * @property string $state {enum self::STATE_*}
 */

The first one throws Undefined offset: 1 as it's not supported by Entity/Reflection/AnnotationParser. The second one is ok but too verbose.

I wrote this by accident knowing it's not supproted. But it looks pretty good and is kind of intuitive. Since the * wildcard is magical in itself, this could be a handy addition.

Should I send a pull request or are there other complications?

JanTvrdik commented 9 years ago

I like the current syntax more. self::CONSTANT is also supported in {default ...}

hrach commented 9 years ago

Currently, it's implemented as parseLiteral function (https://github.com/nextras/orm/blob/8f6954949205362d770c87e4959f8ce6491c2f28/src/Entity/Reflection/AnnotationParser.php#L439-L469), but AnnotationParser will be radically refactored and such functionality will be shared for other macros too. Also, after implementing #106 (follow up #107) I want to be more strict and do not add more magic. The magic brings also complexity for https://github.com/nextras/orm-intellij which I'm trying to develop :)

hrach commented 9 years ago

So, closing. Thanks for understanding.