Phalcon 支持
注意
所有类都以前缀命名Phalcon
支持\Collection¶
-
命名空间
Phalcon\Support
-
使用
ArrayAccess
ArrayIterator
Countable
InvalidArgumentException
IteratorAggregate
JsonSerializable
Phalcon\Support\Collection\CollectionInterface
Serializable
Traversable
-
继承
-
实现
ArrayAccess
CollectionInterface
Countable
IteratorAggregate
JsonSerializable
Serializable
Phalcon\Support\Collection
是一个增强型的面向对象数组。它实现了: -ArrayAccess - Countable - IteratorAggregate - JsonSerializable - Serializable
它可以在应用程序中需要数据集合的任何部分使用。例如,访问全局变量时就使用了这些实现$_GET
, $_POST
等等。
@property 数组 $data @property 布尔值 $insensitive @property 数组 $lowerKeys
属性¶
/**
* @var array
*/
protected $data;
/**
* @var bool
*/
protected $insensitive = true;
/**
* @var array
*/
protected $lowerKeys;
方法¶
Collection 构造函数。 魔术 getter 方法,用于从集合中获取一个元素 魔术 isset 方法,用于检查某个元素是否存在 魔术 setter 方法,用于为元素分配值 魔术 unset 方法,用于从集合中删除一个元素 清除内部集合 计算对象中的元素数量。参见count 从集合中获取元素 返回该类的迭代器 返回键作为数组 返回值作为数组 判断集合中是否存在某个元素。 初始化内部数组 指定应序列化为 JSON 的数据。参见jsonSerialize 是否存在偏移量。参见offsetExists 获取偏移量。参见offsetGet 设置偏移量。参见offsetSet 移除偏移量。参见offsetUnset 从集合中删除元素 对象的字符串表示形式。参见serialize 在集合中设置一个元素 以数组格式返回对象 以 JSON 格式返回对象默认字符串使用以下选项进行 json_encode
JSON_HEX_TAG
, JSON_HEX_APOS
, JSON_HEX_AMP
, JSON_HEX_QUOT
, JSON_UNESCAPED_SLASHES
查看rfc4627
构造对象。参见unserialize @todo 当我们获取 traits 时将被移除 检查是否需要不区分大小写的键,如果是,则将元素转换为小写 内部方法用于设置数据支持\Collection\CollectionInterface
¶
-
命名空间
Phalcon\Support\Collection
-
使用
-
继承
-
实现
Phalcon\Support\Collection\CollectionInterface
Phalcon\Support\Collection 类的接口
方法¶
集合对象的异常¶
-
命名空间
Phalcon\Support\Collection
-
使用
Throwable
-
继承
\Exception
-
实现
Exceptions for the Collection object
只读集合对象¶
-
命名空间
Phalcon\Support\Collection
-
使用
Phalcon\Support\Collection
-
继承
Collection
-
实现
A read only Collection object
方法¶
从集合中删除元素 在集合中设置一个元素支持\Debug¶
-
命名空间
Phalcon\Support
-
使用
ErrorException
Phalcon\Support\Debug\Exception
ReflectionClass
ReflectionException
ReflectionFunction
Throwable
-
继承
-
实现
为 Phalcon 应用程序提供调试功能
属性¶
/**
* @var array
*/
protected $blacklist;
/**
* @var array
*/
protected $data;
/**
* @var bool
*/
protected $hideDocumentRoot = false;
/**
* @var bool
*/
protected static $isActive = false;
/**
* @var bool
*/
protected $showBackTrace = true;
/**
* @var bool
*/
protected $showFileFragment = false;
/**
* @var bool
*/
protected $showFiles = true;
/**
* @var string
*/
protected $uri = https://assets.phalcon.io/debug/5.0.x/;
/**
* @var Version
*/
private $version;
方法¶
构造函数设置一个可复用的版本对象 清除之前添加的所有变量 添加一个变量到调试输出中 返回 CSS 资源 返回 JavaScript 资源 生成指向当前版本文档的链接 显示回溯信息并暂停请求@throws Exception
监听未捕获的异常、非静默通知或警告 监听未捕获的异常 监听非静默的通知或警告 处理未捕获的异常public function onUncaughtLowSeverity( mixed $severity, mixed $message, mixed $file, mixed $line ): void;
支持\Debug\Dump¶
-
命名空间
Phalcon\Support\Debug
-
使用
Phalcon\Di\Di
Phalcon\Support\Helper\Json\Encode
Reflection
ReflectionClass
ReflectionProperty
stdClass
-
继承
-
实现
转储关于变量的信息
$foo = "string";
$bar = ["key" => "value"];
$baz = new stdClass();
echo (new \Phalcon\Debug\Dump())->variables($foo, $bar, $baz);
属性¶
/**
* @var bool
*/
protected $detailed = false;
/**
* @var array
*/
protected $methods;
/**
* @var array
*/
protected $styles;
/**
* @var Encode
*/
private $encode;
方法¶
Phalcon\Debug\Dump 构造函数 variables() 方法的别名 variable() 方法的别名 为变量类型设置样式 返回关于单个变量的信息的 JSON 字符串。$foo = [
"key" => "value",
];
echo (new \Phalcon\Debug\Dump())->toJson($foo);
$foo = new stdClass();
$foo->bar = "buz";
echo (new \Phalcon\Debug\Dump())->toJson($foo);
$foo = "string";
$bar = ["key" => "value"];
$baz = new stdClass();
echo (new \Phalcon\Debug\Dump())->variables($foo, $bar, $baz);
支持\调试\异常¶
-
命名空间
Phalcon\Support\Debug
-
使用
-
继承
\Exception
-
实现
在 Phalcon\Debug 中抛出的异常将使用此类
支持\异常¶
-
命名空间
Phalcon\Support
-
使用
-
继承
\Exception
-
实现
Phalcon\Support\Exception
支持\Helper\Arr\AbstractArr
¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
-
实现
提供用于 Arr 命名空间的辅助方法的抽象类。一旦 Zephir 支持,可以将其移至 trait。
@todo 等待支持时移至 trait
方法¶
过滤集合的辅助方法支持\Helper\Arr\Blacklist¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
AbstractArr
-
实现
按键黑名单过滤:通过从黑名单元素获得的键排除数组中的元素
方法¶
支持\Helper\Arr\Chunk¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
-
实现
将数组分割为指定大小的更小数组。
方法¶
支持\Helper\Arr\Filter¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
AbstractArr
-
实现
使用 array_filter 对集合进行过滤,并在定义了可调用对象时使用它。
方法¶
支持\Helper\Arr\First¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
AbstractArr
-
实现
返回集合的第一个元素。如果传入了一个可调用对象,则返回第一个验证为 true 的元素
方法¶
支持\Helper\Arr\FirstKey¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
AbstractArr
-
实现
返回集合中第一个元素的键。如果传入了一个可调用对象,则返回第一个验证为 true 的元素的键
方法¶
支持\Helper\Arr\Flatten¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
-
实现
将数组扁平化到一个层级深度,除非另有说明。$deep
被设置为true
方法¶
支持\Helper\Arr\Get¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
-
实现
通过键获取数组元素,如果不存在则返回默认值。它还允许使用特定类型对返回值进行强制转换。settype
内部使用
方法¶
public function __invoke( array $collection, mixed $index, mixed $defaultValue = null, string $cast = null ): mixed;
支持\Helper\Arr\Group¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
-
实现
根据传入的可调用对象对数组元素进行分组
方法¶
支持\Helper\Arr\Has¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
-
实现
检查数组是否具有特定键的元素并返回结果。true
/false
根据情况返回相应的布尔值。
方法¶
支持\Helper\Arr\IsUnique¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
-
实现
检查扁平列表是否有重复值。如果有重复值则返回 true,否则返回 false。
方法¶
支持\Helper\Arr\Last¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
AbstractArr
-
实现
返回集合的最后一个元素。如果传入了一个可调用对象,则返回第一个验证为 true 的元素
方法¶
支持\Helper\Arr\LastKey¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
AbstractArr
-
实现
返回集合中最后一个元素的键。如果传入了一个可调用对象,则返回第一个验证为 true 的元素的键
方法¶
支持\Helper\Arr\Order¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
-
实现
按对象的属性对数组或对象集合进行排序。它支持升序/降序排序,以及与ksort
和krsort
常量¶
方法¶
public function __invoke( array $collection, mixed $attribute, int $order = static-constant-access, int $flags = int ): array;
所使用的标志相同的支持。¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
-
实现
返回基于集合值的一个子集
方法¶
支持\Helper\Arr\Set¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
-
实现
设置一个数组元素。使用键是可选的。
方法¶
支持\Helper\Arr\SliceLeft¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
-
实现
返回一个新数组,从左侧移除了 n 个元素。
方法¶
支持\Helper\Arr\SliceRight¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
-
实现
返回一个新数组,从右侧移除了 n 个元素。
方法¶
支持\Helper\Arr\Split¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
-
实现
返回一个新数组,其中集合的键作为一个元素,值作为另一个元素。
方法¶
支持\Helper\Arr\ToObject¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
-
实现
返回传递的数组作为对象。
方法¶
支持\Helper\Arr\ValidateAll¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
AbstractArr
-
实现
返回true
如果提供的函数返回true
对于集合的所有元素,false
。
方法¶
支持\Helper\Arr\ValidateAny¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
AbstractArr
-
实现
返回true
如果提供的函数返回true
对于集合中至少一个元素,false
。
方法¶
支持\Helper\Arr\Whitelist¶
-
命名空间
Phalcon\Support\Helper\Arr
-
使用
-
继承
AbstractArr
-
实现
按键白名单过滤:通过从白名单元素获得的键来筛选数组元素
方法¶
支持\Helper\Exception¶
-
命名空间
Phalcon\Support\Helper
-
使用
-
继承
\Exception
-
实现
-
Phalcon\Support\Exception */
支持\Helper\File\Basename¶
-
命名空间
Phalcon\Support\Helper\File
-
使用
-
继承
-
实现
从给定路径获取文件名,功能等同于 PHP 的basename()
但它支持非 ASCII 编码。PHP 的basename()
不正确支持流或者以非 US-ASCII 字符开头的文件名。
方法¶
@see https://bugs.php.net/bug.php?id=37738支持\Helper\Json\Decode¶
-
命名空间
Phalcon\Support\Helper\Json
-
使用
InvalidArgumentException
-
继承
-
实现
使用json_decode
解码字符串,如果 JSON 数据无法解码,则抛出异常
如果未为 json_encode 指定选项,将使用以下选项
JSON_HEX_TAG, JSON_HEX_APOS, JSON_HEX_AMP, JSON_HEX_QUOT, JSON_UNESCAPED_SLASHES
如果在选项中定义了 JSON_THROW_ON_ERROR,则在发生错误时会抛出 JsonException。否则,任何错误都会抛出 InvalidArgumentException
方法¶
public function __invoke( string $data, bool $associative = bool, int $depth = int, int $options = int );
支持\Helper\Json\Encode¶
-
命名空间
Phalcon\Support\Helper\Json
-
使用
InvalidArgumentException
-
继承
-
实现
使用json_encode
编码字符串,如果 JSON 数据无法编码,则抛出异常
如果未为 json_encode 指定选项,将使用以下选项
JSON_HEX_TAG, JSON_HEX_APOS, JSON_HEX_AMP, JSON_HEX_QUOT, JSON_UNESCAPED_SLASHES
如果在选项中定义了 JSON_THROW_ON_ERROR,则在发生错误时会抛出 JsonException。否则,任何错误都会抛出 InvalidArgumentException
@see https://www.ietf.org/rfc/rfc4627.txt
方法¶
支持\Helper\Number\IsBetween¶
-
命名空间
Phalcon\Support\Helper\Number
-
使用
-
继承
-
实现
检查数字是否在某个范围内
方法¶
支持\Helper\Str\AbstractStr
¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
提供用于 Str 命名空间的辅助方法的抽象类。一旦 Zephir 支持,可以将其移至 trait。
@todo 等待支持时移至 trait
方法¶
检查一个字符串是否以给定字符串结束protected function toInterpolate( string $input, array $context = [], string $left = string, string $right = string ): string;
@see https://www.php-fig.org/psr/psr-3/ 第1.2节 Message
使用 mbstring 将字符串转为小写 检查一个字符串是否以给定字符串开始 使用 mbstring 将字符串转为大写支持\Helper\Str\Camelize¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
PascalCase
-
实现
将字符串转换为 UpperCamelCase 或 lowerCamelCase
方法¶
public function __invoke( string $text, string $delimiters = null, bool $lowerFirst = bool ): string;
支持\Helper\Str\Concat¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
Phalcon\Support\Helper\Exception
-
继承
AbstractStr
-
实现
使用分隔符仅一次连接字符串,避免连接处重复
方法¶
支持\Helper\Str\CountVowels¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
返回所提供字符串中的元音数量。使用正则表达式计算字符串中的元音(A,E,I,O,U)数量。
方法¶
Support\Helper\Str\Decapitalize¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
AbstractStr
-
实现
将字符串的第一个字母小写,然后将其与字符串的其余部分组合在一起。如果要保留字符串的其余部分,请省略upperRest参数;若将其设置为true,则将字符串其余部分转换为大写。
方法¶
public function __invoke( string $text, bool $upperRest = bool, string $encoding = string ): string;
Support\Helper\Str\Decrement¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
从字符串末尾移除一个数字,或者如果该数字已经存在则将其减一
方法¶
Support\Helper\Str\DirFromFile¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
接受一个文件名(不带扩展名),并返回计算后的目录结构,文件名位于最后
方法¶
Support\Helper\Str\DirSeparator¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
接受一个目录名称,并确保其以DIRECTORY_SEPARATOR结尾
方法¶
Support\Helper\Str\Dynamic¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
RuntimeException
-
继承
-
实现
根据模板生成随机文本。模板由左右定界符定义,并且可以包含由分隔符分隔的值
方法¶
public function __invoke( string $text, string $leftDelimiter = string, string $rightDelimiter = string, string $separator = string ): string;
Support\Helper\Str\EndsWith¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
AbstractStr
-
实现
检查一个字符串是否以给定字符串结束
方法¶
Support\Helper\Str\FirstBetween¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
返回参数start和end所指定的两个字符串之间的第一个字符串。
方法¶
Support\Helper\Str\Friendly¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
Phalcon\Support\Helper\Exception
-
继承
AbstractStr
-
实现
将文本转换为适合URL使用的格式。将常见的带重音字符替换为其对应的拉丁字母。如果传递了replace
字符串或数组,也将使用它将这些字符替换为空格。
方法¶
public function __invoke( string $text, string $separator = string, bool $lowercase = bool, mixed $replace = null ): string;
Support\Helper\Str\Humanize¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
让下划线或短横线连接的文本变得易于阅读
方法¶
Support\Helper\Str\Includes¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
判断一个字符串是否包含另一个字符串
方法¶
Support\Helper\Str\Increment¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
在字符串末尾添加一个数字,或者如果该数字已经存在则将其加一
方法¶
Support\Helper\Str\Interpolate¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
将上下文值插入到消息占位符中。默认情况下,左右标记是%
@see https://www.php-fig.org/psr/psr-3/ 第1.2节 Message
方法¶
public function __invoke( string $message, array $context = [], string $leftToken = string, string $rightToken = string ): string;
Support\Helper\Str\IsAnagram¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
比较两个字符串并返回true
如果两个字符串是变位词,false
。
方法¶
Support\Helper\Str\IsLower¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
AbstractStr
-
实现
返回true
如果给定字符串全部为小写,false
。
方法¶
Support\Helper\Str\IsPalindrome¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
返回true
如果给定字符串为回文,false
。
方法¶
Support\Helper\Str\IsUpper¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
AbstractStr
-
实现
返回true
如果给定字符串全部为大写,false
。
方法¶
Support\Helper\Str\KebabCase¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
PascalCase
-
实现
将字符串转换为kebab-case风格
方法¶
Support\Helper\Str\Len¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
使用以下方式计算字符串长度:mb_strlen
方法¶
Support\Helper\Str\Lower¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
AbstractStr
-
实现
使用mbstring将字符串转换为小写
方法¶
Support\Helper\Str\PascalCase¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
将字符串转换为PascalCase风格
方法¶
Support\Helper\Str\Prefix¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
使用提供的前缀对文本进行前缀添加
方法¶
Support\Helper\Str\Random¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
根据给定类型生成随机字符串。类型是RANDOM_*常量之一
常量¶
const RANDOM_ALNUM = 0;
const RANDOM_ALPHA = 1;
const RANDOM_DISTINCT = 5;
const RANDOM_HEXDEC = 2;
const RANDOM_NOZERO = 4;
const RANDOM_NUMERIC = 3;
方法¶
Support\Helper\Str\ReduceSlashes¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
将字符串中的多个斜杠减少为单个斜杠
方法¶
Support\Helper\Str\SnakeCase¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
PascalCase
-
实现
将字符串转换为snake_case风格
方法¶
Support\Helper\Str\StartsWith¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
AbstractStr
-
实现
检查一个字符串是否以给定字符串开始
方法¶
Support\Helper\Str\Suffix¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
使用提供的后缀对文本进行后缀添加
方法¶
Support\Helper\Str\Ucwords¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
大写每个单词的首字母
方法¶
Support\Helper\Str\Uncamelize¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
将字符串转换为非驼峰式风格
方法¶
Support\Helper\Str\Underscore¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
-
实现
用下划线代替空格来表示文本
方法¶
Support\Helper\Str\Upper¶
-
命名空间
Phalcon\Support\Helper\Str
-
使用
-
继承
AbstractStr
-
实现
使用mbstring将字符串转换为大写
方法¶
Support\HelperFactory¶
-
命名空间
Phalcon\Support
-
使用
Phalcon\Factory\AbstractFactory
-
继承
AbstractFactory
-
实现
Helper的ServiceLocator实现
@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 $leftDelimiter = "{", string $rightDelimiter = "}", 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($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)
方法¶
FactoryTrait 构造函数。 返回可用的适配器Support\Registry
¶
-
命名空间
Phalcon\Support
-
使用
Phalcon\Support\Collection
Traversable
-
继承
Collection
-
实现
Phalcon\Registry
注册表是用于在应用程序空间中存储对象和值的容器。通过在注册表中存储值,可以确保相同对象在整个应用程序中始终可用。
$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"]);
除了 ArrayAccess 外,Phalcon\Registry 还实现了 Countable(count($registry) 将返回注册表中的元素数量)、Serializable 和 Iterator(您可以使用 foreach 循环遍历注册表)接口。对于 PHP 5.4 及以上版本,还实现了 JsonSerializable 接口。
Phalcon\Registry 非常快速(通常比用户空间实现的任何注册表都要快);但这也带来了一定代价:Phalcon\Registry 是一个 final 类,不能被继承。
虽然 Phalcon\Registry 暴露了如 __get()、offsetGet()、count() 等方法,但不建议手动调用它们(这些方法主要存在是为了匹配注册表所实现的接口):$registry->__get("property") 比 $registry->property 慢很多倍。
所有魔术方法(JsonSerializable 除外)内部都是通过对象处理器或类似技术实现的:这允许绕过相对较慢的方法调用。
方法¶
构造函数 魔术 getter 方法,用于从集合中获取一个元素 魔术 isset 方法,用于检查某个元素是否存在 魔术 setter 方法,用于为元素分配值 魔术 unset 方法,用于从集合中删除一个元素 清除内部集合 计算对象的元素数量@link https://php.net/manual/en/countable.count.php
final public function get( string $element, mixed $defaultValue = null, string $cast = null ): mixed;
@link https://php.net/manual/en/jsonserializable.jsonserialize.php
检查偏移位置是否存在@link https://php.net/manual/en/arrayaccess.offsetexists.php
要检索的偏移位置@link https://php.net/manual/en/arrayaccess.offsetget.php
要设置的偏移位置@link https://php.net/manual/en/arrayaccess.offsetset.php
要取消设置的偏移位置@link https://php.net/manual/en/arrayaccess.offsetunset.php
从集合中删除元素 对象的字符串表示形式@link https://php.net/manual/en/serializable.serialize.php
在集合中设置一个元素 以数组格式返回对象 以 JSON 格式返回对象默认字符串使用以下选项进行 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
构造对象@link https://php.net/manual/en/serializable.unserialize.php
Support\Version¶
-
命名空间
Phalcon\Support
-
使用
-
继承
-
实现
此类允许获取框架的安装版本
常量¶
const VERSION_MAJOR = 0;
const VERSION_MEDIUM = 1;
const VERSION_MINOR = 2;
const VERSION_SPECIAL = 3;
const VERSION_SPECIAL_NUMBER = 4;
方法¶
返回当前版本(字符串) 返回数字格式的当前版本 返回版本的特定部分。如果传递了错误参数,则将返回完整版本 设置版本号的区域。格式如下:ABBCCDEA - 主版本号 B - 中版本号(两位数) C - 次版本号(两位数) D - 特殊发布版本:1 = alpha,2 = beta,3 = RC,4 = 稳定版 E - 特殊发布子版本,例如 RC1、Beta2 等。