Skip to content

Phalcon annotations

NOTE

All classes are prefixed with Phalcon

Annotations\AdapterFactory

Class Source on GitHub

Factory to create Annotations adapters

@property SerializerFactory $serializerFactory

  • Phalcon\Annotations\AdapterFactory

Uses Exception · Phalcon\Annotations\Adapter\AdapterInterface · Phalcon\Annotations\Adapter\Apcu · Phalcon\Annotations\Adapter\Libmemcached · Phalcon\Annotations\Adapter\Memory · Phalcon\Annotations\Adapter\Redis · Phalcon\Annotations\Adapter\Stream · Phalcon\Annotations\Adapter\Weak · Phalcon\Annotations\Parser\Exception · Phalcon\Storage\SerializerFactory · Phalcon\Traits\Factory\FactoryTrait

Method Summary

Methods

Public · 2

__construct()

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

AdapterFactory constructor.

newInstance()

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

Create a new instance of the adapter

Protected · 2

getExceptionClass()

protected function getExceptionClass(): string;

getServices()

protected function getServices(): array;

Returns the available adapters

Annotations\Adapter\AdapterInterface

Interface Source on GitHub

This interface must be implemented by adapters in Phalcon\Components\Attributes

Uses Phalcon\Storage\Adapter\AdapterInterface

Annotations\Adapter\Apcu

Class Source on GitHub

Stores the parsed annotations in apcu.

Uses Phalcon\Annotations\Parser\Reflection · Phalcon\Storage\Adapter\Apcu

Method Summary

Methods

Public · 1

get()

public function get(
    string $key,
    mixed $defaultValue = null
): mixed;

Annotations\Adapter\Libmemcached

Class Source on GitHub

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

Uses Phalcon\Annotations\Parser\Reflection · Phalcon\Storage\Adapter\Libmemcached

Method Summary

Methods

Public · 1

get()

public function get(
    string $key,
    mixed $defaultValue = null
): mixed;

Annotations\Adapter\Memory

Class Source on GitHub

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

Uses Phalcon\Annotations\Parser\Reflection · Phalcon\Storage\Adapter\Memory

Method Summary

Methods

Public · 1

get()

public function get(
    string $key,
    mixed $defaultValue = null
): mixed;

Annotations\Adapter\Redis

Class Source on GitHub

Stores the parsed annotations in redis.

Uses Phalcon\Annotations\Parser\Reflection · Phalcon\Storage\Adapter\Redis

Method Summary

Methods

Public · 1

get()

public function get(
    string $key,
    mixed $defaultValue = null
): mixed;

Annotations\Adapter\Stream

Class Source on GitHub

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

Uses Phalcon\Annotations\Parser\Reflection · Phalcon\Storage\Adapter\Stream

Method Summary

Methods

Public · 1

get()

public function get(
    string $key,
    mixed $defaultValue = null
): mixed;

Annotations\Adapter\Weak

Class Source on GitHub

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

Uses Phalcon\Annotations\Parser\Reflection · Phalcon\Storage\Adapter\Weak

Method Summary

Methods

Public · 1

get()

public function get(
    string $key,
    mixed $defaultValue = null
): mixed;

Annotations\Annotations

Class Source on GitHub

  • Phalcon\Annotations\Annotations

Uses Phalcon\Annotations\Parser\Collection · Phalcon\Annotations\Parser\Reader · Phalcon\Annotations\Parser\ReaderInterface · Phalcon\Annotations\Parser\Reflection · Phalcon\Storage\Adapter\AdapterInterface

Method Summary

Constants

string CACHE_PREFIX = "_PHATN"

Properties

protected AdapterInterface $adapter
protected array $attributes = []
protected Reader|null $reader = null

Methods

Public · 12

__construct()

public function __construct( AdapterInterface $adapter );

get()

public function get( mixed $className ): Reflection;

Parses or retrieves all the attributes found in a class

getConstant()

public function getConstant(
    string $className,
    string $constantName
): Collection;

Returns the attributes found in a specific constant

getConstants()

public function getConstants( string $className ): array;

Returns the attributes found in all the class' constants

getMethod()

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

Returns the attributes found in a specific method

getMethods()

public function getMethods( string $className ): array;

Returns the attributes found in all the class' methods

getProperties()

public function getProperties( string $className ): array;

Returns the attributes found in all the class' properties

getProperty()

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

Returns the attributes found in a specific property

getReader()

public function getReader(): ReaderInterface;

Returns the annotation reader

read()

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

Reads parsed annotations from memory

setReader()

public function setReader( ReaderInterface $reader ): void;

Sets the attributes parser

write()

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

Writes parsed annotations to memory

Annotations\Models\MetaData\Column

Class Source on GitHub

  • Phalcon\Annotations\Models\MetaData\Column

Uses Attribute

Method Summary

Properties

public bool $allowEmptyString = false
public string|null $column = null
public mixed $default = null
public int|null $length = null
public bool $nullable = false
public bool $skipOnInsert = false
public bool $skipOnUpdate = false
public string $type = "string"

Methods

Public · 1

__construct()

public function __construct(
    string|null $column = null,
    string $type = "string",
    int|null $length = null,
    bool $nullable = false,
    bool $skipOnInsert = false,
    bool $skipOnUpdate = false,
    bool $allowEmptyString = false,
    mixed $default = null
);

Annotations\Models\MetaData\Identity

Class Source on GitHub

  • Phalcon\Annotations\Models\MetaData\Identity

Uses Attribute

Annotations\Models\MetaData\Primary

Class Source on GitHub

  • Phalcon\Annotations\Models\MetaData\Primary

Uses Attribute

Annotations\Models\MetaData\Source

Class Source on GitHub

  • Phalcon\Annotations\Models\MetaData\Source

Uses Attribute

Method Summary

Properties

public string $table

Methods

Public · 1

__construct()

public function __construct( string $table );

Annotations\Parser\Annotation

Class Source on GitHub

Represents a single attribute in an attributes collection

  • Phalcon\Annotations\Parser\Annotation

Uses ReflectionAttribute

Method Summary

Properties

protected array $arguments = [] Attribute Arguments
protected string $name Attribute Name

Methods

Public · 9

__construct()

public function __construct( ReflectionAttribute $reflectionData );

Constructor

getArgument()

public function getArgument( int|string $position ): mixed;

Returns an argument in a specific position

getArguments()

public function getArguments(): array;

Returns the expression arguments

getCleanName()

public function getCleanName(): string;

Returns the attribute's base name

getName()

public function getName(): string;

Returns the attribute's name

getNamedArgument()

public function getNamedArgument( string $name ): mixed;

Returns a named argument

getNamedParameter()

public function getNamedParameter( string $name ): mixed;

Returns a named parameter

hasArgument()

public function hasArgument( int|string $position ): bool;

Returns an argument in a specific position

numberArguments()

public function numberArguments(): int;

Returns the number of arguments that the attribute has

Annotations\Parser\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");

@template TKey of int
@template TValue of Annotation
  • Phalcon\Annotations\Parser\Collection - implements \IteratorAggregate

Uses ArrayIterator · IteratorAggregate · Traversable

Method Summary

Properties

protected array $annotations
protected int $position = 0

Methods

Public · 6

__construct()

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

Constructor

get()

public function get( string $name ): Annotation;

Returns the first annotation that match a name

getAll()

public function getAll( string $name ): array;

Returns all the annotations that match a name

getAnnotations()

public function getAnnotations(): Traversable;

getIterator()

public function getIterator(): Traversable;

has()

public function has( string $name ): bool;

Check if an annotation exists in a collection

Annotations\Parser\Exception

Class Source on GitHub

Class for exceptions thrown by Phalcon\Annotations

  • \Exception
    • Phalcon\Annotations\Parser\Exception

Annotations\Parser\Reader

Class Source on GitHub

Parses classes returning an array with the found annotations

Uses ReflectionClass · ReflectionException

Method Summary

Methods

Public · 1

parse()

public function parse( string $className ): array;

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

Annotations\Parser\ReaderInterface

Interface Source on GitHub

Parses attributes returning an array with the found attributes

  • Phalcon\Annotations\Parser\ReaderInterface

Method Summary

Methods

Public · 1

parse()

public function parse( string $className ): array;

Reads attributes from the class, properties and methods

Annotations\Parser\Reflection

Class Source on GitHub

Allows to manipulate the annotations reflection in an OO manner

use Phalcon\Components\Annotations\Reader;
use Phalcon\Components\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 from the class
$classAnnotations = $reflection->getClassAnnotations();
  • Phalcon\Annotations\Parser\Reflection

Method Summary

Properties

protected Collection|null $classAnnotations = null
protected array $constantAnnotations = []
protected array $methodAnnotations = []
protected array $propertyAnnotations = []
protected array $reflectionData = []

Methods

Public · 6

__construct()

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

Constructor

getClassAnnotations()

public function getClassAnnotations(): Collection|null;

Returns the annotations found in the class docblock

getConstantsAnnotations()

public function getConstantsAnnotations(): array;

Returns the annotations found as constants

getMethodsAnnotations()

public function getMethodsAnnotations(): array;

Returns the annotations found at methods

getPropertiesAnnotations()

public function getPropertiesAnnotations(): array;

Returns the annotations found at properties

getReflectionData()

public function getReflectionData(): array;

Returns the raw parsing intermediate definitions used to construct the reflection

Annotations\Router\Connect

Class Source on GitHub

Uses Attribute · Phalcon\Http\Message\Interfaces\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );

Annotations\Router\Delete

Class Source on GitHub

Uses Attribute · Phalcon\Http\Message\Interfaces\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );

Annotations\Router\Get

Class Source on GitHub

Uses Attribute · Phalcon\Http\Message\Interfaces\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );

Annotations\Router\Head

Class Source on GitHub

Uses Attribute · Phalcon\Http\Message\Interfaces\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );

Annotations\Router\Options

Class Source on GitHub

Uses Attribute · Phalcon\Http\Message\Interfaces\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );

Annotations\Router\Patch

Class Source on GitHub

Uses Attribute · Phalcon\Http\Message\Interfaces\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );

Annotations\Router\Post

Class Source on GitHub

Uses Attribute · Phalcon\Http\Message\Interfaces\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );

Annotations\Router\Purge

Class Source on GitHub

Uses Attribute · Phalcon\Http\Message\Interfaces\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );

Annotations\Router\Put

Class Source on GitHub

Uses Attribute · Phalcon\Http\Message\Interfaces\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );

Annotations\Router\Route

Class Source on GitHub

Uses Attribute · Phalcon\Http\Message\Interfaces\RequestMethodInterface

Method Summary

Properties

public array|string|null $beforeMatch = null
public array $converters = []
public array|string $methods = [...]
public string|null $name = null
public array $paths = []
public string $route

Methods

Public · 1

__construct()

public function __construct(
    string $route,
    array|string $methods = [...],
    string|null $name = null,
    array $paths = [],
    array $converters = [],
    array|string|null $beforeMatch = null
);

Annotations\Router\RoutePrefix

Class Source on GitHub

  • Phalcon\Annotations\Router\RoutePrefix

Uses Attribute

Method Summary

Properties

public string $prefix

Methods

Public · 1

__construct()

public function __construct( string $prefix );

Annotations\Router\Trace

Class Source on GitHub

Uses Attribute · Phalcon\Http\Message\Interfaces\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );