Sections

Abstract Class Phalcon\Annotations\Adapter\AbstractAdapter

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;

メソッド

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

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

メソッド

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

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;

メソッド

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

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;

メソッド

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

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 = ./;

メソッド

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

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;

メソッド

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

GitHub上のソース

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

Factory to create annotations components

メソッド

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

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;

メソッド

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;

イテレータ中の現在の位置/キーを返します。

public function next(): void;

内部のイテレータの位置を次の位置に移動します。

public function rewind(): void;

内部のイテレータを巻き戻します。

public function valid(): bool;

Check if the current annotation in the iterator is valid

Class Phalcon\Annotations\Exception

GitHub上のソース

Namespace Phalcon\Annotations   Extends \Phalcon\Exception

Class for exceptions thrown by Phalcon\Annotations

Class Phalcon\Annotations\Reader

GitHub上のソース

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

Parses docblocks returning an array with the found annotations

メソッド

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

GitHub上のソース

Namespace Phalcon\Annotations

Parses docblocks returning an array with the found annotations

メソッド

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

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;

メソッド

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