annotations icon indicating copy to clipboard operation
annotations copied to clipboard

Support for annotation in class constant docBlock

Open matthieu88160 opened this issue 3 years ago • 5 comments

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.

matthieu88160 avatar Mar 17 '21 10:03 matthieu88160

Out of curiosity, what use case would you have for this in your company?

greg0ire avatar Mar 17 '21 18:03 greg0ire

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.

matthieu88160 avatar Mar 17 '21 19:03 matthieu88160

Funny, I just saw this: https://twitter.com/PHPRFCBot/status/1372252058028449797

greg0ire avatar Mar 17 '21 19:03 greg0ire

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.

matthieu88160 avatar Mar 18 '21 09:03 matthieu88160

I was not implying it at all that it wouldn't be worth it, don't worry ;)

greg0ire avatar Mar 18 '21 10:03 greg0ire

Closing because we won't add new features to this library.

derrabus avatar Oct 05 '22 22:10 derrabus