Phalcon annotations
NOTE
All classes are prefixed with Phalcon
Annotations\Adapter\AbstractAdapter¶
Abstract Source on GitHub
This is the base class for Phalcon\Annotations adapters
Phalcon\Annotations\Adapter\AbstractAdapter- implementsPhalcon\Annotations\Adapter\AdapterInterface
Uses Phalcon\Annotations\Collection · Phalcon\Annotations\Exception · Phalcon\Annotations\Reader · Phalcon\Annotations\ReaderInterface · Phalcon\Annotations\Reflection
Method Summary¶
public
Reflection
get( mixed $className )
Parses or retrieves all the annotations found in a class
public
int
getAnnotationsLimit()
Returns the configured annotations-cache cap (0 = unlimited).
public
Collection
getConstant(string $className,string $constantName)
Returns the annotations found in a specific constant
public
array
getConstants( string $className )
Returns the annotations found in all the class' constants
public
Collection
getMethod(string $className,string $methodName)
Returns the annotations found in a specific method
public
array
getMethods( string $className )
Returns the annotations found in all the class' methods
public
array
getProperties( string $className )
Returns the annotations found in all the class' properties
public
Collection
getProperty(string $className,string $propertyName)
Returns the annotations found in a specific property
public
ReaderInterface
getReader()
Returns the annotation reader
public
setAnnotationsLimit( int $annotationsLimit )
Caps the number of class entries retained in the annotations
public
setReader( ReaderInterface $reader )
Sets the annotations parser
Properties¶
protected
array
$annotations = []
protected
int
$annotationsLimit = 0
Maximum number of class annotation entries retained in the
in-memory cache. 0 (default) keeps the original unbounded
behavior; a positive value clears the cache when adding a new
class would exceed it.
protected
Reader
$reader
Methods¶
get()¶
Parses or retrieves all the annotations found in a class
getAnnotationsLimit()¶
Returns the configured annotations-cache cap (0 = unlimited). See setAnnotationsLimit().
getConstant()¶
Returns the annotations found in a specific constant
getConstants()¶
Returns the annotations found in all the class' constants
getMethod()¶
Returns the annotations found in a specific method
getMethods()¶
Returns the annotations found in all the class' methods
getProperties()¶
Returns the annotations found in all the class' properties
getProperty()¶
Returns the annotations found in a specific property
getReader()¶
Returns the annotation reader
setAnnotationsLimit()¶
Caps the number of class entries retained in the annotations cache. 0 disables the cap (the default; preserves the original unbounded behavior). When the cap is exceeded, the cache is cleared and repopulated on subsequent reads.
setReader()¶
Sets the annotations parser
Annotations\Adapter\AdapterInterface¶
Interface Source on GitHub
This interface must be implemented by adapters in Phalcon\Annotations
Phalcon\Annotations\Adapter\AdapterInterface
Uses Phalcon\Annotations\Collection · Phalcon\Annotations\ReaderInterface · Phalcon\Annotations\Reflection
Method Summary¶
public
Reflection
get( string $className )
Parses or retrieves all the annotations found in a class
public
Collection
getConstant(string $className,string $constantName)
Returns the annotations found in a specific constant
public
array
getConstants( string $className )
Returns the annotations found in all the class' constants
public
Collection
getMethod(string $className,string $methodName)
Returns the annotations found in a specific method
public
array
getMethods( string $className )
Returns the annotations found in all the class' methods
public
array
getProperties( string $className )
Returns the annotations found in all the class' methods
public
Collection
getProperty(string $className,string $propertyName)
Returns the annotations found in a specific property
public
ReaderInterface
getReader()
Returns the annotation reader
public
setReader( ReaderInterface $reader )
Sets the annotations parser
Methods¶
get()¶
Parses or retrieves all the annotations found in a class
getConstant()¶
Returns the annotations found in a specific constant
getConstants()¶
Returns the annotations found in all the class' constants
getMethod()¶
Returns the annotations found in a specific method
getMethods()¶
Returns the annotations found in all the class' methods
getProperties()¶
Returns the annotations found in all the class' methods
getProperty()¶
Returns the annotations found in a specific property
getReader()¶
Returns the annotation reader
setReader()¶
Sets the annotations parser
Annotations\Adapter\Apcu¶
Class Source on GitHub
Stores the parsed annotations in APCu. This adapter is suitable for production
Phalcon\Annotations\Adapter\AbstractAdapterPhalcon\Annotations\Adapter\Apcu
Uses Phalcon\Annotations\Reflection
Method Summary¶
public
__construct( array $options = [] )
Phalcon\Annotations\Adapter\Apcu constructor
public
Reflection|bool
read( string $key )
Reads parsed annotations from APCu
public
bool
write(string $key,Reflection $data)
Writes parsed annotations to APCu
Properties¶
protected
string
$prefix = ""
protected
int
$ttl = 172800
Methods¶
__construct()¶
Phalcon\Annotations\Adapter\Apcu constructor
read()¶
Reads parsed annotations from APCu
write()¶
Writes parsed annotations to APCu
Annotations\Adapter\Memory¶
Class Source on GitHub
Stores the parsed annotations in memory. This adapter is the suitable development/testing
Phalcon\Annotations\Adapter\AbstractAdapterPhalcon\Annotations\Adapter\Memory
Uses Phalcon\Annotations\Reflection
Method Summary¶
public
__construct( array $options = [] )
public
Reflection|bool
read( string $key )
Reads parsed annotations from memory
public
void
write(string $key,Reflection $data)
Writes parsed annotations to memory
Properties¶
protected
mixed
$data
Methods¶
__construct()¶
read()¶
Reads parsed annotations from memory
write()¶
Writes parsed annotations to memory
Annotations\Adapter\Stream¶
Class Source on GitHub
Stores the parsed annotations in files. This adapter is suitable for production
use Phalcon\Annotations\Adapter\Stream;
$annotations = new Stream(
[
"annotationsDir" => "app/cache/annotations/",
]
);
Phalcon\Annotations\Adapter\AbstractAdapterPhalcon\Annotations\Adapter\Stream
Uses Phalcon\Annotations\Exception · Phalcon\Annotations\Exceptions\AnnotationsDirectoryNotWritable · Phalcon\Annotations\Exceptions\CannotReadAnnotationData · Phalcon\Annotations\Reflection · RuntimeException
Method Summary¶
public
__construct( array $options = [] )
Phalcon\Annotations\Adapter\Stream constructor
public
Reflection|bool|int
read( string $key )
Reads parsed annotations from files
public
void
write(string $key,Reflection $data)
Writes parsed annotations to files
Properties¶
protected
string
$annotationsDir = "./"
Methods¶
__construct()¶
Phalcon\Annotations\Adapter\Stream constructor
read()¶
Reads parsed annotations from files
write()¶
Writes parsed annotations to files
Annotations\Annotation¶
Class Source on GitHub
Represents a single annotation in an annotations collection
Phalcon\Annotations\Annotation
Uses Phalcon\Annotations\Exceptions\UnknownAnnotationExpression
Method Summary¶
public
__construct( array $reflectionData )
Phalcon\Annotations\Annotation constructor
public
mixed|null
getArgument( mixed $position )
Returns an argument in a specific position
public
array
getArguments()
Returns the expression arguments
public
array
getExprArguments()
Returns the expression arguments without resolving
public
mixed
getExpression( array $expr )
Resolves an annotation expression
public
null|string
getName()
Returns the annotation's name
public
mixed|null
getNamedArgument( string $name )
Returns a named argument
public
mixed
getNamedParameter( string $name )
Returns a named parameter
public
bool
hasArgument( mixed $position )
Returns an argument in a specific position
public
int
numberArguments()
Returns the number of arguments that the annotation has
Properties¶
protected
array
$arguments = []
Annotation Arguments
protected
array
$exprArguments = []
Annotation ExprArguments
protected
string|null
$name
Annotation Name
Methods¶
__construct()¶
Phalcon\Annotations\Annotation constructor
getArgument()¶
Returns an argument in a specific position
getArguments()¶
Returns the expression arguments
getExprArguments()¶
Returns the expression arguments without resolving
getExpression()¶
Resolves an annotation expression
getName()¶
Returns the annotation's name
getNamedArgument()¶
Returns a named argument
getNamedParameter()¶
Returns a named parameter
hasArgument()¶
Returns an argument in a specific position
numberArguments()¶
Returns the number of arguments that the annotation has
Annotations\AnnotationsFactory¶
Class Source on GitHub
Factory to create annotations components
Phalcon\Factory\AbstractConfigFactoryPhalcon\Factory\AbstractFactoryPhalcon\Annotations\AnnotationsFactory
Uses Phalcon\Annotations\Adapter\AdapterInterface · Phalcon\Factory\AbstractFactory · Phalcon\Support\Helper\Arr\Get
Method Summary¶
public
__construct( array $services = [] )
AdapterFactory constructor.
public
mixed
load( mixed $config )
Factory to create an instance from a Config object
public
AdapterInterface
newInstance(string $name,array $options = [])
Create a new instance of the adapter
protected
string
getExceptionClass()
protected
array
getServices()
Returns the available adapters
Methods¶
__construct()¶
AdapterFactory constructor.
load()¶
Factory to create an instance from a Config object
newInstance()¶
Create a new instance of the adapter
getExceptionClass()¶
getServices()¶
Returns the available adapters
Annotations\Collection¶
Class Source on GitHub
Represents a collection of annotations. This class allows to traverse a group of annotations easily
// Traverse annotations
foreach ($classAnnotations as $annotation) {
echo "Name=", $annotation->getName(), PHP_EOL;
}
// Check if the annotations has a specific
var_dump($classAnnotations->has("Cacheable"));
// Get an specific annotation in the collection
$annotation = $classAnnotations->get("Cacheable");
Phalcon\Annotations\Collection- implementsIterator,Countable
Uses Countable · Iterator · Phalcon\Annotations\Exceptions\AnnotationNotFound
Method Summary¶
public
__construct( array $reflectionData = [] )
Phalcon\Annotations\Collection constructor
public
int
count()
Returns the number of annotations in the collection
public
mixed
current()
Returns the current annotation in the iterator
public
Annotation
get( string $name )
Returns the first annotation that match a name
public
Annotation[]
getAll( string $name )
Returns all the annotations that match a name
public
Annotation[]
getAnnotations()
Returns the internal annotations as an array
public
bool
has( string $name )
Check if an annotation exists in a collection
public
int
key()
Returns the current position/key in the iterator
public
void
next()
Moves the internal iteration pointer to the next position
public
void
rewind()
Rewinds the internal iterator
public
bool
valid()
Check if the current annotation in the iterator is valid
Properties¶
protected
array
$annotations
protected
int
$position = 0
Methods¶
__construct()¶
Phalcon\Annotations\Collection constructor
count()¶
Returns the number of annotations in the collection
current()¶
Returns the current annotation in the iterator
get()¶
Returns the first annotation that match a name
getAll()¶
Returns all the annotations that match a name
getAnnotations()¶
Returns the internal annotations as an array
has()¶
Check if an annotation exists in a collection
key()¶
Returns the current position/key in the iterator
next()¶
Moves the internal iteration pointer to the next position
rewind()¶
Rewinds the internal iterator
valid()¶
Check if the current annotation in the iterator is valid
Annotations\Exception¶
Class Source on GitHub
Class for exceptions thrown by Phalcon\Annotations
\Exception
Annotations\Exceptions\AnnotationNotFound¶
Class Source on GitHub
\ExceptionPhalcon\Annotations\ExceptionPhalcon\Annotations\Exceptions\AnnotationNotFound
Uses Phalcon\Annotations\Exception
Method Summary¶
Methods¶
__construct()¶
Annotations\Exceptions\AnnotationsDirectoryNotWritable¶
Class Source on GitHub
\ExceptionPhalcon\Annotations\ExceptionPhalcon\Annotations\Exceptions\AnnotationsDirectoryNotWritable
Uses Phalcon\Annotations\Exception
Method Summary¶
Methods¶
__construct()¶
Annotations\Exceptions\CannotReadAnnotationData¶
Class Source on GitHub
RuntimeExceptionPhalcon\Annotations\Exceptions\CannotReadAnnotationData
Uses RuntimeException
Method Summary¶
Methods¶
__construct()¶
Annotations\Exceptions\UnknownAnnotationExpression¶
Class Source on GitHub
\ExceptionPhalcon\Annotations\ExceptionPhalcon\Annotations\Exceptions\UnknownAnnotationExpression
Uses Phalcon\Annotations\Exception
Method Summary¶
Methods¶
__construct()¶
Annotations\Reader¶
Class Source on GitHub
Parses docblocks returning an array with the found annotations
Phalcon\Annotations\Reader- implementsPhalcon\Annotations\ReaderInterface
Uses ReflectionClass
Method Summary¶
public
array
parse( string $className )
Reads annotations from the class docblocks, its methods and/or properties
public
array
parseDocBlock(string $docBlock,mixed $file = null,mixed $line = null)
Parses a raw doc block returning the annotations found
Methods¶
parse()¶
Reads annotations from the class docblocks, its methods and/or properties
parseDocBlock()¶
public static function parseDocBlock(
string $docBlock,
mixed $file = null,
mixed $line = null
): array;
Parses a raw doc block returning the annotations found
Annotations\ReaderInterface¶
Interface Source on GitHub
Parses docblocks returning an array with the found annotations
Phalcon\Annotations\ReaderInterface
Method Summary¶
public
array
parse( string $className )
Reads annotations from the class docblocks, its constants, properties and methods
public
array
parseDocBlock(string $docBlock,mixed $file = null,mixed $line = null)
Parses a raw docblock returning the annotations found
Methods¶
parse()¶
Reads annotations from the class docblocks, its constants, properties and methods
parseDocBlock()¶
public static function parseDocBlock(
string $docBlock,
mixed $file = null,
mixed $line = null
): array;
Parses a raw docblock returning the annotations found
Annotations\Reflection¶
Class Source on GitHub
Allows to manipulate the annotations reflection in an OO manner
use Phalcon\Annotations\Reader;
use Phalcon\Annotations\Reflection;
// Parse the annotations in a class
$reader = new Reader();
$parsing = $reader->parse("MyComponent");
// Create the reflection
$reflection = new Reflection($parsing);
// Get the annotations in the class docblock
$classAnnotations = $reflection->getClassAnnotations();
Phalcon\Annotations\Reflection
Method Summary¶
public
__construct( array $reflectionData = [] )
public
Collection|null
getClassAnnotations()
Returns the annotations found in the class docblock
public
Collection[]
getConstantsAnnotations()
Returns the annotations found in the constants' docblocks
public
Collection[]
getMethodsAnnotations()
Returns the annotations found in the methods' docblocks
public
Collection[]
getPropertiesAnnotations()
Returns the annotations found in the properties' docblocks
public
array
getReflectionData()
Returns the raw parsing intermediate definitions used to construct the
Properties¶
protected
Collection|null
$classAnnotations = null
protected
array
$constantAnnotations = []
protected
array
$methodAnnotations = []
protected
array
$propertyAnnotations = []
protected
array
$reflectionData = []
Methods¶
__construct()¶
getClassAnnotations()¶
Returns the annotations found in the class docblock
getConstantsAnnotations()¶
Returns the annotations found in the constants' docblocks
getMethodsAnnotations()¶
Returns the annotations found in the methods' docblocks
getPropertiesAnnotations()¶
Returns the annotations found in the properties' docblocks
getReflectionData()¶
Returns the raw parsing intermediate definitions used to construct the reflection