Documentation

CachedReader
in package
implements Reader

A cache aware annotation reader.

Tags
author

Johannes M. Schmitt schmittjoh@gmail.com

author

Benjamin Eberlei kontakt@beberlei.de

Interfaces, Classes and Traits

Reader
Interface for annotation readers.

Table of Contents

$cache  : Cache
$debug  : bool
$delegate  : Reader
$loadedAnnotations  : array<string|int, mixed>
__construct()  : mixed
Constructor.
clearLoadedAnnotations()  : void
Clears loaded annotations.
getClassAnnotation()  : object|null
Gets a class annotation.
getClassAnnotations()  : array<string|int, mixed>
Gets the annotations applied to a class.
getMethodAnnotation()  : object|null
Gets a method annotation.
getMethodAnnotations()  : array<string|int, mixed>
Gets the annotations applied to a method.
getPropertyAnnotation()  : object|null
Gets a property annotation.
getPropertyAnnotations()  : array<string|int, mixed>
Gets the annotations applied to a property.
fetchFromCache()  : mixed
Fetches a value from the cache.
getLastModification()  : int
Returns the time the class was last modified, testing traits and parents
getTraitLastModificationTime()  : int
isCacheFresh()  : bool
Checks if the cache is fresh.
saveToCache()  : void
Saves a value to the cache.

Properties

$loadedAnnotations

private array<string|int, mixed> $loadedAnnotations = array()

Methods

__construct()

Constructor.

public __construct(Reader $reader, Cache $cache[, bool $debug = false ]) : mixed
Parameters
$reader : Reader
$cache : Cache
$debug : bool = false
Return values
mixed —

clearLoadedAnnotations()

Clears loaded annotations.

public clearLoadedAnnotations() : void
Return values
void —

getClassAnnotation()

Gets a class annotation.

public getClassAnnotation(ReflectionClass $class, mixed $annotationName) : object|null
Parameters
$class : ReflectionClass

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

$annotationName : mixed

The name of the annotation.

Return values
object|null —

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

getClassAnnotations()

Gets the annotations applied to a class.

public getClassAnnotations(ReflectionClass $class) : array<string|int, mixed>
Parameters
$class : ReflectionClass

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

Return values
array<string|int, mixed> —

An array of Annotations.

getMethodAnnotation()

Gets a method annotation.

public getMethodAnnotation(ReflectionMethod $method, mixed $annotationName) : object|null
Parameters
$method : ReflectionMethod

The ReflectionMethod to read the annotations from.

$annotationName : mixed

The name of the annotation.

Return values
object|null —

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

getMethodAnnotations()

Gets the annotations applied to a method.

public getMethodAnnotations(ReflectionMethod $method) : array<string|int, mixed>
Parameters
$method : ReflectionMethod

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

Return values
array<string|int, mixed> —

An array of Annotations.

getPropertyAnnotation()

Gets a property annotation.

public getPropertyAnnotation(ReflectionProperty $property, mixed $annotationName) : object|null
Parameters
$property : ReflectionProperty

The ReflectionProperty to read the annotations from.

$annotationName : mixed

The name of the annotation.

Return values
object|null —

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

getPropertyAnnotations()

Gets the annotations applied to a property.

public getPropertyAnnotations(ReflectionProperty $property) : array<string|int, mixed>
Parameters
$property : ReflectionProperty

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

Return values
array<string|int, mixed> —

An array of Annotations.

fetchFromCache()

Fetches a value from the cache.

private fetchFromCache(string $cacheKey, ReflectionClass $class) : mixed
Parameters
$cacheKey : string

The cache key.

$class : ReflectionClass

The related class.

Return values
mixed —

The cached value or false when the value is not in cache.

getLastModification()

Returns the time the class was last modified, testing traits and parents

private getLastModification(ReflectionClass $class) : int
Parameters
$class : ReflectionClass
Return values
int —

getTraitLastModificationTime()

private getTraitLastModificationTime(ReflectionClass $reflectionTrait) : int
Parameters
$reflectionTrait : ReflectionClass
Return values
int —

isCacheFresh()

Checks if the cache is fresh.

private isCacheFresh(string $cacheKey, ReflectionClass $class) : bool
Parameters
$cacheKey : string
$class : ReflectionClass
Return values
bool —

saveToCache()

Saves a value to the cache.

private saveToCache(string $cacheKey, mixed $value) : void
Parameters
$cacheKey : string

The cache key.

$value : mixed

The value.

Return values
void —

Search results