Skip to content

Phalcon contracts

NOTE

All classes are prefixed with Phalcon

Contracts\Db\Adapter\Adapter Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Db\Adapter
  • Uses

    • Phalcon\Db\ColumnInterface
    • Phalcon\Db\DialectInterface
    • Phalcon\Db\IndexInterface
    • Phalcon\Db\RawValue
    • Phalcon\Db\ReferenceInterface
    • Phalcon\Db\ResultInterface
  • Extends

  • Implements

Canonical contract for Phalcon\Db adapters.

@todo v7 — these will become required interface members. They are omitted from the v5 line to avoid breaking third-party implementors: - addCheck() : bool - createMaterializedView() : bool - dropCheck() : bool - dropMaterializedView() : bool - onConflictUpdate() : string - refreshMaterializedView() : bool - returning() : string

Methods

public function addColumn( string $tableName, string $schemaName, ColumnInterface $column ): bool;
Adds a column to a table

public function addForeignKey( string $tableName, string $schemaName, ReferenceInterface $reference ): bool;
Adds a foreign key to a table

public function addIndex( string $tableName, string $schemaName, IndexInterface $index ): bool;
Adds an index to a table

public function addPrimaryKey( string $tableName, string $schemaName, IndexInterface $index ): bool;
Adds a primary key to a table

public function affectedRows(): int;
Returns the number of affected rows by the last INSERT/UPDATE/DELETE reported by the database system

public function begin( bool $nesting = bool ): bool;
Starts a transaction in the connection

public function close(): void;
Closes active connection returning success. Phalcon automatically closes and destroys active connections within Phalcon\Db\Pool

public function commit( bool $nesting = bool ): bool;
Commits the active transaction in the connection

public function connect( array $descriptor = [] ): void;
This method is automatically called in \Phalcon\Db\Adapter\Pdo constructor. Call it when you need to restore a database connection

public function createSavepoint( string $name ): bool;
Creates a new savepoint

public function createTable( string $tableName, string $schemaName, array $definition ): bool;
Creates a table

public function createView( string $viewName, array $definition, string $schemaName = null ): bool;
Creates a view

public function delete( mixed $table, string $whereCondition = null, array $placeholders = [], array $dataTypes = [] ): bool;
Deletes data from a table using custom RDBMS SQL syntax

public function describeColumns( string $table, string $schema = null ): ColumnInterface[];
Returns an array of Phalcon\Db\Column objects describing a table

public function describeIndexes( string $table, string $schema = null ): IndexInterface[];
Lists table indexes

public function describeReferences( string $table, string $schema = null ): ReferenceInterface[];
Lists table references

public function dropColumn( string $tableName, string $schemaName, string $columnName ): bool;
Drops a column from a table

public function dropForeignKey( string $tableName, string $schemaName, string $referenceName ): bool;
Drops a foreign key from a table

public function dropIndex( string $tableName, string $schemaName, string $indexName ): bool;
Drop an index from a table

public function dropPrimaryKey( string $tableName, string $schemaName ): bool;
Drops primary key from a table

public function dropTable( string $tableName, string $schemaName = null, bool $ifExists = bool ): bool;
Drops a table from a schema/database

public function dropView( string $viewName, string $schemaName = null, bool $ifExists = bool ): bool;
Drops a view

public function escapeIdentifier( mixed $identifier ): string;
Escapes a column/table/schema name

public function escapeString( string $str ): string;
Escapes a value to avoid SQL injections

public function execute( string $sqlStatement, array $bindParams = [], array $bindTypes = [] ): bool;
Sends SQL statements to the database server returning the success state. Use this method only when the SQL statement sent to the server does not return any rows

public function fetchAll( string $sqlQuery, int $fetchMode = int, array $bindParams = [], array $bindTypes = [] ): array;
Dumps the complete result of a query into an array

public function fetchColumn( string $sqlQuery, array $placeholders = [], mixed $column = int ): string | bool;
Returns the n'th field of first row in a SQL query result

// Getting count of robots
$robotsCount = $connection->fetchColumn("SELECT COUNT(*) FROM robots");
print_r($robotsCount);

// Getting name of last edited robot
$robot = $connection->fetchColumn(
    "SELECT id, name FROM robots ORDER BY modified DESC",
    1
);
print_r($robot);

public function fetchOne( string $sqlQuery, int $fetchMode = int, array $bindParams = [], array $bindTypes = [] ): array;
Returns the first row in a SQL query result

public function forUpdate( string $sqlQuery, string $modifier = string ): string;
Returns a SQL modified with a FOR UPDATE clause. The optional modifier appends a row-lock disposition keyword — pass Dialect::LOCK_NOWAIT or Dialect::LOCK_SKIP_LOCKED (or leave as Dialect::LOCK_NONE).

public function getColumnDefinition( ColumnInterface $column ): string;
Returns the SQL column definition from a column

public function getColumnList( mixed $columnList ): string;
Gets a list of columns

public function getConnectionId(): int;
Gets the active connection unique identifier

public function getDefaultIdValue(): RawValue;
Return the default identity value to insert in an identity column

public function getDefaultValue(): RawValue;
Returns the default value to make the RBDM use the default value declared in the table definition

// Inserting a new robot with a valid default value for the column 'year'
$success = $connection->insert(
    "robots",
    [
        "Astro Boy",
        $connection->getDefaultValue()
    ],
    [
        "name",
        "year",
    ]
);

@todo Return NULL if this is not supported by the adapter

public function getDescriptor(): array;
Return descriptor used to connect to the active database

public function getDialect(): DialectInterface;
Returns internal dialect instance

public function getDialectType(): string;
Returns the name of the dialect used

public function getInternalHandler(): mixed;
Return internal PDO handler

public function getNestedTransactionSavepointName(): string;
Returns the savepoint name to use for nested transactions

public function getRealSQLStatement(): string;
Active SQL statement in the object without replace bound parameters

public function getSQLBindTypes(): array;
Active SQL statement in the object

public function getSQLStatement(): string;
Active SQL statement in the object

public function getSQLVariables(): array;
Active SQL statement in the object

public function getType(): string;
Returns type of database system the adapter is used for

public function insert( string $table, array $values, mixed $fields = null, mixed $dataTypes = null ): bool;
Inserts data into a table using custom RDBMS SQL syntax

public function insertAsDict( string $table, mixed $data, mixed $dataTypes = null ): bool;
Inserts data into a table using custom RBDM SQL syntax

// Inserting a new robot
$success = $connection->insertAsDict(
    "robots",
    [
        "name" => "Astro Boy",
        "year" => 1952,
    ]
);

// Next SQL sentence is sent to the database system
INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);

public function isNestedTransactionsWithSavepoints(): bool;
Returns if nested transactions should use savepoints

public function isUnderTransaction(): bool;
Checks whether connection is under database transaction

public function lastInsertId( string $name = null ): string | bool;
Returns insert id for the auto_increment column inserted in the last SQL statement

public function limit( string $sqlQuery, int $number ): string;
Appends a LIMIT clause to sqlQuery argument

public function listTables( string $schemaName = null ): array;
List all tables on a database

public function listViews( string $schemaName = null ): array;
List all views on a database

public function modifyColumn( string $tableName, string $schemaName, ColumnInterface $column, ColumnInterface $currentColumn = null ): bool;
Modifies a table column based on a definition

public function query( string $sqlStatement, array $bindParams = [], array $bindTypes = [] ): ResultInterface | bool;
Sends SQL statements to the database server returning the success state. Use this method only when the SQL statement sent to the server returns rows

public function releaseSavepoint( string $name ): bool;
Releases given savepoint

public function rollback( bool $nesting = bool ): bool;
Rollbacks the active transaction in the connection

public function rollbackSavepoint( string $name ): bool;
Rollbacks given savepoint

public function setNestedTransactionsWithSavepoints( bool $nestedTransactionsWithSavepoints ): Adapter;
Set if nested transactions should use savepoints

public function sharedLock( string $sqlQuery, string $modifier = string ): string;
Returns a SQL modified with a shared-lock clause. See the dialect's sharedLock() for per-engine semantics. The optional modifier is passed straight through (use Dialect::LOCK_NOWAIT / Dialect::LOCK_SKIP_LOCKED for PostgreSQL).

public function supportSequences(): bool;
Check whether the database system requires a sequence to produce auto-numeric values

public function supportsDefaultValue(): bool;
SQLite does not support the DEFAULT keyword

@deprecated Will re removed in the next version

public function tableExists( string $tableName, string $schemaName = null ): bool;
Generates SQL checking for the existence of a schema.table

public function tableOptions( string $tableName, string $schemaName = null ): array;
Gets creation options from a table

public function update( string $table, mixed $fields, mixed $values, mixed $whereCondition = null, mixed $dataTypes = null ): bool;
Updates data on a table using custom RDBMS SQL syntax

public function updateAsDict( string $table, mixed $data, mixed $whereCondition = null, mixed $dataTypes = null ): bool;
Updates data on a table using custom RBDM SQL syntax Another, more convenient syntax

// Updating existing robot
$success = $connection->updateAsDict(
    "robots",
    [
        "name" => "New Astro Boy",
    ],
    "id = 101"
);

// Next SQL sentence is sent to the database system
UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101

public function useExplicitIdValue(): bool;
Check whether the database system requires an explicit value for identity columns

public function viewExists( string $viewName, string $schemaName = null ): bool;
Generates SQL checking for the existence of a schema.view

Contracts\Db\Check Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Db
  • Uses

  • Extends

  • Implements

Canonical contract for Phalcon\Db\Check.

Methods

public function getExpression(): string;
Gets the CHECK expression (the SQL boolean predicate).

public function getName(): string;
Gets the constraint name. An empty string indicates an unnamed CHECK constraint — the dialect will emit the clause without a CONSTRAINT prefix in that case.

Contracts\Db\Column Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Db
  • Uses

  • Extends

  • Implements

Canonical contract for Phalcon\Db\Column.

@todo v7 — these will become required interface members. They are omitted from the v5 line to avoid breaking third-party implementors: - getGenerationExpression() : string | null - isArray() : bool - isGenerated() : bool - isGenerationStored() : bool - isInvisible() : bool

Methods

public function getAfterPosition(): string | null;
Check whether field absolute to position in table

public function getBindType(): int;
Returns the type of bind handling

public function getDefault(): mixed;
Returns default value of column

public function getName(): string;
Returns column name

public function getScale(): int;
Returns column scale

public function getSize(): int | string;
Returns column size

public function getType(): int | string;
Returns column type

public function getTypeReference(): int;
Returns column type reference

public function getTypeValues(): array | string;
Returns column type values

public function hasDefault(): bool;
Check whether column has default value

public function isAutoIncrement(): bool;
Auto-Increment

public function isFirst(): bool;
Check whether column have first position in table

public function isNotNull(): bool;
Not null

public function isNumeric(): bool;
Check whether column have an numeric type

public function isPrimary(): bool;
Column is part of the primary key?

public function isUnsigned(): bool;
Returns true if number column is unsigned

Contracts\Db\Dialect Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Db
  • Uses

    • Phalcon\Db\ColumnInterface
    • Phalcon\Db\IndexInterface
    • Phalcon\Db\ReferenceInterface
  • Extends

  • Implements

Canonical contract for Phalcon\Db dialects.

@todo v7 — these will become required interface members. They are omitted from the v5 line to avoid breaking third-party implementors: - addCheck() : string - createMaterializedView() : string - dropCheck() : string - dropMaterializedView() : string - onConflictUpdate() : string - refreshMaterializedView() : string - returning() : string

Constants

const LOCK_NONE = ;
const LOCK_NOWAIT = NOWAIT;
const LOCK_SKIP_LOCKED = SKIP LOCKED;

Methods

public function addColumn( string $tableName, string $schemaName, ColumnInterface $column ): string;
Generates SQL to add a column to a table

public function addForeignKey( string $tableName, string $schemaName, ReferenceInterface $reference ): string;
Generates SQL to add an index to a table

public function addIndex( string $tableName, string $schemaName, IndexInterface $index ): string;
Generates SQL to add an index to a table

public function addPrimaryKey( string $tableName, string $schemaName, IndexInterface $index ): string;
Generates SQL to add the primary key to a table

public function createSavepoint( string $name ): string;
Generate SQL to create a new savepoint

public function createTable( string $tableName, string $schemaName, array $definition ): string;
Generates SQL to create a table

public function createView( string $viewName, array $definition, string $schemaName = null ): string;
Generates SQL to create a view

public function describeColumns( string $table, string $schema = null ): string;
Generates SQL to describe a table

public function describeIndexes( string $table, string $schema = null ): string;
Generates SQL to query indexes on a table

public function describeReferences( string $table, string $schema = null ): string;
Generates SQL to query foreign keys on a table

public function dropColumn( string $tableName, string $schemaName, string $columnName ): string;
Generates SQL to delete a column from a table

public function dropForeignKey( string $tableName, string $schemaName, string $referenceName ): string;
Generates SQL to delete a foreign key from a table

public function dropIndex( string $tableName, string $schemaName, string $indexName ): string;
Generates SQL to delete an index from a table

public function dropPrimaryKey( string $tableName, string $schemaName ): string;
Generates SQL to delete primary key from a table

public function dropTable( string $tableName, string $schemaName, bool $ifExists = bool ): string;
Generates SQL to drop a table

public function dropView( string $viewName, string $schemaName = null, bool $ifExists = bool ): string;
Generates SQL to drop a view

public function forUpdate( string $sqlQuery, string $modifier = string ): string;
Returns a SQL modified with a FOR UPDATE clause. The optional modifier appends a row-lock disposition keyword — pass Dialect::LOCK_NOWAIT or Dialect::LOCK_SKIP_LOCKED (or leave as Dialect::LOCK_NONE).

public function getColumnDefinition( ColumnInterface $column ): string;
Gets the column name in RDBMS

public function getColumnList( array $columnList ): string;
Gets a list of columns

public function getCustomFunctions(): array;
Returns registered functions

public function getSqlExpression( array $expression, string $escapeChar = null, array $bindCounts = [] ): string;
Transforms an intermediate representation for an expression into a database system valid expression

public function limit( string $sqlQuery, mixed $number ): string;
Generates the SQL for LIMIT clause

public function listTables( string $schemaName = null ): string;
List all tables in database

public function modifyColumn( string $tableName, string $schemaName, ColumnInterface $column, ColumnInterface $currentColumn = null ): string;
Generates SQL to modify a column in a table

public function registerCustomFunction( string $name, callable $customFunction ): \Phalcon\Db\Dialect;
Registers custom SQL functions

public function releaseSavepoint( string $name ): string;
Generate SQL to release a savepoint

public function rollbackSavepoint( string $name ): string;
Generate SQL to rollback a savepoint

public function select( array $definition ): string;
Builds a SELECT statement

public function sharedLock( string $sqlQuery, string $modifier = string ): string;
Returns a SQL modified with a shared-lock clause. MySQL emits LOCK IN SHARE MODE; PostgreSQL emits FOR SHARE; SQLite returns the original query unchanged. The optional modifier appends a row-lock disposition keyword (Dialect::LOCK_NOWAIT / Dialect::LOCK_SKIP_LOCKED) for PostgreSQL — MySQL's legacy LOCK IN SHARE MODE does not support modifiers, so non-empty values are silently ignored on MySQL.

public function supportsReleaseSavepoints(): bool;
Checks whether the platform supports releasing savepoints.

public function supportsSavepoints(): bool;
Checks whether the platform supports savepoints

public function tableExists( string $tableName, string $schemaName = null ): string;
Generates SQL checking for the existence of a schema.table

public function tableOptions( string $table, string $schema = null ): string;
Generates the SQL to describe the table creation options

public function viewExists( string $viewName, string $schemaName = null ): string;
Generates SQL checking for the existence of a schema.view

Contracts\Db\Index Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Db
  • Uses

  • Extends

  • Implements

Canonical contract for Phalcon\Db\Index.

@todo v7 — these will become required interface members. They are omitted from the v5 line to avoid breaking third-party implementors: - getDirections() : array - getWhere() : string - isConcurrent() : bool - isInvisible() : bool

Methods

public function getColumns(): array;
Gets the columns that corresponds the index

public function getName(): string;
Gets the index name

public function getType(): string;
Gets the index type

Contracts\Db\Reference Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Db
  • Uses

  • Extends

  • Implements

Canonical contract for Phalcon\Db\Reference.

Methods

public function getColumns(): array;
Gets local columns which reference is based

public function getName(): string;
Gets the index name

public function getOnDelete(): string | null;
Gets the referenced on delete

public function getOnUpdate(): string | null;
Gets the referenced on update

public function getReferencedColumns(): array;
Gets referenced columns

public function getReferencedSchema(): string | null;
Gets the schema where referenced table is

public function getReferencedTable(): string;
Gets the referenced table

public function getSchemaName(): string | null;
Gets the schema where referenced table is

Contracts\Db\Result Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Db
  • Uses

  • Extends

  • Implements

Canonical contract for Phalcon\Db result objects.

Methods

public function dataSeek( int $number );
Moves internal resultset cursor to another position letting us to fetch a certain row

public function execute(): bool;
Allows to execute the statement again. Some database systems don't support scrollable cursors. So, as cursors are forward only, we need to execute the cursor again to fetch rows from the beginning

public function fetch(): mixed;
Fetches an array/object of strings that corresponds to the fetched row, or FALSE if there are no more rows. This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode()

public function fetchAll(): array;
Returns an array of arrays containing all the records in the result. This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode()

public function fetchArray(): mixed;
Returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows. This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode()

public function getInternalResult(): \PDOStatement;
Gets the internal PDO result object

public function numRows(): int;
Gets number of rows returned by a resultset

public function setFetchMode( int $fetchMode ): bool;
Changes the fetching mode affecting Phalcon\Db\Result\Pdo::fetch()

Contracts\Encryption\Security\CryptoUtils Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Encryption\Security
  • Uses

    • Phalcon\Encryption\Security\Random
  • Extends

  • Implements

This file is part of the Phalcon Framework.

(c) Phalcon Team team@phalcon.io

For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.

Methods

public function computeHmac( string $data, string $key, string $algo, bool $raw = bool ): string;
public function getRandom(): Random;
public function getRandomBytes(): int;
public function getSaltBytes( int $numberBytes = int ): string;
public function setRandomBytes( int $randomBytes ): Security;

Contracts\Encryption\Security\CsrfProtection Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Encryption\Security
  • Uses

  • Extends

  • Implements

This file is part of the Phalcon Framework.

(c) Phalcon Team team@phalcon.io

For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.

Methods

public function checkToken( string $tokenKey = null, mixed $tokenValue = null, bool $destroyIfValid = bool ): bool;
public function destroyToken(): Security;
public function getRequestToken(): string | null;
public function getSessionToken(): string | null;
public function getToken(): string | null;
public function getTokenKey(): string | null;

Contracts\Encryption\Security\PasswordSecurity Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Encryption\Security
  • Uses

  • Extends

  • Implements

This file is part of the Phalcon Framework.

(c) Phalcon Team team@phalcon.io

For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.

Methods

public function checkHash( string $password, string $passwordHash, int $maxPassLength = int ): bool;
public function getDefaultHash(): int;
public function getHashInformation( string $hash ): array;
public function getWorkFactor(): int;
public function hash( string $password, array $options = [] ): string;
public function isLegacyHash( string $passwordHash ): bool;
public function setDefaultHash( int $defaultHash ): Security;
public function setWorkFactor( int $workFactor ): Security;

Contracts\Encryption\Security\Security Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Encryption\Security
  • Uses

  • Extends

    CryptoUtils

  • Implements

This file is part of the Phalcon Framework.

(c) Phalcon Team team@phalcon.io

For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.

Contracts\Events\Event Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Events
  • Uses

  • Extends

  • Implements

Canonical contract for Phalcon\Events\Event.

Methods

public function getData(): mixed;
Gets event data

public function getType(): mixed;
Gets event type

public function isCancelable(): bool;
Check whether the event is cancelable

public function isStopped(): bool;
Check whether the event is currently stopped

public function setData( mixed $data = null ): Event;
Sets event data

public function setType( string $type ): Event;
Sets event type

public function stop(): Event;
Stops the event preventing propagation

Contracts\Events\EventsAware Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Events
  • Uses

    • Phalcon\Events\ManagerInterface
  • Extends

  • Implements

Canonical contract for Phalcon\Events\EventsAwareInterface. Implemented by components that accept an events manager and dispatch through it.

Cross-references the legacy ManagerInterface (not the canonical Manager contract) to preserve LSP for the many AbstractEventsAware subclasses that already type-hint ManagerInterface. ManagerInterface extends Manager, so this remains type-compatible with any code that needs the canonical surface.

Methods

public function getEventsManager(): ManagerInterface | null;
Returns the internal events manager

public function setEventsManager( ManagerInterface $eventsManager ): void;
Sets the events manager

Contracts\Events\Manager Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Events
  • Uses

  • Extends

  • Implements

Canonical contract for Phalcon\Events\Manager.

Constants

const DEFAULT_PRIORITY = 100;

Methods

public function addSubscriber( Subscriber $subscriber ): void;
Registers an event subscriber. The subscriber's getSubscribedEvents() map is parsed and each entry is attached through the regular listener pipeline.

public function arePrioritiesEnabled(): bool;
Returns whether priority ordering is currently enabled.

public function attach( string $eventType, mixed $handler, int $priority = static-constant-access ): void;
Attach a listener to the events manager.

public function clearSubscribers(): void;
Removes every registered subscriber and detaches each listener they contributed. Listeners attached via attach() are untouched.

public function collectResponses( bool $collect ): void;
Toggle response collection on/off.

public function detach( string $eventType, mixed $handler ): void;
Detach a listener from the events manager.

public function detachAll( string $type = null ): void;
Removes all listeners — globally or for a single event type.

public function enablePriorities( bool $enablePriorities ): void;
Toggle priority ordering on/off.

public function fire( string $eventType, object $source, mixed $data = null, bool $cancelable = bool );
Fires an event, notifying the active listeners.

public function getListeners( string $type ): array;
Returns all listeners attached to the given event type.

public function getResponses(): array;
Returns the responses recorded during the last fire (when collecting).

public function getSubscribers(): array;
Returns the list of registered subscriber instances.

public function hasListeners( string $type ): bool;
Check whether the given event type has any listeners.

public function isCollecting(): bool;
Check whether the manager is currently collecting responses.

public function isValidHandler( mixed $handler ): bool;
Returns true when the given handler is an object or callable.

public function removeSubscriber( Subscriber $subscriber ): void;
Removes a previously registered subscriber. Detaches every listener the subscriber declared via getSubscribedEvents(). Idempotent.

Contracts\Events\Stoppable Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Events
  • Uses

  • Extends

  • Implements

Phalcon's local mirror of PSR-14 StoppableEventInterface. Identical shape; not extended from the PSR interface because the Zephir extension cannot reference Composer-loaded interfaces at build time. A separate bridge package exposes a PSR-14 adapter.

Methods

public function isPropagationStopped(): bool;
Returns true when the event must stop propagating to subsequent listeners.

Contracts\Events\Subscriber Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Events
  • Uses

  • Extends

  • Implements

Contract for event subscriber classes. A subscriber declares the events it wants to listen to via a static map; Events\Manager parses the map and attaches each entry as a regular listener.

Accepted value shapes per event key:

'event:name' => 'methodName' 'event:name' => ['methodName', priority] 'event:name' => [ ['methodName1'], ['methodName2', priority], ]

Keys can be either a Phalcon event string (e.g. "db:beforeQuery") or a fully qualified event class name.

Wildcard subscriptions: Phalcon's manager fires both the prefix queue and the full-name queue (e.g. "db" is fired before "db:beforeQuery"). To subscribe to every event of a component, use the prefix as the key:

'db' => 'onAnyDbEvent' // fires for db:beforeQuery, db:afterQuery, ...

Methods

public static function getSubscribedEvents(): array;
Returns a map of event name => listener config. Called once per Manager::addSubscriber() / removeSubscriber() call.

Contracts\Forms\Schema Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Forms
  • Uses

  • Extends

  • Implements

Contract for objects that supply a normalized list of form element definitions. Implementations may source the definitions from a PHP array, a JSON document, a YAML file, or any other format.

Each returned definition must be an associative array containing at least: - 'type' (string) — element type key (e.g. 'text', 'select', 'checkgroup') - 'name' (string) — the HTML name attribute value

Optional keys per definition: - 'label' (string) — visible label text - 'default' (mixed) — pre-populated default value - 'attributes' (array) — additional HTML attributes - 'filters' (array|string) — filter names applied on bind() - 'validators' (array) — ValidatorInterface instances - 'options' (array) — choices for select / checkgroup / radiogroup

Methods

public function load(): array;
Returns an ordered list of normalized element definitions.

Contracts\Html\Helper\Input\SelectData Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Html\Helper\Input
  • Uses

  • Extends

  • Implements

Interface for SELECT option data providers.

Return format: [value => label] for flat options; [groupLabel => [value => label, ...]] for optgroups.

Methods

public function getAttributes(): array;
Returns the per-option attribute map.

Format: [optionValue => [attrName => stringValue, ...]]. Implementations must return resolved string values; no escaping, ordering, or rendering is performed here.

public function getOptions(): array;

Contracts\Mvc\Model\Relation\CacheKeyProvider Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Mvc\Model\Relation
  • Uses

  • Extends

  • Implements

Interface for models that provide a custom unique key for the reusable records cache in the Model Manager. Implement this interface when the default object-identity based key (unique_key) does not produce stable cache hits across multiple object instances that represent the same database record.

Methods

public function getUniqueKey(): string;
Returns a string that uniquely identifies this model instance for use as the key in the reusable records cache.

Contracts\Paginator\Adapter Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Paginator
  • Uses

  • Extends

  • Implements

Interface for Phalcon\Paginator adapters

Methods

public function getLimit(): int;
Get current rows limit

public function paginate(): Repository;
Returns a slice of the resultset to show in the pagination

public function setCurrentPage( int $page );
Set the current page number

public function setLimit( int $limit );
Set current rows limit

Contracts\Paginator\Repository Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Paginator
  • Uses

  • Extends

  • Implements

Interface for the repository of current state Phalcon\Paginator\AdapterInterface::paginate()

Constants

const PROPERTY_CURRENT_PAGE = current;
const PROPERTY_FIRST_PAGE = first;
const PROPERTY_ITEMS = items;
const PROPERTY_LAST_PAGE = last;
const PROPERTY_LIMIT = limit;
const PROPERTY_NEXT_PAGE = next;
const PROPERTY_PREVIOUS_PAGE = previous;
const PROPERTY_TOTAL_ITEMS = total_items;

Methods

public function getAliases(): array;
Gets the aliases for properties repository

public function getCurrent(): int;
Gets number of the current page

public function getFirst(): int;
Gets number of the first page

public function getItems(): mixed;
Gets the items on the current page

public function getLast(): int;
Gets number of the last page

public function getLimit(): int;
Gets current rows limit

public function getNext(): int;
Gets number of the next page

public function getPrevious(): int;
Gets number of the previous page

public function getTotalItems(): int;
Gets the total number of items

public function setAliases( array $aliases ): Repository;
Sets the aliases for properties repository

public function setProperties( array $properties ): Repository;
Sets values for properties of the repository

Contracts\Support\Collection Interface

Source on GitHub

  • Namespace

    • Phalcon\Contracts\Support
  • Uses

    • ArrayAccess
    • IteratorAggregate
  • Extends

    ArrayAccess

  • Implements

Canonical contract for Phalcon\Support\Collection.

@phpstan-template T

@extends ArrayAccess @extends IteratorAggregate

Methods

public function __get( string $element ): mixed;
public function __isset( string $element ): bool;
public function __set( string $element, mixed $value ): void;
public function __unset( string $element ): void;

public function clear(): void;
Clears the internal collection.

public function column( string $propertyOrMethod ): array;
Returns the values from a single property/method extracted from every item in the collection, keyed by the original collection key.

public function each( callable $callback ): Collection;
Invokes the callback for every item in the collection.

@phpstan-param callable(T, array-key): mixed $callback

public function filter( callable $callback ): Collection;
Returns a new collection of items for which the callback returns true.

@phpstan-param callable(T, array-key): bool $callback @phpstan-return static

public function first(): mixed;
Returns the first value in the collection or null when empty.

@phpstan-return T|null

public function get( string $element, mixed $defaultValue = null, string $cast = null ): mixed;
Returns an element from the collection.

public function getKeys( bool $insensitive = bool ): array;
Returns the keys (insensitive or not) of the collection.

@deprecated Use {@see self::keys()} instead. Will be removed in a future major release.

public function getType(): string | null;
Returns the configured runtime type guard, or null when not set.

public function getValues(): array;
Returns the values of the internal array.

@deprecated Use {@see self::values()} instead. Will be removed in a future major release.

public function has( string $element ): bool;
Checks whether an element exists in the collection.

public function init( array $data = [] ): void;
Initializes the internal array.

public function isEmpty(): bool;
Returns true when the collection has no entries.

public function keys( bool $insensitive = bool ): array;
Returns the keys (insensitive or not) of the collection.

public function last(): mixed;
Returns the last value in the collection or null when empty.

@phpstan-return T|null

public function map( callable $callback ): Collection;
Returns a new collection with the callback applied to every value.

@phpstan-param callable(T, array-key): mixed $callback

public function reduce( callable $callback, mixed $initial = null ): mixed;
Reduces the collection to a single value using the callback.

@phpstan-param callable(mixed, T, array-key): mixed $callback

public function remove( string $element ): void;
Removes the element from the collection.

public function replace( array $data ): void;
Replaces the collection data with a new array, clearing first.

public function set( string $element, mixed $value ): void;
Stores an element in the collection.

@phpstan-param T $value

public function sort( callable $callback = null, int $order = int ): Collection;
Returns a new collection sorted by value, preserving keys.

@phpstan-return static

public function toArray(): array;
Returns the collection as an array.

@phpstan-return array

public function toJson( int $options = int ): string;
Returns the collection serialized as a JSON string.

public function values(): array;
Returns the values of the internal array.

public function where( string $propertyOrMethod, mixed $value ): Collection;
Returns a new collection containing only the items whose propertyOrMethod strictly equals $value.

@phpstan-return static