class SimpleAnnotationReader implements Reader (View source)

Simple Annotation Reader.

This annotation reader is intended to be used in projects where you have full-control over all annotations that are available.

Methods

__construct()

Constructor.

void
addNamespace(string $namespace)

Adds a namespace in which we will look for annotations.

array
getClassAnnotations(ReflectionClass $class)

Gets the annotations applied to a class.

array
getMethodAnnotations(ReflectionMethod $method)

Gets the annotations applied to a method.

array
getPropertyAnnotations(ReflectionProperty $property)

Gets the annotations applied to a property.

object|null
getClassAnnotation(ReflectionClass $class, string $annotationName)

Gets a class annotation.

object|null
getMethodAnnotation(ReflectionMethod $method, string $annotationName)

Gets a method annotation.

object|null
getPropertyAnnotation(ReflectionProperty $property, string $annotationName)

Gets a property annotation.

Details

__construct()

Constructor.

Initializes a new SimpleAnnotationReader.

void addNamespace(string $namespace)

Adds a namespace in which we will look for annotations.

Parameters

string $namespace

Return Value

void

array getClassAnnotations(ReflectionClass $class)

Gets the annotations applied to a class.

Parameters

ReflectionClass $class The ReflectionClass of the class from which the class annotations should be read.

Return Value

array An array of Annotations.

array getMethodAnnotations(ReflectionMethod $method)

Gets the annotations applied to a method.

Parameters

ReflectionMethod $method The ReflectionMethod of the method from which the annotations should be read.

Return Value

array An array of Annotations.

array getPropertyAnnotations(ReflectionProperty $property)

Gets the annotations applied to a property.

Parameters

ReflectionProperty $property The ReflectionProperty of the property from which the annotations should be read.

Return Value

array An array of Annotations.

object|null getClassAnnotation(ReflectionClass $class, string $annotationName)

Gets a class annotation.

Parameters

ReflectionClass $class The ReflectionClass of the class from which the class annotations should be read.
string $annotationName The name of the annotation.

Return Value

object|null The Annotation or NULL, if the requested annotation does not exist.

object|null getMethodAnnotation(ReflectionMethod $method, string $annotationName)

Gets a method annotation.

Parameters

ReflectionMethod $method The ReflectionMethod to read the annotations from.
string $annotationName The name of the annotation.

Return Value

object|null The Annotation or NULL, if the requested annotation does not exist.

object|null getPropertyAnnotation(ReflectionProperty $property, string $annotationName)

Gets a property annotation.

Parameters

ReflectionProperty $property The ReflectionProperty to read the annotations from.
string $annotationName The name of the annotation.

Return Value

object|null The Annotation or NULL, if the requested annotation does not exist.