定制 symfony/polyfill-deepclone 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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\NotInstantiableException and DeepClone\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

GitHub 信息

  • Stars: 6
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固