symfony/polyfill-deepclone
最新稳定版本:v1.38.2
Composer 安装命令:
composer require symfony/polyfill-deepclone
包简介
Symfony polyfill for the deepclone extension
README 文档
README
This package provides a pure-PHP implementation of the functions and exception classes from the deepclone extension:
deepclone_to_array(mixed $value, ?array $allowedClasses = null): array— converts any serializable PHP value graph into a pure array (only scalars and nested arrays, no objects).deepclone_from_array(array $data, ?array $allowedClasses = null): mixed— rebuilds the value graph from the array, preserving object identity, references, cycles, and private property state.DeepClone\NotInstantiableExceptionandDeepClone\ClassNotFoundException
When the native deepclone extension is loaded, this polyfill does nothing —
the extension provides the same functions 4–5× faster.
The array representation preserves PHP's copy-on-write for strings and scalar
arrays, making repeated cloning of a prototype significantly more memory
efficient than unserialize(serialize()). It also serves as a cache-friendly
serialization format: when dumped via var_export() into a .php file,
OPcache maps the array into shared memory, making deserialization essentially
free.
This is the same wire format used by Symfony's VarExporter\DeepCloner.
More information can be found in the main Polyfill README.
License
This library is released under the MIT license.
统计信息
- 总下载量: 637.06k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 1
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-10