Skip to content

Phalcon traits

NOTE

All classes are prefixed with Phalcon

Traits\Factory\ConfigTrait

Trait Source on GitHub

  • Phalcon\Traits\Factory\ConfigTrait

Uses Phalcon\Config\ConfigInterface

Used by Phalcon\Auth\ManagerFactory

Method Summary

Methods

Protected · 2

checkConfig()

protected function checkConfig( mixed $config ): array;

checkConfigElement()

protected function checkConfigElement(
    array $config,
    string $element
): array;

Checks if the config has a specific element

Traits\Factory\FactoryTrait

Trait Source on GitHub

Methods allowing a mapper based factory to operate. Supports injected services, getting a service by name (key), initialization and setting of the exception class (when exceptions are needed to be thrown)

  • Phalcon\Traits\Factory\FactoryTrait

Uses Exception

Method Summary

Methods

Protected · 5

getCachedInstance()

protected function getCachedInstance(
    string $name,
    mixed $arguments
): object;

Return an object from the instances pool. If it does not exist, create it

getExceptionClass()

abstract protected function getExceptionClass(): string;

Returns the exception class for the factory

getService()

protected function getService( string $name ): string;

Returns a service based on the name; throws exception if it does not exist

getServices()

abstract protected function getServices(): array;

Returns the services for the factory

init()

protected function init( array $services = [] ): void;

Initializes services

Traits\Php\ApcuTrait

Trait Source on GitHub

APCu based wrapper methods

  • Phalcon\Traits\Php\ApcuTrait

Used by Phalcon\Storage\Adapter\Apcu

Method Summary

Methods

Protected · 7

phpApcuDec()

protected static function phpApcuDec(
    mixed $key,
    int $step = 1
): bool|int;

@link https://php.net/manual/en/function.apcu-dec.php

phpApcuDelete()

protected static function phpApcuDelete( mixed $key ): bool|array;

@link https://php.net/manual/en/function.apcu-delete.php

phpApcuExists()

protected static function phpApcuExists( mixed $key ): bool|array;

@link https://php.net/manual/en/function.apcu-exists.php

phpApcuFetch()

protected static function phpApcuFetch( mixed $key ): mixed;

@link https://php.net/manual/en/function.apcu-fetch.php

phpApcuInc()

protected static function phpApcuInc(
    mixed $key,
    int $step = 1
): bool|int;

@link https://php.net/manual/en/function.apcu-inc.php

phpApcuIterator()

protected static function phpApcuIterator( string $pattern ): \APCUIterator|bool;

@link https://php.net/manual/en/class.apcuiterator.php

phpApcuStore()

protected static function phpApcuStore(
    mixed $key,
    mixed $payload,
    int $ttl = 0
): bool|array;

@link https://php.net/manual/en/function.apcu-store.php

Traits\Php\Base64Trait

Trait Source on GitHub

Base64 based wrapper methods

  • Phalcon\Traits\Php\Base64Trait

Used by Phalcon\Encryption\Crypt · Phalcon\Encryption\Security\JWT\Builder · Phalcon\Encryption\Security\JWT\Token\Parser · Phalcon\Storage\Serializer\Base64

Method Summary

Methods

Protected · 4

doDecodeUrl()

protected static function doDecodeUrl( string $input ): string;

Decode a Base64 URL string

doEncodeUrl()

protected static function doEncodeUrl( string $input ): string;

Encode a string in Base64 URL format

phpBase64Decode()

protected static function phpBase64Decode(
    string $input,
    bool $strict = false
): string|false;

@link https://php.net/manual/en/function.base64-decode.php

phpBase64Encode()

protected static function phpBase64Encode( string $input ): string;

@link https://php.net/manual/en/function.base64-encode.php

Traits\Php\FileTrait

Trait Source on GitHub

File based wrapper methods

  • Phalcon\Traits\Php\FileTrait

Used by Phalcon\Annotations\Adapter\Stream · Phalcon\Assets\Asset · Phalcon\Assets\Collection · Phalcon\Assets\Manager · Phalcon\Auth\Adapter\Stream · Phalcon\Cli\Console · Phalcon\Config\Adapter\Json · Phalcon\Encryption\Security\Uuid\SysNodeProvider · Phalcon\Forms\Loader\JsonLoader · Phalcon\Http\Request · Phalcon\Image\Adapter\Gd · Phalcon\Image\Adapter\Imagick · Phalcon\Logger\Adapter\Stream · Phalcon\Mvc\Application · Phalcon\Mvc\Model\MetaData\Stream · Phalcon\Mvc\Router · Phalcon\Mvc\View · Phalcon\Mvc\View\Engine\Volt\Compiler · Phalcon\Mvc\View\Simple · Phalcon\Queue\Adapter\Beanstalk\BeanstalkConnection · Phalcon\Queue\Adapter\Stream\StreamContext · Phalcon\Session\Adapter\Stream · Phalcon\Storage\Adapter\Stream · Phalcon\Translate\Adapter\Csv

Method Summary

Methods

Protected · 9

phpFclose()

protected static function phpFclose( mixed $handle ): bool;

Closes an open file pointer

@link https://php.net/manual/en/function.fclose.php

phpFgetCsv()

protected static function phpFgetCsv(
    mixed $stream,
    int $length = 0,
    string $separator = ",",
    mixed $enclosure = null,
    mixed $escape = null
): array|false;

Gets line from file pointer and parse for CSV fields

@link https://php.net/manual/en/function.fgetcsv.php

phpFileExists()

protected static function phpFileExists( string $filename ): bool;

@link https://php.net/manual/en/function.file-exists.php

phpFileGetContents()

protected static function phpFileGetContents(
    string $filename,
    bool $useIncludePath = false,
    mixed $context = null,
    int $offset = 0,
    int|null $length = null
): false|string;

@link https://php.net/manual/en/function.file-get-contents.php

phpFilePutContents()

protected static function phpFilePutContents(
    string $filename,
    mixed $data,
    int $flags = 0,
    mixed $context = null
): false|int;

@link https://php.net/manual/en/function.file-put-contents.php

phpFopen()

protected static function phpFopen(
    string $filename,
    string $mode,
    bool $useIncludePath = false,
    mixed $context = null
): mixed;

@link https://php.net/manual/en/function.fopen.php

phpFwrite()

protected static function phpFwrite(
    mixed $handle,
    string $data,
    int|null $length = null
): false|int;

Binary-safe file write

@link https://php.net/manual/en/function.fwrite.php

phpIsWritable()

protected static function phpIsWritable( string $filename ): bool;

Tells whether the filename is writable

@link https://php.net/manual/en/function.is-writable.php

protected static function phpUnlink(
    string $filename,
    mixed $context = null
): bool;

@link https://php.net/manual/en/function.unlink.php

Traits\Php\HashTrait

Trait Source on GitHub

Hashing method wrappers

  • Phalcon\Traits\Php\HashTrait

Used by Phalcon\Assets\Asset · Phalcon\Assets\Inline · Phalcon\Encryption\Crypt · Phalcon\Encryption\Security · Phalcon\Encryption\Security\JWT\Signer\Hmac

Method Summary

Methods

Protected · 3

phpHash()

protected static function phpHash(
    string $algorithm,
    string $data,
    bool $binary = false
): string;

@link https://php.net/manual/en/function.hash.php

phpHashEquals()

protected static function phpHashEquals(
    string $knownString,
    string $userString
): bool;

@link https://php.net/manual/en/function.hash-equals.php

phpHashHmac()

protected static function phpHashHmac(
    string $algorithm,
    string $data,
    string $key,
    bool $binary = false
): string;

@link https://php.net/manual/en/function.hash-hmac.php

Traits\Php\HeaderTrait

Trait Source on GitHub

Header based wrapper methods

  • Phalcon\Traits\Php\HeaderTrait

Used by Phalcon\Session\Manager

Method Summary

Methods

Protected · 1

phpHeadersSent()

protected static function phpHeadersSent(): bool;

Checks if or where headers have been sent

@link https://php.net/manual/en/function.headers-sent.php

Traits\Php\IgbinaryTrait

Trait Source on GitHub

Igbinary based wrapper methods

  • Phalcon\Traits\Php\IgbinaryTrait

Used by Phalcon\Storage\Serializer\Igbinary

Method Summary

Methods

Protected · 2

phpIgbinarySerialize()

protected static function phpIgbinarySerialize( mixed $value ): string|null;

@link https://php.net/manual/en/function.igbinary-serialize.php

phpIgbinaryUnserialize()

protected static function phpIgbinaryUnserialize( mixed $value );

@link https://php.net/manual/en/function.igbinary-unserialize.php

Traits\Php\InfoTrait

Trait Source on GitHub

Information method wrappers

  • Phalcon\Traits\Php\InfoTrait

Used by Phalcon\Config\Adapter\Yaml · Phalcon\Encryption\Crypt · Phalcon\Encryption\Security\Uuid\SysNodeProvider · Phalcon\Filter\Validation\Validator\Confirmation · Phalcon\Filter\Validation\Validator\File\MimeType · Phalcon\Filter\Validation\Validator\StringLength\Max · Phalcon\Filter\Validation\Validator\StringLength\Min · Phalcon\Forms\Loader\YamlLoader · Phalcon\Http\Response · Phalcon\Image\Adapter\Gd · Phalcon\Mvc\View\Engine\Volt · Phalcon\Queue\Consumer\Worker · Phalcon\Support\Debug\ReportBuilder · Phalcon\Support\Helper\Arr\Group · Phalcon\Translate\Adapter\Gettext

Method Summary

Methods

Protected · 2

phpExtensionLoaded()

protected static function phpExtensionLoaded( string $name ): bool;

Find out whether an extension is loaded

@link https://php.net/manual/en/function.extension-loaded.php

phpFunctionExists()

protected static function phpFunctionExists( string $functionName ): bool;

Return true if the given function has been defined

@link https://php.net/manual/en/function.function-exists.php

Traits\Php\IniTrait

Trait Source on GitHub

  • Phalcon\Traits\Php\IniTrait

Used by Phalcon\Config\Adapter\Ini · Phalcon\Session\Adapter\Stream

Method Summary

Methods

Protected · 4

phpIniGet()

protected static function phpIniGet(
    string $input,
    string $defaultValue = ""
): string;

Gets the value of a configuration option

@link https://php.net/manual/en/function.ini-get.php @link https://php.net/manual/en/ini.list.php

phpIniGetBool()

protected static function phpIniGetBool(
    string $input,
    bool $defaultValue = false
): bool;

Query a php.ini value and return it back as boolean

@link https://php.net/manual/en/function.ini-get.php @link https://php.net/manual/en/ini.list.php

phpIniGetInt()

protected static function phpIniGetInt(
    string $input,
    int $defaultValue = 0
): int;

Query a php.ini value and return it back as integer

@link https://php.net/manual/en/function.ini-get.php @link https://php.net/manual/en/ini.list.php

phpParseIniFile()

protected static function phpParseIniFile(
    string $filename,
    bool $processSections = false,
    int $scannerMode = 0
): array|false;

Parse a configuration file

@link https://php.net/manual/en/function.parse-ini-file.php

Traits\Php\MbCaseTrait

Trait Source on GitHub

Multibyte case conversion wrapper method

  • Phalcon\Traits\Php\MbCaseTrait

Used by Phalcon\Filter\Sanitize\Lower · Phalcon\Filter\Sanitize\Upper · Phalcon\Filter\Sanitize\UpperWords

Method Summary

Methods

Protected · 1

phpMbConvertCase()

protected static function phpMbConvertCase(
    string $input,
    int $mode
): string;

Converts the case of a string using mb_convert_case()

@link https://php.net/manual/en/function.mb-convert-case.php

Traits\Php\MsgpackTrait

Trait Source on GitHub

MessagePack based wrapper methods

  • Phalcon\Traits\Php\MsgpackTrait

Used by Phalcon\Storage\Serializer\Msgpack

Method Summary

Methods

Protected · 2

phpMsgpackPack()

protected static function phpMsgpackPack( mixed $value ): string;

@link https://php.net/manual/en/function.msgpack-pack.php

phpMsgpackUnpack()

protected static function phpMsgpackUnpack( mixed $value );

@link https://php.net/manual/en/function.msgpack-unpack.php

Traits\Php\OpensslTrait

Trait Source on GitHub

OpenSSL based wrapper methods

  • Phalcon\Traits\Php\OpensslTrait

Used by Phalcon\Encryption\Crypt

Method Summary

Methods

Protected · 2

phpOpensslCipherIvLength()

protected static function phpOpensslCipherIvLength( string $cipher ): int|bool;

@link https://php.net/manual/en/function.openssl-cipher-iv-length.php

phpOpensslRandomPseudoBytes()

protected static function phpOpensslRandomPseudoBytes( int $length );

@link https://php.net/manual/en/function.openssl-random-pseudo-bytes.php

Traits\Php\SerializeTrait

Trait Source on GitHub

PHP serialize/unserialize wrapper methods

  • Phalcon\Traits\Php\SerializeTrait

Used by Phalcon\Storage\Serializer\Php

Method Summary

Methods

Protected · 2

phpSerialize()

protected static function phpSerialize( mixed $value ): string;

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

phpUnserialize()

protected static function phpUnserialize(
    string $data,
    array $options = []
): mixed;

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

Traits\Php\UrlTrait

Trait Source on GitHub

URL based wrapper methods

  • Phalcon\Traits\Php\UrlTrait

Used by Phalcon\Html\Escaper\UrlEscaper · Phalcon\Http\Response

Method Summary

Methods

Protected · 3

phpParseUrl()

protected static function phpParseUrl(
    string $url,
    int $component = -1
);

@link https://php.net/manual/en/function.parse-url.php

phpRawUrlDecode()

protected static function phpRawUrlDecode( string $input ): string;

@link https://php.net/manual/en/function.rawurldecode.php

phpRawUrlEncode()

protected static function phpRawUrlEncode( string $input ): string;

@link https://php.net/manual/en/function.rawurlencode.php

Traits\Php\YamlTrait

Trait Source on GitHub

YAML based wrapper methods

  • Phalcon\Traits\Php\YamlTrait

Used by Phalcon\Config\Adapter\Yaml

Method Summary

Methods

Protected · 1

phpYamlParseFile()

protected static function phpYamlParseFile(
    string $filename,
    int $pos = 0,
    array $callbacks = []
);

Parse a YAML stream from a file

@link https://php.net/manual/en/function.yaml-parse-file.php

Traits\Support\Helper\Arr\FilterTrait

Trait Source on GitHub

Filters a collection using array_filter with an optional callable

  • Phalcon\Traits\Support\Helper\Arr\FilterTrait

Used by Phalcon\Support\Helper\Arr\AbstractArr

Method Summary

Methods

Protected · 1

toFilter()

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

Helper method to filter the collection

Traits\Support\Helper\Arr\GetTrait

Trait 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\Traits\Support\Helper\Arr\GetTrait

Used by Phalcon\ADR\Middleware\CorsMiddleware · Phalcon\Annotations\AnnotationsFactory · Phalcon\Db\Adapter\PdoFactory · Phalcon\Filter\Validation\Validator\File · Phalcon\Http\Cookie · Phalcon\Http\Request\File · Phalcon\Image\ImageFactory · Phalcon\Logger\LoggerFactory · Phalcon\Mvc\Model\MetaData · Phalcon\Session\Adapter\AbstractAdapter · Phalcon\Session\Adapter\Stream · Phalcon\Session\Manager · Phalcon\Storage\Adapter\AbstractAdapter · Phalcon\Support\Debug · Phalcon\Support\Debug\ReportBuilder · Phalcon\Support\Helper\Arr\Get

Method Summary

Methods

Protected · 1

getArrVal()

protected static function getArrVal(
    array $collection,
    mixed $index,
    mixed $defaultValue = null,
    string|null $cast = null
): mixed;

Traits\Support\Helper\Json\DecodeTrait

Trait Source on GitHub

Decodes a string using json_decode, throwing the native \JsonException on failure. Any framework-flavored exception is added by the Support helper class that wraps this trait.

  • Phalcon\Traits\Support\Helper\Json\DecodeTrait

Used by Phalcon\Support\Helper\Json\Decode

Method Summary

Methods

Protected · 1

toDecode()

protected static function toDecode(
    string $data,
    bool $associative = false,
    int $depth = 512,
    int $options = 79
);

Decodes a string using json_decode

Traits\Support\Helper\Json\EncodeTrait

Trait Source on GitHub

Encodes data using json_encode, throwing the native \JsonException on failure. Any framework-flavored exception is added by the Support helper class that wraps this trait.

  • Phalcon\Traits\Support\Helper\Json\EncodeTrait

Used by Phalcon\Logger\Formatter\Json · Phalcon\Support\Helper\Json\Encode

Method Summary

Methods

Protected · 1

toEncode()

protected static function toEncode(
    mixed $data,
    int $options = 79,
    int $depth = 512
): string;

Encodes data using json_encode

Traits\Support\Helper\Str\CamelizeTrait

Trait Source on GitHub

Converts strings to upperCamelCase or lowerCamelCase

  • Phalcon\Traits\Support\Helper\Str\CamelizeTrait

Used by Phalcon\Support\Helper\Str\Camelize

Method Summary

Methods

Public · 1

toCamelize()

public static function toCamelize(
    string $text,
    string $delimiters = "-_",
    bool $lowerFirst = false
): string;

Traits\Support\Helper\Str\DirFromFileTrait

Trait Source on GitHub

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

  • Phalcon\Traits\Support\Helper\Str\DirFromFileTrait

Used by Phalcon\Storage\Adapter\Stream · Phalcon\Support\Helper\Str\DirFromFile

Method Summary

Methods

Protected · 1

toDirFromFile()

protected static function toDirFromFile(
    string $file,
    bool $filesystemSafe = false
): string;

Traits\Support\Helper\Str\DirSeparatorTrait

Trait Source on GitHub

Accepts a directory name and ensures that it ends with DIRECTORY_SEPARATOR

  • Phalcon\Traits\Support\Helper\Str\DirSeparatorTrait

Used by Phalcon\Mvc\View · Phalcon\Mvc\View\Simple · Phalcon\Session\Adapter\Stream · Phalcon\Storage\Adapter\Stream · Phalcon\Support\Helper\Str\DirSeparator

Method Summary

Methods

Protected · 1

toDirSeparator()

protected static function toDirSeparator( string $directory ): string;

Traits\Support\Helper\Str\EndsWithTrait

Trait Source on GitHub

Check if a string ends with a given string

  • Phalcon\Traits\Support\Helper\Str\EndsWithTrait

Used by Phalcon\Support\Helper\Str\AbstractStr

Method Summary

Methods

Protected · 1

toEndsWith()

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

Traits\Support\Helper\Str\InterpolateTrait

Trait Source on GitHub

Interpolates context values into the message placeholders

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

  • Phalcon\Traits\Support\Helper\Str\InterpolateTrait

Used by Phalcon\Logger\Formatter\AbstractFormatter · Phalcon\Support\Debug\Dump · Phalcon\Support\Debug\Renderer\HtmlRenderer · Phalcon\Support\Helper\Str\AbstractStr · Phalcon\Support\Helper\Str\Interpolate · Phalcon\Translate\Interpolator\AssociativeArray

Method Summary

Methods

Protected · 1

toInterpolate()

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

Traits\Support\Helper\Str\LowerTrait

Trait Source on GitHub

Lowercases a string using mbstring

  • Phalcon\Traits\Support\Helper\Str\LowerTrait

Used by Phalcon\Support\Helper\Str\AbstractStr

Method Summary

Methods

Protected · 1

toLower()

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

Traits\Support\Helper\Str\StartsWithTrait

Trait Source on GitHub

Check if a string starts with a given string

  • Phalcon\Traits\Support\Helper\Str\StartsWithTrait

Used by Phalcon\Support\Helper\Str\AbstractStr

Method Summary

Methods

Protected · 1

toStartsWith()

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

Traits\Support\Helper\Str\UncamelizeTrait

Trait Source on GitHub

Converts strings to non camelized style

  • Phalcon\Traits\Support\Helper\Str\UncamelizeTrait

Used by Phalcon\Support\Helper\Str\Uncamelize

Method Summary

Methods

Protected · 1

toUncamelize()

protected static function toUncamelize(
    string $text,
    string $delimiter = "_"
): string;

Traits\Support\Helper\Str\UpperTrait

Trait Source on GitHub

Uppercases a string using mbstring

  • Phalcon\Traits\Support\Helper\Str\UpperTrait

Used by Phalcon\Support\Helper\Str\AbstractStr

Method Summary

Methods

Protected · 1

toUpper()

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