Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Sebastian Bergmann's Blog:
Annotations in PHP
Apr 19, 2005 @ 12:30:31

New from Sebastian Bergmann's blog today:

Yesterday someone proposed adding support for annotations to the PHP Interpreter. Although it would be nice to have this kind of functionality out-of-the-box and built into the interpreter itself this is not necessary.

I could not resist and started working on a package that exends the Reflection API of PHP 5 by adding getAnnotations(), getAnnotation($name), and hasAnnotation($name) methods to ReflectionClass, ReflectionFunction, ReflectionMethod, and ReflectionProperty.

Using a combination of the Reflection API (PHP5 only) and these suggested attributes, the simple kind of class that Sebastian has worked up could be used to "reverse engineer" a class - running the functions would grab the annotations, parse them correctly, and show the information for specific element you're looking for...

tagged:

Link:


Trending Topics: