This project aims to add native support for Annotations in PHP.
Native support for Annotations in PHP
You will find all informations on this patch on the PHP Annotation's RFC.
Short example :
<?php
[Inherited]
class Foo extends ReflectionAnnotation {}
class Bar extends ReflectionAnnotation {}
[Foo]
[Bar]
class A {}
class B extends A {}
When you attempt to retrieve the defined information for classes A and B, you get:
<?php
$reflClassA = new ReflectionClass('A');
var_dump($reflClassA->getAnnotations());
/*
array(2) {
["Foo"]=>
object(Foo)#%d (1) {
["value"]=>NULL
},
["Bar"]=>
object(Bar)#%d (1) {
["value"]=>NULL
}
}
*/
$reflClassB = new ReflectionClass('B');
var_dump($reflClassB->getAnnotations());
/*
array(2) {
["Foo"]=>
object(Foo)#%d (1) {
["value"]=>NULL
}
}
*/
Download
| Patch and tests | Annotations.diff |
Details
State : Dev
Current version : -
Release Date : Sep, 2010
Techno : C / Zend Engine / Bison / Flex
License : Zend Engine License, version 2.00
WebSite : https://wiki.php.net/rfc/annotations