annotations
annotations copied to clipboard
Support for annotation in class constant docBlock
Hello all,
Doctrine annotations library allows to parse annotations from lots of class members but seems to miss the class constants from the reader scope. Even if the runtime usage of class constant annotations will not be widely used, it could be a nice addition to the current features, and an actual use case for me and my company.
By the way, I propose to add two new methods in the Reader interface:
-
public function getConstantAnnotations(ReflectionClassConstant $constant);
-
public function getConstantAnnotation(ReflectionClassConstant $constant, $annotationName);
As ReflectionClassConstant
is part of PHP since version 7.1
it fit with current doctrine/annotations requirements.
Out of curiosity, what use case would you have for this in your company?
Working on a system to sync classes between multiple language, driven by PHP as main development language. Our principal use case is to generate Enums from class/interface constants. We are using annotations to control generation behaviors.
Funny, I just saw this: https://twitter.com/PHPRFCBot/status/1372252058028449797
Funny, I just saw this: https://twitter.com/PHPRFCBot/status/1372252058028449797
😄 Such a great feature. Enums are just an example case, constants still fit well for internal class configuration constant even if Enums are implemented.
I was not implying it at all that it wouldn't be worth it, don't worry ;)
Closing because we won't add new features to this library.