<?php
use Doctrine\Common\Annotations\AnnotationReader;
interface Foo
{
/**
* @MyAnnotation(defaultValue="bar")
*/
public function bar();
}
/**
* @Annotation
*/
class MyAnnotation
{
public $defaultValue;
}
$ref = new ReflectionClass('Foo');
$method = $ref->getMethod('bar');
$parser = new AnnotationReader();
// or getPropertyAnnotations to get all annotations of a property
$myAnnotation = $parser
->getMethodAnnotation($method, 'MyAnnotation');
echo $myAnnotation->defaultValue;