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