Skip to content

Phalcon Annotations

Updated View as Markdown

Annotations\AdapterFactory

ClassSource on GitHub

Factory to create Annotations adapters

@property SerializerFactory $serializerFactory

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\Factory\AbstractFactory · Phalcon\Storage\SerializerFactory

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

InterfaceSource on GitHub

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

Uses Phalcon\Storage\Adapter\AdapterInterface

Annotations\Adapter\Apcu

ClassSource 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

ClassSource 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

ClassSource 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

ClassSource 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

ClassSource 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

ClassSource 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

ClassSource 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

stringCACHE_PREFIX = "_PHATN"

Properties

protectedAdapterInterface$adapter
protectedarray$attributes = []
protectedReader|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

ClassSource on GitHub
  • Phalcon\Annotations\Models\MetaData\Column

Uses Attribute

Method Summary

Properties

publicbool$allowEmptyString = false
publicstring|null$column = null
publicmixed$default = null
publicint|null$length = null
publicbool$nullable = false
publicbool$skipOnInsert = false
publicbool$skipOnUpdate = false
publicstring$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

ClassSource on GitHub
  • Phalcon\Annotations\Models\MetaData\Identity

Uses Attribute

Annotations\Models\MetaData\Primary

ClassSource on GitHub
  • Phalcon\Annotations\Models\MetaData\Primary

Uses Attribute

Annotations\Models\MetaData\Source

ClassSource on GitHub
  • Phalcon\Annotations\Models\MetaData\Source

Uses Attribute

Method Summary

Properties

publicstring$table

Methods

Public · 1

__construct()

public function __construct( string $table );

Annotations\Parser\Annotation

ClassSource on GitHub

Represents a single attribute in an attributes collection

  • Phalcon\Annotations\Parser\Annotation

Uses ReflectionAttribute

Method Summary

Properties

protectedarray$arguments = []

Attribute Arguments

protectedstring$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

ClassSource 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

protectedarray$annotations
protectedint$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

ClassSource on GitHub

Class for exceptions thrown by Phalcon\Annotations

  • \Exception
    • Phalcon\Annotations\Parser\Exception

Annotations\Parser\Reader

ClassSource 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

InterfaceSource 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

ClassSource 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

protectedCollection|null$classAnnotations = null
protectedarray$constantAnnotations = []
protectedarray$methodAnnotations = []
protectedarray$propertyAnnotations = []
protectedarray$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

ClassSource on GitHub

Uses Attribute · Phalcon\Http\Message\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );

Annotations\Router\Delete

ClassSource on GitHub

Uses Attribute · Phalcon\Http\Message\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );

Annotations\Router\Get

ClassSource on GitHub

Uses Attribute · Phalcon\Http\Message\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );

Annotations\Router\Head

ClassSource on GitHub

Uses Attribute · Phalcon\Http\Message\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );

Annotations\Router\Options

ClassSource on GitHub

Uses Attribute · Phalcon\Http\Message\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );

Annotations\Router\Patch

ClassSource on GitHub

Uses Attribute · Phalcon\Http\Message\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );

Annotations\Router\Post

ClassSource on GitHub

Uses Attribute · Phalcon\Http\Message\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );

Annotations\Router\Purge

ClassSource on GitHub

Uses Attribute · Phalcon\Http\Message\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );

Annotations\Router\Put

ClassSource on GitHub

Uses Attribute · Phalcon\Http\Message\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );

Annotations\Router\Route

ClassSource on GitHub

Uses Attribute · Phalcon\Http\Message\RequestMethodInterface

Method Summary

Properties

publicarray|string|null$beforeMatch = null
publicarray$converters = []
publicarray|string$methods = [...]
publicstring|null$name = null
publicarray$paths = []
publicstring$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

ClassSource on GitHub
  • Phalcon\Annotations\Router\RoutePrefix

Uses Attribute

Method Summary

Properties

publicstring$prefix

Methods

Public · 1

__construct()

public function __construct( string $prefix );

Annotations\Router\Trace

ClassSource on GitHub

Uses Attribute · Phalcon\Http\Message\RequestMethodInterface

Method Summary

Methods

Public · 1

__construct()

public function __construct( mixed $params );
Navigation

Type to search…

↑↓ navigate↵ selectEsc close