Phalcon annotations
NOTE
All classes are prefixed with Phalcon
Annotations\Adapter\AbstractAdapter ¶
-
Namespace
Phalcon\Annotations\Adapter
-
Uses
Phalcon\Annotations\Collection
Phalcon\Annotations\Exception
Phalcon\Annotations\Reader
Phalcon\Annotations\ReaderInterface
Phalcon\Annotations\Reflection
-
Extends
-
Implements
AdapterInterface
This is the base class for Phalcon\Annotations adapters
Properties¶
Methods¶
Parses or retrieves all the annotations found in a class Returns the annotations found in a specific constant Returns the annotations found in all the class' constants Returns the annotations found in a specific method Returns the annotations found in all the class' methods Returns the annotations found in all the class' properties Returns the annotations found in a specific property Returns the annotation reader Sets the annotations parserAnnotations\Adapter\AdapterInterface ¶
-
Namespace
Phalcon\Annotations\Adapter
-
Uses
Phalcon\Annotations\Collection
Phalcon\Annotations\ReaderInterface
Phalcon\Annotations\Reflection
-
Extends
-
Implements
This interface must be implemented by adapters in Phalcon\Annotations
Methods¶
Parses or retrieves all the annotations found in a class Returns the annotations found in a specific constant Returns the annotations found in all the class' constants Returns the annotations found in a specific method Returns the annotations found in all the class' methods Returns the annotations found in all the class' methods Returns the annotations found in a specific property Returns the annotation reader Sets the annotations parserAnnotations\Adapter\Apcu¶
-
Namespace
Phalcon\Annotations\Adapter
-
Uses
Phalcon\Annotations\Reflection
-
Extends
AbstractAdapter
-
Implements
Stores the parsed annotations in APCu. This adapter is suitable for production
Properties¶
Methods¶
Reads parsed annotations from APCu Writes parsed annotations to APCuAnnotations\Adapter\Memory¶
-
Namespace
Phalcon\Annotations\Adapter
-
Uses
Phalcon\Annotations\Reflection
-
Extends
AbstractAdapter
-
Implements
Stores the parsed annotations in memory. This adapter is the suitable development/testing
Properties¶
Methods¶
Reads parsed annotations from memory Writes parsed annotations to memoryAnnotations\Adapter\Stream¶
-
Namespace
Phalcon\Annotations\Adapter
-
Uses
Phalcon\Annotations\Exception
Phalcon\Annotations\Reflection
RuntimeException
-
Extends
AbstractAdapter
-
Implements
Stores the parsed annotations in files. This adapter is suitable for production
use Phalcon\Annotations\Adapter\Stream;
$annotations = new Stream(
[
"annotationsDir" => "app/cache/annotations/",
]
);
Properties¶
Methods¶
Reads parsed annotations from files Writes parsed annotations to filesAnnotations\Annotation¶
-
Namespace
Phalcon\Annotations
-
Uses
-
Extends
-
Implements
Represents a single annotation in an annotations collection
Properties¶
/**
* Annotation Arguments
*
* @var array
*/
protected $arguments;
/**
* Annotation ExprArguments
*
* @var array
*/
protected $exprArguments;
/**
* Annotation Name
*
* @var string|null
*/
protected $name;
Methods¶
Phalcon\Annotations\Annotation constructor Returns an argument in a specific position Returns the expression arguments Returns the expression arguments without resolving Resolves an annotation expression Returns the annotation's name Returns a named argument Returns a named parameter Returns an argument in a specific position Returns the number of arguments that the annotation hasAnnotations\AnnotationsFactory¶
-
Namespace
Phalcon\Annotations
-
Uses
Phalcon\Annotations\Adapter\AdapterInterface
Phalcon\Factory\AbstractFactory
Phalcon\Support\Helper\Arr\Get
-
Extends
AbstractFactory
-
Implements
Factory to create annotations components
Methods¶
AdapterFactory constructor. Create a new instance of the adapter Returns the available adaptersAnnotations\Collection¶
-
Namespace
Phalcon\Annotations
-
Uses
Countable
Iterator
-
Extends
-
Implements
Countable
Iterator
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");
Properties¶
Methods¶
Phalcon\Annotations\Collection constructor Returns the number of annotations in the collection Returns the current annotation in the iterator Returns the first annotation that match a name Returns all the annotations that match a name Returns the internal annotations as an array Check if an annotation exists in a collection Returns the current position/key in the iterator Moves the internal iteration pointer to the next position Rewinds the internal iterator Check if the current annotation in the iterator is validAnnotations\Exception¶
-
Namespace
Phalcon\Annotations
-
Uses
-
Extends
\Exception
-
Implements
Class for exceptions thrown by Phalcon\Annotations
Annotations\Reader¶
-
Namespace
Phalcon\Annotations
-
Uses
ReflectionClass
-
Extends
-
Implements
ReaderInterface
Parses docblocks returning an array with the found annotations
Methods¶
Reads annotations from the class docblocks, its methods and/or propertiespublic static function parseDocBlock( string $docBlock, mixed $file = null, mixed $line = null ): array;
Annotations\ReaderInterface ¶
-
Namespace
Phalcon\Annotations
-
Uses
-
Extends
-
Implements
Parses docblocks returning an array with the found annotations
Methods¶
Reads annotations from the class docblocks, its constants, properties and methodspublic static function parseDocBlock( string $docBlock, mixed $file = null, mixed $line = null ): array;
Annotations\Reflection¶
-
Namespace
Phalcon\Annotations
-
Uses
-
Extends
-
Implements
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();
Properties¶
/**
* @var Collection|null
*/
protected $classAnnotations;
/**
* @var array
*/
protected $constantAnnotations;
/**
* @var array
*/
protected $propertyAnnotations;
/**
* @var array
*/
protected $methodAnnotations;
/**
* @var array
*/
protected $reflectionData;