Annotations\Adapter\AbstractAdapter
AbstractSource on GitHubThis 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
publicReflectionget( mixed$className )Parses or retrieves all the annotations found in a classpublicintgetAnnotationsLimit()Returns the configured annotations-cache cap (0 = unlimited).publicCollectiongetConstant(string$className,string$constantName)Returns the annotations found in a specific constantpublicarraygetConstants( string$className )Returns the annotations found in all the class' constantspublicCollectiongetMethod(string$className,string$methodName)Returns the annotations found in a specific methodpublicarraygetMethods( string$className )Returns the annotations found in all the class' methodspublicarraygetProperties( string$className )Returns the annotations found in all the class' propertiespublicCollectiongetProperty(string$className,string$propertyName)Returns the annotations found in a specific propertypublicReaderInterfacegetReader()Returns the annotation readerpublicsetAnnotationsLimit( int$annotationsLimit )Caps the number of class entries retained in the annotationspublicsetReader( ReaderInterface$reader )Sets the annotations parserProperties
protectedarray$annotations = []protectedint$annotationsLimit = 0Maximum 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.protectedReader$readerMethods
get()
public function get( mixed $className ): Reflection;Parses or retrieves all the annotations found in a class
getAnnotationsLimit()
public function getAnnotationsLimit(): int;Returns the configured annotations-cache cap (0 = unlimited). See setAnnotationsLimit().
getConstant()
public function getConstant(
string $className,
string $constantName
): Collection;Returns the annotations found in a specific constant
getConstants()
public function getConstants( string $className ): array;Returns the annotations found in all the class’ constants
getMethod()
public function getMethod(
string $className,
string $methodName
): Collection;Returns the annotations found in a specific method
getMethods()
public function getMethods( string $className ): array;Returns the annotations found in all the class’ methods
getProperties()
public function getProperties( string $className ): array;Returns the annotations found in all the class’ properties
getProperty()
public function getProperty(
string $className,
string $propertyName
): Collection;Returns the annotations found in a specific property
getReader()
public function getReader(): ReaderInterface;Returns the annotation reader
setAnnotationsLimit()
public function setAnnotationsLimit( int $annotationsLimit );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()
public function setReader( ReaderInterface $reader );Sets the annotations parser
Annotations\Adapter\AdapterInterface
InterfaceSource on GitHubThis 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
publicReflectionget( string$className )Parses or retrieves all the annotations found in a classpublicCollectiongetConstant(string$className,string$constantName)Returns the annotations found in a specific constantpublicarraygetConstants( string$className )Returns the annotations found in all the class' constantspublicCollectiongetMethod(string$className,string$methodName)Returns the annotations found in a specific methodpublicarraygetMethods( string$className )Returns the annotations found in all the class' methodspublicarraygetProperties( string$className )Returns the annotations found in all the class' methodspublicCollectiongetProperty(string$className,string$propertyName)Returns the annotations found in a specific propertypublicReaderInterfacegetReader()Returns the annotation readerpublicsetReader( ReaderInterface$reader )Sets the annotations parserMethods
get()
public function get( string $className ): Reflection;Parses or retrieves all the annotations found in a class
getConstant()
public function getConstant(
string $className,
string $constantName
): Collection;Returns the annotations found in a specific constant
getConstants()
public function getConstants( string $className ): array;Returns the annotations found in all the class’ constants
getMethod()
public function getMethod(
string $className,
string $methodName
): Collection;Returns the annotations found in a specific method
getMethods()
public function getMethods( string $className ): array;Returns the annotations found in all the class’ methods
getProperties()
public function getProperties( string $className ): array;Returns the annotations found in all the class’ methods
getProperty()
public function getProperty(
string $className,
string $propertyName
): Collection;Returns the annotations found in a specific property
getReader()
public function getReader(): ReaderInterface;Returns the annotation reader
setReader()
public function setReader( ReaderInterface $reader );Sets the annotations parser
Annotations\Adapter\Apcu
ClassSource on GitHubStores the parsed annotations in APCu. This adapter is suitable for production
use Phalcon\Annotations\Adapter\Apcu;
$annotations = new Apcu();Phalcon\Annotations\Adapter\AbstractAdapterPhalcon\Annotations\Adapter\Apcu
Uses Phalcon\Annotations\Reflection
Method Summary
public__construct( array$options = [] )Phalcon\Annotations\Adapter\Apcu constructorpublicReflection|boolread( string$key )Reads parsed annotations from APCupublicboolwrite(string$key,Reflection$data)Writes parsed annotations to APCuProperties
protectedstring$prefix = ""protectedint$ttl = 172800Methods
__construct()
public function __construct( array $options = [] );Phalcon\Annotations\Adapter\Apcu constructor
read()
public function read( string $key ): Reflection|bool;Reads parsed annotations from APCu
write()
public function write(
string $key,
Reflection $data
): bool;Writes parsed annotations to APCu
Annotations\Adapter\Memory
ClassSource on GitHubStores 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 = [] )publicReflection|boolread( string$key )Reads parsed annotations from memorypublicvoidwrite(string$key,Reflection$data)Writes parsed annotations to memoryProperties
protectedmixed$dataMethods
__construct()
public function __construct( array $options = [] );read()
public function read( string $key ): Reflection|bool;Reads parsed annotations from memory
write()
public function write(
string $key,
Reflection $data
): void;Writes parsed annotations to memory
Annotations\Adapter\Stream
ClassSource on GitHubStores 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 · Phalcon\Traits\Php\FileTrait · RuntimeException
Method Summary
public__construct( array$options = [] )Phalcon\Annotations\Adapter\Stream constructorpublicReflection|bool|intread( string$key )Reads parsed annotations from filespublicvoidwrite(string$key,Reflection$data)Writes parsed annotations to filesProperties
protectedstring$annotationsDir = "./"Methods
__construct()
public function __construct( array $options = [] );Phalcon\Annotations\Adapter\Stream constructor
read()
public function read( string $key ): Reflection|bool|int;Reads parsed annotations from files
write()
public function write(
string $key,
Reflection $data
): void;Writes parsed annotations to files
Annotations\Annotation
ClassSource on GitHubRepresents a single annotation in an annotations collection
Phalcon\Annotations\Annotation
Uses Phalcon\Annotations\Exceptions\UnknownAnnotationExpression
Method Summary
public__construct( array$reflectionData )Phalcon\Annotations\Annotation constructorpublicmixed|nullgetArgument( mixed$position )Returns an argument in a specific positionpublicarraygetArguments()Returns the expression argumentspublicarraygetExprArguments()Returns the expression arguments without resolvingpublicmixedgetExpression( array$expr )Resolves an annotation expressionpublicnull|stringgetName()Returns the annotation's namepublicmixed|nullgetNamedArgument( string$name )Returns a named argumentpublicmixedgetNamedParameter( string$name )Returns a named parameterpublicboolhasArgument( mixed$position )Returns an argument in a specific positionpublicintnumberArguments()Returns the number of arguments that the annotation hasProperties
protectedarray$arguments = []Annotation Argumentsprotectedarray$exprArguments = []Annotation ExprArgumentsprotectedstring|null$nameAnnotation NameMethods
__construct()
public function __construct( array $reflectionData );Phalcon\Annotations\Annotation constructor
getArgument()
public function getArgument( mixed $position ): mixed|null;Returns an argument in a specific position
getArguments()
public function getArguments(): array;Returns the expression arguments
getExprArguments()
public function getExprArguments(): array;Returns the expression arguments without resolving
getExpression()
public function getExpression( array $expr ): mixed;Resolves an annotation expression
getName()
public function getName(): null|string;Returns the annotation’s name
getNamedArgument()
public function getNamedArgument( string $name ): mixed|null;Returns a named argument
getNamedParameter()
public function getNamedParameter( string $name ): mixed;Returns a named parameter
hasArgument()
public function hasArgument( mixed $position ): bool;Returns an argument in a specific position
numberArguments()
public function numberArguments(): int;Returns the number of arguments that the annotation has
Annotations\AnnotationsFactory
ClassSource on GitHubFactory to create annotations components
Phalcon\Factory\AbstractConfigFactoryPhalcon\Factory\AbstractFactoryPhalcon\Annotations\AnnotationsFactory
Uses Phalcon\Annotations\Adapter\AdapterInterface · Phalcon\Annotations\Adapter\Apcu · Phalcon\Annotations\Adapter\Memory · Phalcon\Annotations\Adapter\Stream · Phalcon\Factory\AbstractFactory · Phalcon\Traits\Support\Helper\Arr\GetTrait
Method Summary
public__construct( array$services = [] )AdapterFactory constructor.publicmixedload( mixed$config )Factory to create an instance from a Config objectpublicAdapterInterfacenewInstance(string$name,array$options = [])Create a new instance of the adapterprotectedstringgetExceptionClass()protectedarraygetServices()Returns the available adaptersMethods
__construct()
public function __construct( array $services = [] );AdapterFactory constructor.
load()
public function load( mixed $config ): mixed;Factory to create an instance from a Config object
newInstance()
public function newInstance(
string $name,
array $options = []
): AdapterInterface;Create a new instance of the adapter
getExceptionClass()
protected function getExceptionClass(): string;getServices()
protected function getServices(): array;Returns the available adapters
Annotations\Collection
ClassSource on GitHubRepresents 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- implements\Iterator,\Countable
Uses Countable · Iterator · Phalcon\Annotations\Exceptions\AnnotationNotFound
Method Summary
public__construct( array$reflectionData = [] )Phalcon\Annotations\Collection constructorpublicintcount()Returns the number of annotations in the collectionpublicmixedcurrent()Returns the current annotation in the iteratorpublicAnnotationget( string$name )Returns the first annotation that match a namepublicAnnotation[]getAll( string$name )Returns all the annotations that match a namepublicAnnotation[]getAnnotations()Returns the internal annotations as an arraypublicboolhas( string$name )Check if an annotation exists in a collectionpublicintkey()Returns the current position/key in the iteratorpublicvoidnext()Moves the internal iteration pointer to the next positionpublicvoidrewind()Rewinds the internal iteratorpublicboolvalid()Check if the current annotation in the iterator is validProperties
protectedarray$annotationsprotectedint$position = 0Methods
__construct()
public function __construct( array $reflectionData = [] );Phalcon\Annotations\Collection constructor
count()
public function count(): int;Returns the number of annotations in the collection
current()
public function current(): mixed;Returns the current annotation in the iterator
get()
public function get( string $name ): Annotation;Returns the first annotation that match a name
getAll()
public function getAll( string $name ): Annotation[];Returns all the annotations that match a name
getAnnotations()
public function getAnnotations(): Annotation[];Returns the internal annotations as an array
has()
public function has( string $name ): bool;Check if an annotation exists in a collection
key()
public function key(): int;Returns the current position/key in the iterator
next()
public function next(): void;Moves the internal iteration pointer to the next position
rewind()
public function rewind(): void;Rewinds the internal iterator
valid()
public function valid(): bool;Check if the current annotation in the iterator is valid
Annotations\Exception
ClassSource on GitHubClass for exceptions thrown by Phalcon\Annotations
\Exception
Annotations\Exceptions\AnnotationNotFound
ClassSource on GitHub\ExceptionPhalcon\Annotations\ExceptionPhalcon\Annotations\Exceptions\AnnotationNotFound
Uses Phalcon\Annotations\Exception
Method Summary
Methods
__construct()
public function __construct( string $name );Annotations\Exceptions\AnnotationsDirectoryNotWritable
ClassSource on GitHub\ExceptionPhalcon\Annotations\ExceptionPhalcon\Annotations\Exceptions\AnnotationsDirectoryNotWritable
Uses Phalcon\Annotations\Exception
Method Summary
Methods
__construct()
public function __construct();Annotations\Exceptions\CannotReadAnnotationData
ClassSource on GitHub\RuntimeExceptionPhalcon\Annotations\Exceptions\CannotReadAnnotationData
Uses RuntimeException
Method Summary
Methods
__construct()
public function __construct();Annotations\Exceptions\UnknownAnnotationExpression
ClassSource on GitHub\ExceptionPhalcon\Annotations\ExceptionPhalcon\Annotations\Exceptions\UnknownAnnotationExpression
Uses Phalcon\Annotations\Exception
Method Summary
Methods
__construct()
public function __construct( string $type );Annotations\Reader
ClassSource on GitHubParses docblocks returning an array with the found annotations
Phalcon\Annotations\Reader- implementsPhalcon\Annotations\ReaderInterface
Uses ReflectionClass
Method Summary
publicarrayparse( string$className )Reads annotations from the class docblocks, its methods and/or propertiespublicarrayparseDocBlock(string$docBlock,mixed$file = null,mixed$line = null)Parses a raw doc block returning the annotations foundMethods
parse()
public function parse( string $className ): array;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
InterfaceSource on GitHubParses docblocks returning an array with the found annotations
Phalcon\Annotations\ReaderInterface
Method Summary
publicarrayparse( string$className )Reads annotations from the class docblocks, its constants, properties and methodspublicarrayparseDocBlock(string$docBlock,mixed$file = null,mixed$line = null)Parses a raw docblock returning the annotations foundMethods
parse()
public function parse( string $className ): array;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
ClassSource on GitHubAllows 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 = [] )publicCollection|nullgetClassAnnotations()Returns the annotations found in the class docblockpublicCollection[]getConstantsAnnotations()Returns the annotations found in the constants' docblockspublicCollection[]getMethodsAnnotations()Returns the annotations found in the methods' docblockspublicCollection[]getPropertiesAnnotations()Returns the annotations found in the properties' docblockspublicarraygetReflectionData()Returns the raw parsing intermediate definitions used to construct theProperties
protectedCollection|null$classAnnotations = nullprotectedarray$constantAnnotations = []protectedarray$methodAnnotations = []protectedarray$propertyAnnotations = []protectedarray$reflectionData = []Methods
__construct()
public function __construct( array $reflectionData = [] );getClassAnnotations()
public function getClassAnnotations(): Collection|null;Returns the annotations found in the class docblock
getConstantsAnnotations()
public function getConstantsAnnotations(): Collection[];Returns the annotations found in the constants’ docblocks
getMethodsAnnotations()
public function getMethodsAnnotations(): Collection[];Returns the annotations found in the methods’ docblocks
getPropertiesAnnotations()
public function getPropertiesAnnotations(): Collection[];Returns the annotations found in the properties’ docblocks
getReflectionData()
public function getReflectionData(): array;Returns the raw parsing intermediate definitions used to construct the reflection