Introducing JSON support for annotations. This allows annotating objects with JSON configuration without need to convert it to PHP array syntax. Additionally new syntax can be mixed with old one. Adding support for JSON is backwards compatible, as in previous version such syntax would throw exception.
Example of annotation with JSON syntax
Notice the unquoted key. It is possible to use unquoted values, but risky to some extend.
Creating annotation class read
from begining to learn about
Having addendum configured, let's create annotation class. This
will allow us to use
@ notation on our project
classes. As each annotation is in fact class, which has some
simple logic to set up metadata container. This container will be
used to obtain values configured by annotations. Please not that
this values might be different than raw values on
notations. As value returned by meta container is solely
dependent on values set by annotation definition.
This way, we have opportunity to set initial logic in annotation,
thus having already prepared and cached values returned by
metadata container. To obtain access to container for currently
process class, there
getEntity is method in
annotation. This returns container instance, which can be
configured with any property required.