With Doctrine annotation processing engine for PHP, and Annotatons being used for Doctrine Entities and for Zend Form, and possibly other things, and use in other languages as well, it looks like Annotations
are here to stay.
Example Annotations for Zend Form:
/**
* @Annotation\Filter({"name":"StringTrim"})
* @Annotation\Validator({"name":"StringLength", "options":{"min":1, "max":24}})
* @Annotation\Validator({"name":"Regex","options":{"pattern":"/^[a-zA-Z][a-zA-Z0-9_-]{0,24}$/"}})
* @Annotation\Attributes({"type":"text"})
* @Annotation\Options({"label":"Username:"})
* @Annotation\ErrorMessage("Invalid Username")
*/
public $username;
AnnotationBuilder
class with the help of the processing engine will go on to build a Zend Form for me, according to the specs. Alternative ways to doing so are available via Zend\Form classes and methods.
Concerns
I notice that Annotations are basically comments, and are not subject to verification by the interpreter or a compiler, and that is part of my concern. If some syntax changes, there is no error message, and nothing immediately detectable that needs to be fixed.
You could think that mistyping a property will raise an error somewhere, but no - trying to alter some of the Annotation directives, does not issue a warning, but defaults are assumed. As such, typing up an Annotation you do not get the feedback about any syntax of semantic errors.
Question
When other ways are available (classes, methods, api, arrays), which could be statically and dynamically checked, is it detrimental to code quality and maintenance to use Annotations?