Sections

Abstract Class Phalcon\Annotations\Adapter\AbstractAdapter

Código fuente en GitHub

Namespace Phalcon\Annotations\Adapter   Uses Phalcon\Annotations\Adapter\AdapterInterface, Phalcon\Annotations\Reader, Phalcon\Annotations\Exception, Phalcon\Annotations\Collection, Phalcon\Annotations\Reflection, Phalcon\Annotations\ReaderInterface   Implements AdapterInterface

This is the base class for Phalcon\Annotations adapters

Properties

/**
 * @var array
 */
protected annotations;

/**
 * @var Reader
 */
protected reader;

Métodos

public function get( mixed $className ): Reflection;

Parses or retrieves all the annotations found in a class

public function getMethod( string $className, string $methodName ): Collection;

Returns the annotations found in a specific method

public function getMethods( string $className ): array;

Returns the annotations found in all the class’ methods

public function getProperties( string $className ): array;

Returns the annotations found in all the class’ methods

public function getProperty( string $className, string $propertyName ): Collection;

Returns the annotations found in a specific property

public function getReader(): ReaderInterface;

Returns the annotation reader

public function setReader( ReaderInterface $reader );

Sets the annotations parser

Interface Phalcon\Annotations\Adapter\AdapterInterface

Código fuente en GitHub

Namespace Phalcon\Annotations\Adapter   Uses Phalcon\Annotations\Reflection, Phalcon\Annotations\Collection, Phalcon\Annotations\ReaderInterface

This interface must be implemented by adapters in Phalcon\Annotations

Métodos

public function get( string $className ): Reflection;

Parses or retrieves all the annotations found in a class

public function getMethod( string $className, string $methodName ): Collection;

Returns the annotations found in a specific method

public function getMethods( string $className ): array;

Returns the annotations found in all the class’ methods

public function getProperties( string $className ): array;

Returns the annotations found in all the class’ methods

public function getProperty( string $className, string $propertyName ): Collection;

Returns the annotations found in a specific property

public function getReader(): ReaderInterface;

Returns the annotation reader

public function setReader( ReaderInterface $reader );

Sets the annotations parser

Class Phalcon\Annotations\Adapter\Apcu

Código fuente en GitHub

Namespace Phalcon\Annotations\Adapter   Uses Phalcon\Annotations\Adapter\AbstractAdapter, Phalcon\Annotations\Reflection   Extends AbstractAdapter

Stores the parsed annotations in APCu. This adapter is suitable for production

use Phalcon\Annotations\Adapter\Apcu;

$annotations = new Apcu();

Properties

/**
 * @var string
 */
protected prefix = ;

/**
 * @var int
 */
protected ttl = 172800;

Métodos

public function __construct( array $options = [] ): void;

Phalcon\Annotations\Adapter\Apcu constructor

public function read( string $key ): Reflection | bool;

Reads parsed annotations from APCu

public function write( string $key, Reflection $data ): bool;

Writes parsed annotations to APCu

Class Phalcon\Annotations\Adapter\Memory

Código fuente en GitHub

Namespace Phalcon\Annotations\Adapter   Uses Phalcon\Annotations\Adapter\AbstractAdapter, Phalcon\Annotations\Reflection   Extends AbstractAdapter

Stores the parsed annotations in memory. This adapter is the suitable development/testing

Properties

/**
 * @var mixed
 */
protected data;

Métodos

public function read( string $key ): Reflection | bool;

Reads parsed annotations from memory

public function write( string $key, Reflection $data ): void;

Writes parsed annotations to memory

Class Phalcon\Annotations\Adapter\Stream

Código fuente en GitHub

Namespace Phalcon\Annotations\Adapter   Uses Phalcon\Annotations\Adapter\AbstractAdapter, Phalcon\Annotations\Reflection, Phalcon\Annotations\Exception   Extends AbstractAdapter

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

/**
 * @var string
 */
protected annotationsDir = ./;

Métodos

public function __construct( array $options = [] ): void;

Phalcon\Annotations\Adapter\Stream constructor

public function read( string $key ): Reflection | bool | int;

Reads parsed annotations from files

public function write( string $key, Reflection $data ): void;

Writes parsed annotations to files

Class Phalcon\Annotations\Annotation

Código fuente en GitHub

Namespace Phalcon\Annotations   Uses Phalcon\Annotations\Annotation, Phalcon\Annotations\Exception

Represents a single annotation in an annotations collection

Properties

/**
 * Annotation Arguments
 *
 * @var array
 */
protected arguments;

/**
 * Annotation ExprArguments
 *
 * @var string
 */
protected exprArguments;

/**
 * Annotation Name
 *
 * @var string
 */
protected name;

Métodos

public function __construct( array $reflectionData ): void;

Phalcon\Annotations\Annotation constructor

public function getArgument( mixed $position );

Returns an argument in a specific position

public function getArguments(): array;

Returns the expression arguments

public function getExprArguments(): array;

Returns the expression arguments without resolving

public function getExpression( array $expr ): mixed;

Resolves an annotation expression

public function getName(): string;

Returns the annotation’s name

public function getNamedArgument( string $name );

Returns a named argument

public function getNamedParameter( string $name ): mixed;

Returns a named parameter

public function hasArgument( mixed $position ): bool;

Returns an argument in a specific position

public function numberArguments(): int;

Returns the number of arguments that the annotation has

Class Phalcon\Annotations\AnnotationsFactory

Código fuente en GitHub

Namespace Phalcon\Annotations   Uses Phalcon\Annotations\Adapter\AbstractAdapter, Phalcon\Factory\AbstractFactory, Phalcon\Helper\Arr   Extends AbstractFactory

Factory to create annotations components

Métodos

public function __construct( array $services = [] );

AdapterFactory constructor.

public function load( mixed $config ): mixed;

Factory to create an instace from a Config object

public function newInstance( string $name, array $options = [] ): AbstractAdapter;

Create a new instance of the adapter

protected function getAdapters(): array;

The available adapters

Class Phalcon\Annotations\Collection

Código fuente en GitHub

Namespace Phalcon\Annotations   Uses Countable, Iterator, Phalcon\Annotations\Annotation, Phalcon\Annotations\Exception   Implements Iterator, Countable

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

/**
 * @var array
 */
protected annotations;

/**
 * @var int
 */
protected position = 0;

Métodos

public function __construct( array $reflectionData = [] ): void;

Phalcon\Annotations\Collection constructor

public function count(): int;

Returns the number of annotations in the collection

public function current(): Annotation | bool;

Returns the current annotation in the iterator

public function get( string $name ): Annotation;

Returns the first annotation that match a name

public function getAll( string $name ): Annotation[];

Returns all the annotations that match a name

public function getAnnotations(): Annotation[];

Returns the internal annotations as an array

public function has( string $name ): bool;

Check if an annotation exists in a collection

public function key(): int;

Devuelve la llave/posición actual del iterador

public function next(): void;

Mueve el puntero interno de iteración a la siguiente posición

public function rewind(): void;

Rebobina el iterador interno

public function valid(): bool;

Check if the current annotation in the iterator is valid

Class Phalcon\Annotations\Exception

Código fuente en GitHub

Namespace Phalcon\Annotations   Extends \Phalcon\Exception

Class for exceptions thrown by Phalcon\Annotations

Class Phalcon\Annotations\Reader

Código fuente en GitHub

Namespace Phalcon\Annotations   Uses Phalcon\Annotations\ReaderInterface, ReflectionClass   Implements ReaderInterface

Parses docblocks returning an array with the found annotations

Métodos

public function parse( string $className ): array;

Reads annotations from the class docblocks, its methods and/or properties

public static function parseDocBlock( string $docBlock, mixed $file = null, mixed $line = null ): array;

Parses a raw doc block returning the annotations found

Interface Phalcon\Annotations\ReaderInterface

Código fuente en GitHub

Namespace Phalcon\Annotations

Parses docblocks returning an array with the found annotations

Métodos

public function parse( string $className ): array;

Reads annotations from the class docblocks, its methods and/or properties

public static function parseDocBlock( string $docBlock, mixed $file = null, mixed $line = null ): array;

Parses a raw docblock returning the annotations found

Class Phalcon\Annotations\Reflection

Código fuente en GitHub

Namespace Phalcon\Annotations   Uses Phalcon\Annotations\Collection

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

//
protected classAnnotations;

//
protected methodAnnotations;

//
protected propertyAnnotations;

/**
 * @var array
 */
protected reflectionData;

Métodos

public function __construct( array $reflectionData = [] ): void;

Phalcon\Annotations\Reflection constructor

public function getClassAnnotations(): Collection | bool;

Returns the annotations found in the class docblock

public function getMethodsAnnotations(): Collection[] | bool;

Returns the annotations found in the methods’ docblocks

public function getPropertiesAnnotations(): Collection[] | bool;

Returns the annotations found in the properties’ docblocks

public function getReflectionData(): array;

Returns the raw parsing intermediate definitions used to construct the reflection