Skip to content

Phalcon support

NOTE

All classes are prefixed with Phalcon

Support\AbstractLocator

Abstract Source on GitHub

Abstract base class for service locators.

Provides a unified way to register, validate, and resolve services from a DI container, with support for both legacy Di and new Container.

@template T of object

Uses Phalcon\Contracts\Container\Service\Collection · Phalcon\Di\DiInterface · Throwable

Method Summary

Properties

protected Collection|DiInterface $container
protected array $services = []

Methods

Public · 6

__construct()

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

getAll()

public function getAll(): array;

Returns the full registered service map (defaults plus any added via register()).

getClass()

public function getClass( string $name ): string;

Returns the class-string registered under the given name.

has()

public function has( string $name ): bool;

Whether a service with the given name is registered.

newInstance()

public function newInstance( string $name ): object;

Retrieve a service instance from the container.

On the DiInterface path this returns the container's shared instance (getShared()) — despite the name, it is not a fresh build. Locators whose services carry per-activation state should override this method to resolve a fresh instance; see Auth\Access\AccessLocator, which uses ContainerResolver::resolveFresh for exactly that reason.

register()

public function register(
    string $name,
    string $definition
): static;

Register a service or override an existing one.

Protected · 4

getExceptionClass()

abstract protected function getExceptionClass(): string;

Get the exception class to throw on errors.

getInterfaceClass()

abstract protected function getInterfaceClass(): string;

Get the interface/class that all registered services must implement. This allows different locators to enforce different contracts.

getService()

protected function getService( string $name ): string;

Get the service class name for a given name.

getServices()

abstract protected function getServices(): array;

Get the default services for this locator.

Support\Collection

Class Source on GitHub

Phalcon\Support\Collection is a supercharged object-oriented array. It implements: - ArrayAccess - Countable - IteratorAggregate - JsonSerializable

It can be used in any part of the application that needs collection of data Such implementations are for instance accessing globals $_GET, $_POST etc.

@property array $data @property bool $insensitive @property array $lowerKeys @property bool $strictNull @property string|null $type

Uses ArrayAccess · ArrayIterator · Countable · InvalidArgumentException · IteratorAggregate · JsonSerializable · Phalcon\Support\Collection\CollectionInterface · Phalcon\Support\Collection\Exceptions\InvalidValueType · Phalcon\Support\Helper\Json\Encode · Traversable

Method Summary

public __construct(array $data = [],bool $insensitive = true,bool $strictNull = false,string $type = null) Collection constructor. public mixed __get( string $element ) Magic getter to get an element from the collection public bool __isset( string $element ) Magic isset to check whether an element exists or not public array __serialize() Returns the state of the collection for serialization, including public void __set(string $element,mixed $value) Magic setter to assign values to an element public void __unserialize( array $data ) Restores the collection state. Accepts both the structured format public void __unset( string $element ) Magic unset to remove an element from the collection public void clear() Clears the internal collection public array column( string $propertyOrMethod ) Returns the values from a single property/method extracted from every public int count() Count elements of an object public static each( callable $callback ) Invokes the callback for every item in the collection. Returns the public static filter( callable $callback ) Returns a new collection of items for which the callback returns true. public mixed first() Returns the first value in the collection, or null if empty. public mixed get(string $element,mixed $defaultValue = null,string $cast = null) Get the element from the collection public Traversable getIterator() Returns the iterator of the class public array getKeys( bool $insensitive = true ) Returns the keys (insensitive or not) of the collection. public string|null getType() Returns the configured runtime type guard, or null if none. public array getValues() Returns the values of the internal array. public bool has( string $element ) Get the element from the collection public void init( array $data = [] ) Initialize internal array public bool isEmpty() Return if the collection is empty public array jsonSerialize() Specify data which should be serialized to JSON public array keys( bool $insensitive = true ) Returns the keys (insensitive or not) of the collection. public mixed last() Returns the last value in the collection, or null if empty. public static map( callable $callback ) Returns a new collection with the callback applied to every value. public bool offsetExists( mixed $element ) Whether a offset exists public mixed offsetGet( mixed $element ) Offset to retrieve public void offsetSet(mixed $element,mixed $value) Offset to set public void offsetUnset( mixed $element ) Offset to unset public mixed reduce(callable $callback,mixed $initial = null) Reduces the collection to a single value using the callback. The public void remove( string $element ) Delete the element from the collection public void replace( array $data ) Replaces the collection data with a new array, clearing existing data first public string|null serialize() BC - delegate to __serialize() public void set(string $element,mixed $value) Set an element in the collection public static sort(mixed $callback = null,int $order = 4) Returns a new collection sorted by value. Keys are preserved. When a public array toArray() Returns the object in an array format public string toJson( int $options = 4194383 ) Returns the object in a JSON format public void unserialize( string $data ) BC - delegate to __unserialize() public array values() Returns the values of the internal array. public static where(string $propertyOrMethod,mixed $value) Returns a new collection containing only the items whose protected static cloneEmpty( array $data = [] ) Builds a new collection of the same concrete class, carrying over the protected mixed extractValue(mixed $item,string $propertyOrMethod) Extracts a single value from an item. For arrays returns the keyed protected string processKey( string $element ) Checks if we need insensitive keys and if so, converts the element to protected void setData(string $element,mixed $value) Internal method to set data protected void validateType( mixed $value ) Validates the value against the configured $type guard. When $type

Properties

protected array $data = []
protected bool $insensitive = true
protected array $lowerKeys = []
protected bool $strictNull = false
protected string|null $type = null

Methods

Public · 40

__construct()

public function __construct(
    array $data = [],
    bool $insensitive = true,
    bool $strictNull = false,
    string $type = null
);

Collection constructor.

__get()

public function __get( string $element ): mixed;

Magic getter to get an element from the collection

__isset()

public function __isset( string $element ): bool;

Magic isset to check whether an element exists or not

__serialize()

public function __serialize(): array;

Returns the state of the collection for serialization, including configuration flags so the round-trip restores full state.

__set()

public function __set(
    string $element,
    mixed $value
): void;

Magic setter to assign values to an element

__unserialize()

public function __unserialize( array $data ): void;

Restores the collection state. Accepts both the structured format emitted by __serialize() and the legacy flat-array format for BC with previously serialized data.

__unset()

public function __unset( string $element ): void;

Magic unset to remove an element from the collection

clear()

public function clear(): void;

Clears the internal collection

column()

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.

count()

public function count(): int;

Count elements of an object

each()

public function each( callable $callback ): static;

Invokes the callback for every item in the collection. Returns the collection itself to allow chaining.

filter()

public function filter( callable $callback ): static;

Returns a new collection of items for which the callback returns true. Keys are preserved.

first()

public function first(): mixed;

Returns the first value in the collection, or null if empty.

get()

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

Get the element from the collection

getIterator()

public function getIterator(): Traversable;

Returns the iterator of the class

getKeys()

public function getKeys( bool $insensitive = true ): array;

Returns the keys (insensitive or not) of the collection.

getType()

public function getType(): string|null;

Returns the configured runtime type guard, or null if none.

getValues()

public function getValues(): array;

Returns the values of the internal array.

has()

public function has( string $element ): bool;

Get the element from the collection

init()

public function init( array $data = [] ): void;

Initialize internal array

isEmpty()

public function isEmpty(): bool;

Return if the collection is empty

jsonSerialize()

public function jsonSerialize(): array;

Specify data which should be serialized to JSON

@link https://php.net/manual/en/jsonserializable.jsonserialize.php

keys()

public function keys( bool $insensitive = true ): array;

Returns the keys (insensitive or not) of the collection.

last()

public function last(): mixed;

Returns the last value in the collection, or null if empty.

map()

public function map( callable $callback ): static;

Returns a new collection with the callback applied to every value. Keys are preserved.

offsetExists()

public function offsetExists( mixed $element ): bool;

Whether a offset exists

@link https://php.net/manual/en/arrayaccess.offsetexists.php

offsetGet()

public function offsetGet( mixed $element ): mixed;

Offset to retrieve

@link https://php.net/manual/en/arrayaccess.offsetget.php

offsetSet()

public function offsetSet(
    mixed $element,
    mixed $value
): void;

Offset to set

@link https://php.net/manual/en/arrayaccess.offsetset.php

offsetUnset()

public function offsetUnset( mixed $element ): void;

Offset to unset

@link https://php.net/manual/en/arrayaccess.offsetunset.php

reduce()

public function reduce(
    callable $callback,
    mixed $initial = null
): mixed;

Reduces the collection to a single value using the callback. The callback receives ($accumulator, $value, $key).

remove()

public function remove( string $element ): void;

Delete the element from the collection

replace()

public function replace( array $data ): void;

Replaces the collection data with a new array, clearing existing data first

serialize()

public function serialize(): string|null;

BC - delegate to __serialize()

set()

public function set(
    string $element,
    mixed $value
): void;

Set an element in the collection

sort()

public function sort(
    mixed $callback = null,
    int $order = 4
): static;

Returns a new collection sorted by value. Keys are preserved. When a callback is supplied, uasort is used. Without a callback, the comparison direction is controlled by the $order argument (SORT_ASC or SORT_DESC).

toArray()

public function toArray(): array;

Returns the object in an array format

toJson()

public function toJson( int $options = 4194383 ): string;

Returns the object in a JSON format

The following options are used if none specified for json_encode

JSON_HEX_TAG, JSON_HEX_APOS, JSON_HEX_AMP, JSON_HEX_QUOT, JSON_UNESCAPED_SLASHES, JSON_THROW_ON_ERROR

@see https://www.ietf.org/rfc/rfc4627.txt

unserialize()

public function unserialize( string $data ): void;

BC - delegate to __unserialize()

values()

public function values(): array;

Returns the values of the internal array.

where()

public function where(
    string $propertyOrMethod,
    mixed $value
): static;

Returns a new collection containing only the items whose propertyOrMethod strictly equals $value.

Protected · 5

cloneEmpty()

protected function cloneEmpty( array $data = [] ): static;

Builds a new collection of the same concrete class, carrying over the configuration (insensitivity, strict-null, type) of the current one.

extractValue()

protected function extractValue(
    mixed $item,
    string $propertyOrMethod
): mixed;

Extracts a single value from an item. For arrays returns the keyed entry; for objects, prefers a callable method, then a readable property. Returns null when nothing matches.

processKey()

protected function processKey( string $element ): string;

Checks if we need insensitive keys and if so, converts the element to lowercase

setData()

protected function setData(
    string $element,
    mixed $value
): void;

Internal method to set data

validateType()

protected function validateType( mixed $value ): void;

Validates the value against the configured $type guard. When $type is null this is a no-op. Scalar tokens (int, string, bool, float, array, object) map to their is_* checks; anything else is treated as a class/interface name and tested with instanceof.

Support\Collection\CollectionInterface

Interface Source on GitHub

Phalcon\Support\Collection\CollectionInterface

Uses Phalcon\Contracts\Support\Collection

Support\Collection\Exception

Class Source on GitHub

Exceptions for the Collection object

Uses Phalcon\Support\Exception

Support\Collection\Exceptions\InvalidValueType

Class Source on GitHub

  • InvalidArgumentException
    • Phalcon\Support\Collection\Exceptions\InvalidValueType

Uses InvalidArgumentException

Method Summary

Methods

Public · 1

__construct()

public function __construct(
    string $type,
    mixed $value
);

Support\Collection\Exceptions\ReadOnlyViolation

Class Source on GitHub

Uses Phalcon\Support\Collection\Exception

Method Summary

Methods

Public · 1

__construct()

public function __construct();

Support\Collection\ReadOnlyCollection

Class Source on GitHub

A read only Collection object

Uses Phalcon\Support\Collection · Phalcon\Support\Collection\Exceptions\ReadOnlyViolation

Method Summary

Properties

protected bool $constructed = false

Methods

Public · 7

__construct()

public function __construct(
    array $data = [],
    bool $insensitive = true,
    bool $strictNull = false,
    string $type = null
);

ReadOnlyCollection constructor.

__unserialize()

public function __unserialize( array $data ): void;

Restores the collection state during unserialization.

Temporarily disables the read-only guard so the parent class can restore the collection state. The guard is re-enabled before the method returns.

clear()

public function clear(): void;

init()

public function init( array $data = [] ): void;

remove()

public function remove( string $element ): void;

Delete the element from the collection

replace()

public function replace( array $data ): void;

Replaces the collection data with a new array

set()

public function set(
    string $element,
    mixed $value
): void;

Set an element in the collection

Support\Debug

Class Source on GitHub

Provides debug capabilities to Phalcon applications

  • Phalcon\Support\Debug

Uses Phalcon\Support\Debug\Exceptions\RequestHalted · Phalcon\Support\Debug\Exceptions\RuntimeWarning · ReflectionClass · ReflectionException · ReflectionFunction · Throwable

Method Summary

public static clearVars() Clears are variables added previously public static debugVar( mixed $varz ) Adds a variable to the debug output public string getCssSources() Returns the CSS sources public string getJsSources() Returns the JavaScript sources public string getVersion() Generates a link to the current version documentation public void halt() Halts the request showing a backtrace public static listen(bool $exceptions = true,bool $lowSeverity = false) Listen for uncaught exceptions and non silent notices or warnings public static listenExceptions() Listen for uncaught exceptions public static listenLowSeverity() Listen for non silent notices or warnings public bool onUncaughtException( \Throwable $exception ) Handles uncaught exceptions public void onUncaughtLowSeverity(mixed $severity,mixed $message,mixed $file,mixed $line) Throws an exception when a notice or warning is raised public string renderHtml( \Throwable $exception ) Render exception to html format. public static setBlacklist( array $blacklist ) Sets if files the exception's backtrace must be showed public static setShowBackTrace( bool $showBackTrace ) Sets if files the exception's backtrace must be showed public static setShowFileFragment( bool $showFileFragment ) Sets if files must be completely opened and showed in the output public static setShowFiles( bool $showFiles ) Set if files part of the backtrace must be shown in the output public static setUri( string $uri ) Change the base URI for static resources protected string escapeString( string $value ) Escapes a string with htmlentities protected string|null getArrayDump(array $argument,mixed $n = 0) Produces a recursive representation of an array protected string getVarDump( mixed $variable ) Produces an string representation of a variable protected string showTraceItem(int $number,array $trace) Shows a backtrace item

Properties

protected array $blacklist = [...]
protected array $data = []
protected bool $hideDocumentRoot = false
protected bool $isActive = false
protected bool $showBackTrace = true
protected bool $showFileFragment = false
protected bool $showFiles = true
protected string $uri = "https://assets.phalcon.io/debug/5.0.x/"

Methods

Public · 17

clearVars()

public function clearVars(): static;

Clears are variables added previously

debugVar()

public function debugVar( mixed $varz ): static;

Adds a variable to the debug output

getCssSources()

public function getCssSources(): string;

Returns the CSS sources

getJsSources()

public function getJsSources(): string;

Returns the JavaScript sources

getVersion()

public function getVersion(): string;

Generates a link to the current version documentation

halt()

public function halt(): void;

Halts the request showing a backtrace

listen()

public function listen(
    bool $exceptions = true,
    bool $lowSeverity = false
): static;

Listen for uncaught exceptions and non silent notices or warnings

listenExceptions()

public function listenExceptions(): static;

Listen for uncaught exceptions

listenLowSeverity()

public function listenLowSeverity(): static;

Listen for non silent notices or warnings

onUncaughtException()

public function onUncaughtException( \Throwable $exception ): bool;

Handles uncaught exceptions

onUncaughtLowSeverity()

public function onUncaughtLowSeverity(
    mixed $severity,
    mixed $message,
    mixed $file,
    mixed $line
): void;

Throws an exception when a notice or warning is raised

renderHtml()

public function renderHtml( \Throwable $exception ): string;

Render exception to html format.

setBlacklist()

public function setBlacklist( array $blacklist ): static;

Sets if files the exception's backtrace must be showed

setShowBackTrace()

public function setShowBackTrace( bool $showBackTrace ): static;

Sets if files the exception's backtrace must be showed

setShowFileFragment()

public function setShowFileFragment( bool $showFileFragment ): static;

Sets if files must be completely opened and showed in the output or just the fragment related to the exception

setShowFiles()

public function setShowFiles( bool $showFiles ): static;

Set if files part of the backtrace must be shown in the output

setUri()

public function setUri( string $uri ): static;

Change the base URI for static resources

Protected · 4

escapeString()

protected function escapeString( string $value ): string;

Escapes a string with htmlentities

getArrayDump()

protected function getArrayDump(
    array $argument,
    mixed $n = 0
): string|null;

Produces a recursive representation of an array

getVarDump()

protected function getVarDump( mixed $variable ): string;

Produces an string representation of a variable

showTraceItem()

final protected function showTraceItem(
    int $number,
    array $trace
): string;

Shows a backtrace item

Support\Debug\Dump

Class Source on GitHub

Dumps information about a variable(s)

$foo = 123;

echo (new \Phalcon\Debug\Dump())->variable($foo, "foo");
$foo = "string";
$bar = ["key" => "value"];
$baz = new stdClass();

echo (new \Phalcon\Debug\Dump())->variables($foo, $bar, $baz);
  • Phalcon\Support\Debug\Dump

Uses Phalcon\Di\DiInterface · Phalcon\Support\Helper\Json\Encode · Reflection · ReflectionClass · ReflectionProperty · stdClass

Method Summary

Properties

protected bool $detailed = false
protected array $methods = []
protected array $styles = []

Methods

Public · 9

__construct()

public function __construct(
    array $styles = [],
    bool $detailed = false
);

Phalcon\Debug\Dump constructor

all()

public function all(): string;

Alias of variables() method

getDetailed()

public function getDetailed(): bool;

one()

public function one(
    mixed $variable,
    string $name = null
): string;

Alias of variable() method

setDetailed()

public function setDetailed( bool $flag ): void;

setStyles()

public function setStyles( array $styles = [] ): array;

Set styles for vars type

toJson()

public function toJson( mixed $variable ): string;

Returns an JSON string of information about a single variable.

$foo = [
    "key" => "value",
];

echo (new \Phalcon\Debug\Dump())->toJson($foo);

$foo = new stdClass();
$foo->bar = "buz";

echo (new \Phalcon\Debug\Dump())->toJson($foo);

variable()

public function variable(
    mixed $variable,
    string $name = null
): string;

Returns an HTML string of information about a single variable.

echo (new \Phalcon\Debug\Dump())->variable($foo, "foo");

variables()

public function variables(): string;

Returns an HTML string of debugging information about any number of variables, each wrapped in a "pre" tag.

$foo = "string";
$bar = ["key" => "value"];
$baz = new stdClass();

echo (new \Phalcon\Debug\Dump())->variables($foo, $bar, $baz);
Protected · 2

getStyle()

protected function getStyle( string $type ): string;

Get style for type

output()

protected function output(
    mixed $variable,
    string $name = null,
    int $tab = 1
): string;

Prepare an HTML string of information about a single variable.

Support\Debug\Exception

Class Source on GitHub

Exceptions thrown in Phalcon\Debug will use this class

Uses Phalcon\Support\Exception

Support\Debug\Exceptions\RequestHalted

Class Source on GitHub

Uses Phalcon\Support\Debug\Exception

Method Summary

Methods

Public · 1

__construct()

public function __construct();

Support\Debug\Exceptions\RuntimeWarning

Class Source on GitHub

  • \ErrorException
    • Phalcon\Support\Debug\Exceptions\RuntimeWarning

Support\Exception

Class Source on GitHub

Exceptions thrown in Phalcon\Support will use this class

Support\HelperFactory

Class Source on GitHub

ServiceLocator implementation for helpers

@method string basename(string $uri, string $suffix = null) @method array blacklist(array $collection, array $blackList) @method string camelize(string $text, string $delimiters = null, bool $lowerFirst = false) @method array chunk(array $collection, int $size, bool $preserveKeys = false) @method string concat(string $delimiter, string $first, string $second, string ...$arguments) @method int countVowels(string $text) @method string decapitalize(string $text, bool $upperRest = false, string $encoding = 'UTF-8') @method string decode(string $data, bool $associative = false, int $depth = 512, int $options = 0) @method string decrement(string $text, string $separator = '') @method string dirFromFile(string $file) @method string dirSeparator(string $directory) @method string dynamic(string $text, string $leftDel = "{", string $rightDel = "}", string $separator = "|") @method string encode($data, int $options = 0, int $depth = 512) @method bool endsWith(string $haystack, string $needle, bool $ignoreCase = true) @method mixed filter(array $collection, callable|null $method) @method mixed first(array $collection, callable $method = null) @method string firstBetween(string $text, string $start, string $end) @method mixed firstKey(array $collection, callable $method = null) @method string friendly(string $text, string $separator = '-', bool $lowercase = true, $replace = null) @method array flatten(array $collection, bool $deep = false) @method mixed get(array $collection, $index, $defaultValue = null, string $cast = null) @method array group(array $collection, $method) @method bool has(array $collection, $index) @method string humanize(string $text) @method bool includes(string $haystack, string $needle) @method string increment(string $text, string $separator = '') @method string interpolate(string $message, array $context = [], string $leftToken = "%", string $rightToken = "%") @method bool isAnagram(string $first, string $second) @method bool isBetween(int $value, int $start, int $end) @method bool isLower(string $text, string $encoding = 'UTF-8') @method bool isPalindrome(string $text) @method bool isUnique(array $collection) @method bool isUpper(string $text, string $encoding = 'UTF-8') @method string kebabCase(string $text, string $delimiters = null) @method mixed last(array $collection, callable $method = null) @method mixed lastKey(array $collection, callable $method = null) @method int len(string $text, string $encoding = 'UTF-8') @method string lower(string $text, string $encoding = 'UTF-8') @method array order(array $collection, $attribute, string $order = 'asc') @method string pascalCase(string $text, string $delimiters = null) @method array pluck(array $collection, string $element) @method string prefix(string $text, string $prefix) @method string random(int $type = 0, int $length = 8) @method string reduceSlashes(string $text) @method array set(array $collection, $value, $index = null) @method array sliceLeft(array $collection, int $elements = 1) @method array sliceRight(array $collection, int $elements = 1) @method string snakeCase(string $text, string $delimiters = null) @method array split(array $collection) @method bool startsWith(string $haystack, string $needle, bool $ignoreCase = true) @method string suffix($text, string $suffix) @method object toObject(array $collection) @method bool validateAll(array $collection, callable $method) @method bool validateAny(array $collection, callable $method) @method string ucwords(string $text, string $encoding = 'UTF-8') @method string uncamelize(string $text, string $delimiters = '_') @method string underscore(string $text) @method string upper(string $text, string $encoding = 'UTF-8') @method array whitelist(array $collection, array $whiteList)

Uses Phalcon\Factory\AbstractFactory

Method Summary

Methods

Public · 3

__call()

public function __call(
    string $name,
    array $arguments
);

__construct()

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

FactoryTrait constructor.

newInstance()

public function newInstance( string $name );
Protected · 2

getExceptionClass()

protected function getExceptionClass(): string;

getServices()

protected function getServices(): array;

Returns the available adapters

Support\Helper\Arr\AbstractArr

Abstract Source on GitHub

Abstract class offering methods to help with the Arr namespace. This can be moved to a trait once Zephir supports it.

This base exists only for the Arr helper hierarchy; it is not a general base class. New code that needs these routines should compose the relevant invokable helper (for example Arr\Get) rather than extending it.

@internal

@todo move to trait when there is support for it

Method Summary

Methods

Protected · 1

toFilter()

protected function toFilter(
    array $collection,
    mixed $method = null
): array;

Helper method to filter the collection

Support\Helper\Arr\Blacklist

Class Source on GitHub

Black list filter by key: exclude elements of an array by the keys obtained from the elements of a blacklist

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    array $blackList
): array;

Support\Helper\Arr\Chunk

Class Source on GitHub

Chunks an array into smaller arrays of a specified size.

  • Phalcon\Support\Helper\Arr\Chunk

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    int $size,
    bool $preserveKeys = false
): array;

Support\Helper\Arr\Filter

Class Source on GitHub

Filters a collection using array_filter and using the callable (if defined)

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    mixed $method = null
): mixed;

Support\Helper\Arr\First

Class Source on GitHub

Returns the first element of the collection. If a callable is passed, the element returned is the first that validates true

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    mixed $method = null
): mixed;

Support\Helper\Arr\FirstKey

Class Source on GitHub

Returns the key of the first element of the collection. If a callable is passed, the element returned is the first that validates true

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    mixed $method = null
): mixed;

Support\Helper\Arr\Flatten

Class Source on GitHub

Flattens an array up to the one level depth, unless $deep is set to true

  • Phalcon\Support\Helper\Arr\Flatten

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    bool $deep = false
): array;

Support\Helper\Arr\Get

Class Source on GitHub

Gets an array element by key and if it does not exist returns the default. It also allows for casting the returned value to a specific type using settype internally

  • Phalcon\Support\Helper\Arr\Get

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    mixed $index,
    mixed $defaultValue = null,
    string $cast = null
): mixed;

Support\Helper\Arr\Group

Class Source on GitHub

Groups the elements of an array based on the passed callable

  • Phalcon\Support\Helper\Arr\Group

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    mixed $method
): array;

Support\Helper\Arr\Has

Class Source on GitHub

Checks an array if it has an element with a specific key and returns true/false accordingly

  • Phalcon\Support\Helper\Arr\Has

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    mixed $index
): bool;

Support\Helper\Arr\IsUnique

Class Source on GitHub

Checks a flat list for duplicate values. Returns true if duplicate values exist and false if values are all unique.

  • Phalcon\Support\Helper\Arr\IsUnique

Method Summary

Methods

Public · 1

__invoke()

public function __invoke( array $collection ): bool;

Support\Helper\Arr\Last

Class Source on GitHub

Returns the last element of the collection. If a callable is passed, the element returned is the first that validates true

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    mixed $method = null
): mixed;

Support\Helper\Arr\LastKey

Class Source on GitHub

Returns the key of the last element of the collection. If a callable is passed, the element returned is the first that validates true

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    mixed $method = null
): mixed;

Support\Helper\Arr\Order

Class Source on GitHub

Sorts a collection of arrays or objects by an attribute of the object. It supports ascending/descending sorts but also flags that are identical to the ones used by ksort and krsort

  • Phalcon\Support\Helper\Arr\Order

Method Summary

Constants

int ORDER_ASC = 1
int ORDER_DESC = 2

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    mixed $attribute,
    int $order = self::ORDER_ASC,
    int $flags = 0
): array;

Support\Helper\Arr\Pluck

Class Source on GitHub

Returns a subset of the collection based on the values of the collection

  • Phalcon\Support\Helper\Arr\Pluck

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    string $element
): array;

Support\Helper\Arr\Set

Class Source on GitHub

Sets an array element. Using a key is optional

  • Phalcon\Support\Helper\Arr\Set

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    mixed $value,
    mixed $index = null
): array;

Support\Helper\Arr\SliceLeft

Class Source on GitHub

Returns a new array with n elements removed from the left.

  • Phalcon\Support\Helper\Arr\SliceLeft

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    int $elements = 1
): array;

Support\Helper\Arr\SliceRight

Class Source on GitHub

Returns a new array with n elements removed from the right.

  • Phalcon\Support\Helper\Arr\SliceRight

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    int $elements = 1
): array;

Support\Helper\Arr\Split

Class Source on GitHub

Returns a new array with keys of the collection as one element and values as another

  • Phalcon\Support\Helper\Arr\Split

Method Summary

Methods

Public · 1

__invoke()

public function __invoke( array $collection ): array;

Support\Helper\Arr\ToObject

Class Source on GitHub

Returns the passed array as an object.

  • Phalcon\Support\Helper\Arr\ToObject

Method Summary

Methods

Public · 1

__invoke()

public function __invoke( array $collection ): object;

Support\Helper\Arr\ValidateAll

Class Source on GitHub

Returns true if the provided function returns true for all elements of the collection, false otherwise.

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    mixed $method
): bool;

Support\Helper\Arr\ValidateAny

Class Source on GitHub

Returns true if the provided function returns true for at least one element of the collection, false otherwise.

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    mixed $method
): bool;

Support\Helper\Arr\Whitelist

Class Source on GitHub

White list filter by key: obtain elements of an array filtering by the keys obtained from the elements of a whitelist

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    array $collection,
    array $whiteList
): array;

Support\Helper\Exception

Class Source on GitHub

Exceptions thrown in Phalcon\Support\Helper will use this class

Uses Phalcon\Support\Exception

Support\Helper\File\Basename

Class Source on GitHub

Gets the filename from a given path, Same as PHP's basename() but has non-ASCII support. PHP's basename() does not properly support streams or filenames beginning with a non-US-ASCII character.

  • Phalcon\Support\Helper\File\Basename

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $uri,
    string $suffix = null
): string;

@see https://bugs.php.net/bug.php?id=37738

Support\Helper\Json\Decode

Class Source on GitHub

Decodes a string using json_decode and throws an exception if the JSON data cannot be decoded

The following options are used if none specified for json_encode

JSON_HEX_TAG, JSON_HEX_APOS, JSON_HEX_AMP, JSON_HEX_QUOT, JSON_UNESCAPED_SLASHES

If JSON_THROW_ON_ERROR is defined in the options a JsonException will be thrown in the case of an error. Otherwise, any error will throw JsonDecodeError

  • Phalcon\Support\Helper\Json\Decode

Uses Phalcon\Support\Helper\Json\Exceptions\JsonDecodeError

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $data,
    bool $associative = false,
    int $depth = 512,
    int $options = 79
);

Support\Helper\Json\Encode

Class Source on GitHub

Encodes a string using json_encode and throws an exception if the JSON data cannot be encoded

The following options are used if none specified for json_encode

JSON_HEX_TAG, JSON_HEX_APOS, JSON_HEX_AMP, JSON_HEX_QUOT, JSON_UNESCAPED_SLASHES

If JSON_THROW_ON_ERROR is defined in the options a JsonException will be thrown in the case of an error. Otherwise, any error will throw JsonEncodeError

@see https://www.ietf.org/rfc/rfc4627.txt

  • Phalcon\Support\Helper\Json\Encode

Uses Phalcon\Support\Helper\Json\Exceptions\JsonEncodeError

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    mixed $data,
    int $options = 79,
    int $depth = 512
): string;

Support\Helper\Json\Exceptions\JsonDecodeError

Class Source on GitHub

  • InvalidArgumentException
    • Phalcon\Support\Helper\Json\Exceptions\JsonDecodeError

Uses InvalidArgumentException · Throwable

Method Summary

Methods

Public · 1

__construct()

public function __construct(
    string $message = "",
    int $code = 0,
    Throwable $previous = null
);

Support\Helper\Json\Exceptions\JsonEncodeError

Class Source on GitHub

  • InvalidArgumentException
    • Phalcon\Support\Helper\Json\Exceptions\JsonEncodeError

Uses InvalidArgumentException · Throwable

Method Summary

Methods

Public · 1

__construct()

public function __construct(
    string $message = "",
    int $code = 0,
    Throwable $previous = null
);

Support\Helper\Number\IsBetween

Class Source on GitHub

Checks if a number is within a range

  • Phalcon\Support\Helper\Number\IsBetween

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    int $value,
    int $start,
    int $end
): bool;

Support\Helper\Str\AbstractStr

Abstract Source on GitHub

Abstract class offering methods to help with the Str namespace. This can be moved to a trait once Zephir supports it.

This base exists only for the Str helper hierarchy; it is not a general base class. New code that needs these routines should compose the relevant invokable helper (for example Str\Interpolate) rather than extending it.

@internal

@todo move to trait when there is support for it

Method Summary

Methods

Protected · 5

toEndsWith()

protected function toEndsWith(
    string $haystack,
    string $needle,
    bool $ignoreCase = true
): bool;

Check if a string ends with a given string

toInterpolate()

protected function toInterpolate(
    string $input,
    array $context = [],
    string $left = "%",
    string $right = "%"
): string;

Interpolates context values into the message placeholders

@see https://www.php-fig.org/psr/psr-3/ Section 1.2 Message

toLower()

protected function toLower(
    string $text,
    string $encoding = "UTF-8"
): string;

Lowercases a string using mbstring

toStartsWith()

protected function toStartsWith(
    string $haystack,
    string $needle,
    bool $ignoreCase = true
): bool;

Check if a string starts with a given string

toUpper()

protected function toUpper(
    string $text,
    string $encoding = "UTF-8"
): string;

Uppercases a string using mbstring

Support\Helper\Str\Camelize

Class Source on GitHub

Converts strings to upperCamelCase or lowerCamelCase

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $text,
    string $delimiters = null,
    bool $lowerFirst = false
): string;

Support\Helper\Str\Concat

Class Source on GitHub

Concatenates strings using the separator only once without duplication in places concatenation

Uses Phalcon\Support\Helper\Str\Exceptions\InsufficientArguments

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(): string;

Support\Helper\Str\CountVowels

Class Source on GitHub

Returns number of vowels in provided string. Uses a regular expression to count the number of vowels (A, E, I, O, U) in a string.

  • Phalcon\Support\Helper\Str\CountVowels

Method Summary

Methods

Public · 1

__invoke()

public function __invoke( string $text ): int;

Support\Helper\Str\Decapitalize

Class Source on GitHub

Decapitalizes the first letter of the string and then adds it with rest of the string. Omit the upperRest parameter to keep the rest of the string intact, or set it to true to convert to uppercase.

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $text,
    bool $upperRest = false,
    string $encoding = "UTF-8"
): string;

Support\Helper\Str\Decrement

Class Source on GitHub

Removes a number from the end of a string or decrements that number if it is already defined

  • Phalcon\Support\Helper\Str\Decrement

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $text,
    string $separator = "_"
): string;

Support\Helper\Str\DirFromFile

Class Source on GitHub

Accepts a file name (without extension) and returns a calculated directory structure with the filename in the end

  • Phalcon\Support\Helper\Str\DirFromFile

Method Summary

Methods

Public · 1

__invoke()

public function __invoke( string $file ): string;

Support\Helper\Str\DirSeparator

Class Source on GitHub

Accepts a directory name and ensures that it ends with DIRECTORY_SEPARATOR

  • Phalcon\Support\Helper\Str\DirSeparator

Method Summary

Methods

Public · 1

__invoke()

public function __invoke( string $directory ): string;

Support\Helper\Str\Dynamic

Class Source on GitHub

Generates random text in accordance with the template. The template is defined by the left and right delimiter and it can contain values separated by the separator

  • Phalcon\Support\Helper\Str\Dynamic

Uses Phalcon\Support\Helper\Str\Exceptions\SyntaxError

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $text,
    string $leftDelimiter = "{",
    string $rightDelimiter = "}",
    string $separator = "|"
): string;

Support\Helper\Str\EndsWith

Class Source on GitHub

Check if a string ends with a given string

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $haystack,
    string $needle,
    bool $ignoreCase = true
): bool;

Support\Helper\Str\Exceptions\InsufficientArguments

Class Source on GitHub

Uses Phalcon\Support\Helper\Exception

Method Summary

Methods

Public · 1

__construct()

public function __construct();

Support\Helper\Str\Exceptions\InvalidReplaceFormat

Class Source on GitHub

Uses Phalcon\Support\Helper\Exception

Support\Helper\Str\Exceptions\SyntaxError

Class Source on GitHub

  • RuntimeException
    • Phalcon\Support\Helper\Str\Exceptions\SyntaxError

Uses RuntimeException

Method Summary

Methods

Public · 1

__construct()

public function __construct( string $text );

Support\Helper\Str\FirstBetween

Class Source on GitHub

Returns the first string there is between the strings from the parameter start and end.

  • Phalcon\Support\Helper\Str\FirstBetween

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $text,
    string $start,
    string $end
): string;

Support\Helper\Str\Friendly

Class Source on GitHub

Changes a text to a URL friendly one. Replaces commonly known accented characters with their Latin equivalents. If a replace string or array is passed, it will also be used to replace those characters with a space.

Uses Phalcon\Support\Helper\Str\Exceptions\InvalidReplaceFormat

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $text,
    string $separator = "-",
    bool $lowercase = true,
    mixed $replace = null
): string;

Support\Helper\Str\Humanize

Class Source on GitHub

Makes an underscored or dashed text human-readable

  • Phalcon\Support\Helper\Str\Humanize

Method Summary

Methods

Public · 1

__invoke()

public function __invoke( string $text ): string;

Support\Helper\Str\Includes

Class Source on GitHub

Determines whether a string includes another string or not.

  • Phalcon\Support\Helper\Str\Includes

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $haystack,
    string $needle
): bool;

Support\Helper\Str\Increment

Class Source on GitHub

Adds a number to the end of a string or increments that number if it is already defined

  • Phalcon\Support\Helper\Str\Increment

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $text,
    string $separator = "_"
): string;

Support\Helper\Str\Interpolate

Class Source on GitHub

Interpolates context values into the message placeholders. By default, the right and left tokens are %

@see https://www.php-fig.org/psr/psr-3/ Section 1.2 Message

  • Phalcon\Support\Helper\Str\Interpolate

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $message,
    array $context = [],
    string $leftToken = "%",
    string $rightToken = "%"
): string;

Support\Helper\Str\IsAnagram

Class Source on GitHub

Compare two strings and returns true if both strings are anagram, false otherwise.

  • Phalcon\Support\Helper\Str\IsAnagram

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $first,
    string $second
): bool;

Support\Helper\Str\IsLower

Class Source on GitHub

Returns true if the given string is in lower case, false otherwise.

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $text,
    string $encoding = "UTF-8"
): bool;

Support\Helper\Str\IsPalindrome

Class Source on GitHub

Returns true if the given string is a palindrome, false otherwise.

  • Phalcon\Support\Helper\Str\IsPalindrome

Method Summary

Methods

Public · 1

__invoke()

public function __invoke( string $text ): bool;

Support\Helper\Str\IsUpper

Class Source on GitHub

Returns true if the given string is in upper case, false otherwise.

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $text,
    string $encoding = "UTF-8"
): bool;

Support\Helper\Str\KebabCase

Class Source on GitHub

Converts strings to kebab-case style

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $text,
    string $delimiters = null
): string;

Support\Helper\Str\Len

Class Source on GitHub

Calculates the length of the string using mb_strlen

  • Phalcon\Support\Helper\Str\Len

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $text,
    string $encoding = "UTF-8"
): int;

Support\Helper\Str\Lower

Class Source on GitHub

Converts a string to lowercase using mbstring

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $text,
    string $encoding = "UTF-8"
): string;

Support\Helper\Str\PascalCase

Class Source on GitHub

Converts strings to PascalCase style

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $text,
    string $delimiters = null
): string;
Protected · 1

processArray()

protected function processArray(
    string $text,
    string $delimiters = null
): array;

Support\Helper\Str\Prefix

Class Source on GitHub

Prefixes the text with the supplied prefix

  • Phalcon\Support\Helper\Str\Prefix

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    mixed $text,
    string $prefix
): string;

Support\Helper\Str\Random

Class Source on GitHub

Generates a random string based on the given type. Type is one of the RANDOM_* constants

  • Phalcon\Support\Helper\Str\Random

Method Summary

Constants

int RANDOM_ALNUM = 0 Only alphanumeric characters [a-zA-Z0-9]
int RANDOM_ALPHA = 1 Only alphabetical characters [azAZ]
int RANDOM_DISTINCT = 5 Only alphanumeric uppercase characters exclude similar characters [2345679ACDEFHJKLMNPRSTUVWXYZ]
int RANDOM_HEXDEC = 2 Only hexadecimal characters [0-9a-f]
int RANDOM_NOZERO = 4 Only numbers without 0 [1-9]
int RANDOM_NUMERIC = 3 Only numbers [0-9]

Methods

Public · 1

__invoke()

public function __invoke(
    int $type = self::RANDOM_ALNUM,
    int $length = 8
): string;

Support\Helper\Str\ReduceSlashes

Class Source on GitHub

Reduces multiple slashes in a string to single slashes

  • Phalcon\Support\Helper\Str\ReduceSlashes

Method Summary

Methods

Public · 1

__invoke()

public function __invoke( string $text ): string;

Support\Helper\Str\SnakeCase

Class Source on GitHub

Converts strings to snake_case style

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $text,
    string $delimiters = null
): string;

Support\Helper\Str\StartsWith

Class Source on GitHub

Check if a string starts with a given string

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $haystack,
    string $needle,
    bool $ignoreCase = true
): bool;

Support\Helper\Str\Suffix

Class Source on GitHub

Suffixes the text with the supplied suffix

  • Phalcon\Support\Helper\Str\Suffix

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    mixed $text,
    string $suffix
): string;

Support\Helper\Str\Ucwords

Class Source on GitHub

Capitalizes the first letter of each word

  • Phalcon\Support\Helper\Str\Ucwords

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $text,
    string $encoding = "UTF-8"
): string;

Support\Helper\Str\Uncamelize

Class Source on GitHub

Converts strings to non camelized style

  • Phalcon\Support\Helper\Str\Uncamelize

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $text,
    string $delimiter = "_"
): string;

Support\Helper\Str\Underscore

Class Source on GitHub

Makes a text underscored instead of spaced

  • Phalcon\Support\Helper\Str\Underscore

Method Summary

Methods

Public · 1

__invoke()

public function __invoke( string $text ): string;

Support\Helper\Str\Upper

Class Source on GitHub

Converts a string to uppercase using mbstring

Method Summary

Methods

Public · 1

__invoke()

public function __invoke(
    string $text,
    string $encoding = "UTF-8"
): string;

Support\Registry

Final Source on GitHub

A registry is a container for storing objects and values in the application space. By storing the value in a registry, the same object is always available throughout your application.

$registry = new \Phalcon\Registry();

// Set value
$registry->something = "something";
// or
$registry["something"] = "something";

// Get value
$value = $registry->something;
// or
$value = $registry["something"];

// Check if the key exists
$exists = isset($registry->something);
// or
$exists = isset($registry["something"]);

// Unset
unset($registry->something);
// or
unset($registry["something"]);

In addition to ArrayAccess, Phalcon\Registry also implements Countable (count($registry) will return the number of elements in the registry), Serializable and Iterator (you can iterate over the registry using a foreach loop) interfaces. For PHP 5.4 and higher, JsonSerializable interface is implemented.

Phalcon\Registry is very fast (it is typically faster than any userspace implementation of the registry); however, this comes at a price: Phalcon\Registry is a final class and cannot be inherited from.

Though Phalcon\Registry exposes methods like __get(), offsetGet(), count() etc, it is not recommended to invoke them manually (these methods exist mainly to match the interfaces the registry implements): $registry->__get("property") is several times slower than $registry->property.

Internally all the magic methods (and interfaces except JsonSerializable) are implemented using object handlers or similar techniques: this allows to bypass relatively slow method calls.

Uses Phalcon\Support\Collection · Traversable

Method Summary

public __construct( array $data = [] ) Constructor public mixed __get( string $element ) Magic getter to get an element from the collection public bool __isset( string $element ) Magic isset to check whether an element exists or not public void __set(string $element,mixed $value) Magic setter to assign values to an element public void __unset( string $element ) Magic unset to remove an element from the collection public void clear() Clears the internal collection public int count() Count elements of an object public mixed get(string $element,mixed $defaultValue = null,string $cast = null) Get the element from the collection public Traversable getIterator() Returns the iterator of the class public bool has( string $element ) Determines whether an element is present in the collection. public void init( array $data = [] ) Initialize internal array public array jsonSerialize() Specify data which should be serialized to JSON public bool offsetExists( mixed $element ) Whether a offset exists public mixed offsetGet( mixed $element ) Offset to retrieve public void offsetSet(mixed $element,mixed $value) Offset to set public void offsetUnset( mixed $element ) Offset to unset public void remove( string $element ) Delete the element from the collection public string|null serialize() String representation of object public void set(string $element,mixed $value) Set an element in the collection public array toArray() Returns the object in an array format public string toJson( int $options = 79 ) Returns the object in a JSON format public void unserialize( string $data ) Constructs the object

Methods

Public · 22

__construct()

final public function __construct( array $data = [] );

Constructor

__get()

final public function __get( string $element ): mixed;

Magic getter to get an element from the collection

__isset()

final public function __isset( string $element ): bool;

Magic isset to check whether an element exists or not

__set()

final public function __set(
    string $element,
    mixed $value
): void;

Magic setter to assign values to an element

__unset()

final public function __unset( string $element ): void;

Magic unset to remove an element from the collection

clear()

final public function clear(): void;

Clears the internal collection

count()

final public function count(): int;

Count elements of an object

@link https://php.net/manual/en/countable.count.php

get()

final public function get(
    string $element,
    mixed $defaultValue = null,
    string $cast = null
): mixed;

Get the element from the collection

getIterator()

final public function getIterator(): Traversable;

Returns the iterator of the class

has()

final public function has( string $element ): bool;

Determines whether an element is present in the collection.

init()

final public function init( array $data = [] ): void;

Initialize internal array

jsonSerialize()

final public function jsonSerialize(): array;

Specify data which should be serialized to JSON

@link https://php.net/manual/en/jsonserializable.jsonserialize.php

offsetExists()

final public function offsetExists( mixed $element ): bool;

Whether a offset exists

@link https://php.net/manual/en/arrayaccess.offsetexists.php

offsetGet()

final public function offsetGet( mixed $element ): mixed;

Offset to retrieve

@link https://php.net/manual/en/arrayaccess.offsetget.php

offsetSet()

final public function offsetSet(
    mixed $element,
    mixed $value
): void;

Offset to set

@link https://php.net/manual/en/arrayaccess.offsetset.php

offsetUnset()

final public function offsetUnset( mixed $element ): void;

Offset to unset

@link https://php.net/manual/en/arrayaccess.offsetunset.php

remove()

final public function remove( string $element ): void;

Delete the element from the collection

serialize()

final public function serialize(): string|null;

String representation of object

@link https://php.net/manual/en/serializable.serialize.php

set()

final public function set(
    string $element,
    mixed $value
): void;

Set an element in the collection

toArray()

final public function toArray(): array;

Returns the object in an array format

toJson()

final public function toJson( int $options = 79 ): string;

Returns the object in a JSON format

The default string uses the following options for json_encode

JSON_HEX_TAG, JSON_HEX_APOS, JSON_HEX_AMP, JSON_HEX_QUOT, JSON_UNESCAPED_SLASHES

@see https://www.ietf.org/rfc/rfc4627.txt

unserialize()

final public function unserialize( string $data ): void;

Constructs the object

@link https://php.net/manual/en/serializable.unserialize.php

Support\Settings

Class Source on GitHub

Phalcon\Support\Settings

Provides a PHP-userland layer for reading and overriding the Phalcon extension's ini settings (orm., db., form.*).

get() checks PHP-level overrides first, then falls back to globals_get() which reads the value configured in php.ini / .htaccess / per-virtualhost.

set() stores the value in the PHP-level overrides array only. It does NOT call globals_set(), so the change is confined to this static state and never modifies the underlying C struct. This prevents settings changed by one project from leaking into another project sharing the same PHP worker process.

NOTE: In non-ZTS (non-thread-safe) PHP builds, globals_get() reads from a process-level C struct. Because set() does not write to that struct, any value set via ini_set("phalcon.orm.*", ...) or globals_set() by other code remains visible through get() as the fallback for keys that have no PHP-level override. In ZTS builds each thread has its own copy of the struct.

reset() clears only the keys that were previously set via set(), restoring those keys to their globals_get() fallback values.

  • Phalcon\Support\Settings

Method Summary

Properties

protected array $overrides PHP-level overrides. Keys stored here take priority over globals_get().

Methods

Public · 3

get()

public static function get( string $key ): mixed;

Returns the value of a known setting.

Resolution order: 1. PHP-level override (set via Settings::set()) 2. globals_get() - the C-level value, honoring php.ini / .htaccess 3. null - for unknown keys

reset()

public static function reset(): void;

Clears all PHP-level overrides, restoring get() to return globals_get() fallback values (as configured in php.ini or .htaccess).

set()

public static function set(
    string $key,
    mixed $value
): void;

Overrides a setting at the PHP level.

Does NOT call globals_set(), so the C-level struct is not modified and no other project sharing this PHP process is affected.

Unknown keys are silently ignored.

Support\Version

Class Source on GitHub

This class allows to get the installed version of the framework

  • Phalcon\Support\Version

Method Summary

Constants

int VERSION_MAJOR = 0 The constant referencing the major version. Returns 0 ``php echo (new Phalcon\Support\Version()) ->getPart(Phalcon\Support\Version::VERSION_MAJOR); ``
int VERSION_MEDIUM = 1 The constant referencing the major version. Returns 1 ``php echo (new Phalcon\Support\Version()) ->getPart(Phalcon\Support\Version::VERSION_MEDIUM); ``
int VERSION_MINOR = 2 The constant referencing the major version. Returns 2 ``php echo (new Phalcon\Support\Version()) ->getPart(Phalcon\Support\Version::VERSION_MINOR); ``
int VERSION_SPECIAL = 3 The constant referencing the major version. Returns 3 ``php echo (new Phalcon\Support\Version()) ->getPart(Phalcon\Support\Version::VERSION_SPECIAL); ``
int VERSION_SPECIAL_NUMBER = 4 The constant referencing the major version. Returns 4 ``php echo (new Phalcon\Support\Version()) ->getPart(Phalcon\Support\Version::VERSION_SPECIAL_NUMBER); ``

Methods

Public · 3

get()

public function get(): string;

Returns the active version (string)

echo (new Phalcon\Version())->get();

getId()

public function getId(): string;

Returns the numeric active version

echo (new Phalcon\Version())->getId();

getPart()

public function getPart( int $part ): string;

Returns a specific part of the version. If the wrong parameter is passed it will return the full version

echo (new Phalcon\Version())->getPart(Phalcon\Version::VERSION_MAJOR);
Protected · 2

getSpecial()

protected final function getSpecial( int $special ): string;

Translates a number to a special release.

getVersion()

protected function getVersion(): array;

Area where the version number is set. The format is as follows: ABBCCDE

A - Major version B - Med version (two digits) C - Min version (two digits) D - Special release: 1 = alpha, 2 = beta, 3 = RC, 4 = stable E - Special release version i.e. RC1, Beta2 etc.