A while ago, a RFC (Request For Comment) was created by Guilherme Blanco. He proposed extending PHP to support annotations. Annotations are available in different language such as Java, it allows adding metadata to classes, methods, variables, etc.
Here is a small transcript of the RFC.
Why do we need Class Metadata?
Frameworks in general rely on metadata information in order to correctly work. They can use it for many purposes:
- phpUnit Providing meta functionality for test cases, examples: @dataProvider for test data iteration, @expectedException for catching exceptions, etc.
- phpDoc Providing useful information for API generation, examples: @author, @param, @return, etc.
- Doctrine For Object-Relational mapping, examples: @Entity, @OneToOne, @Id, etc.
- Zend Framework Server classes Used to automate mappings for XML-RPC, SOAP, etc.
- Others One clear thing that comes to my mind is Validation, Functional Behavior injection (which could take advantage of Traits), etc. Also, any Framework could take advantage of it somehow.
So, any meta mapping injection could be easily achieved via the implementation of a centralized Annotations support. Source : http://wiki.php.net/rfc/annotations
For a full description of the RFC, please go here : http://wiki.php.net/rfc/annotations
Pierrick Charron (Core PHP Developer and Co-Founder at AlfalConsultants) has worked on a Zend Engine patch to add native Annotation support within PHP.
Patch can be downloaded from here : http://www.adoy.net/php/Annotations.diff