Documentation

AnnotationProcessor
in package
implements Middleware

Processes the annotations that are in the PHPDoc comments

Interfaces, Classes, Traits and Enums

Middleware

Table of Contents

$annotationClasses  : array<string|int, string>
$annotations  : array<string|int, array<string|int, Annotation>>
$namespaces  : array<string|int, string>
add()  : mixed
Adds an annotation for processing
addNamespace()  : mixed
Adds a namespace
run()  : mixed
Creates the annotations then processes all interfaces in the App or those that are in the given namespaces.
createAnnotationsPerType()  : void
Creates the annotation instances and puts them into the right `$annotations` array
isProcessAllowed()  : bool
If no namespace added returns true, otherwise checks the namespace and returns true if the interface is in it.
process()  : void
Processes one class with the given name
processAll()  : void
Processes all interfaces in the App or those are in the given namespaces
processClass()  : void
Processes all class type annotations for the class
processMethods()  : void
Processes all method type annotations for all the methods of a class
processProperties()  : void
Processes all property type annotations for all the properties of a class
processSubject()  : mixed
Processes a class, property or a method annotation

Properties

$annotations

protected array<string|int, array<string|int, Annotation>> $annotations = [\Dynart\Micro\Annotation::TYPE_CLASS => [], \Dynart\Micro\Annotation::TYPE_PROPERTY => [], \Dynart\Micro\Annotation::TYPE_METHOD => []]

Methods

add()

Adds an annotation for processing

public add(string $className) : mixed

The given class name should implement the Annotation interface, otherwise it will throw an MicroException.

Parameters
$className : string

The class name

Tags
throws
MicroException

if the given class does not implement the Annotation

Return values
mixed

addNamespace()

Adds a namespace

public addNamespace(string $namespace) : mixed

If one or more namespace added only those will be processed. The namespace should NOT start with a backslash!

Parameters
$namespace : string
Return values
mixed

run()

Creates the annotations then processes all interfaces in the App or those that are in the given namespaces.

public run() : mixed
Return values
mixed

createAnnotationsPerType()

Creates the annotation instances and puts them into the right `$annotations` array

protected createAnnotationsPerType() : void
Return values
void

isProcessAllowed()

If no namespace added returns true, otherwise checks the namespace and returns true if the interface is in it.

protected isProcessAllowed(string $className) : bool
Parameters
$className : string

The name of the class

Return values
bool

Should we process this class?

process()

Processes one class with the given name

protected process(string $className) : void
Parameters
$className : string

The name of the class

Return values
void

processAll()

Processes all interfaces in the App or those are in the given namespaces

protected processAll() : void
Return values
void

processClass()

Processes all class type annotations for the class

protected processClass( $refClass) : void
Parameters
$refClass :
Return values
void

processMethods()

Processes all method type annotations for all the methods of a class

protected processMethods( $refClass) : void
Parameters
$refClass :
Return values
void

processProperties()

Processes all property type annotations for all the properties of a class

protected processProperties( $refClass) : void
Parameters
$refClass :
Return values
void

processSubject()

Processes a class, property or a method annotation

protected processSubject(Annotation $annotation, string $type, string $className, ReflectionClass|ReflectionProperty|ReflectionMethod $subject) : mixed

Gets the PHPDoc comment from the subject, search for the annotation name in it. If the annotation name present does the regular expression search and calls the Annotation::process() with the results.

Parameters
$annotation : Annotation

The annotation

$type : string

The type of the annotation

$className : string

The class name

$subject : ReflectionClass|ReflectionProperty|ReflectionMethod

The reflection class, property or method

Return values
mixed

Search results