eliashaeussler/deep-closure-comparator
最新稳定版本:1.2.1
Composer 安装命令:
composer require eliashaeussler/deep-closure-comparator
包简介
Provides a PHPUnit comparator to assert equality of closures
README 文档
README
Deep Closure Comparator
A Composer library that provides a PHPUnit comparator to assert equality
of closures. It can be used to perform deep evaluation of closures, e.g.
as part of objects. Closures are compared using their serialized value,
which is calculated by the opis/closure
library.
???? Installation
composer require --dev eliashaeussler/deep-closure-comparator
⚡ Usage
Instead of using the self::assertEquals() method of a PHPUnit test case, use the assertEquals
method that is shipped within the DeepClosureAssert class:
use EliasHaeussler\DeepClosureComparator\DeepClosureAssert; use PHPUnit\Framework\TestCase; final class Foo { public function __construct( public ?\Closure $bar = null, ) {} } final class FooTest extends TestCase { public function testSomething(): void { $expected = new Foo(); $expected->bar = static fn() => 'foo'; $actual = new Foo(); $actual->bar = static fn() => 'foo'; DeepClosureAssert::assertEquals($expected, $actual); } }
Or, in other words:
-self::assertEquals($expected, $actual); +DeepClosureAssert::assertEquals($expected, $actual);
Note
Closures are compared using their serialized representation. This is done by the
opis/closure library, which provides mechanisms
to deep inspect and serialize given closures. More information can be found in the
official documentation of this library.
???????? Contributing
Please have a look at CONTRIBUTING.md.
???? Credits
This project developed from a hardened implementation detail in the
sebastian/comparator library,
as part of PHPUnit's supply chain. With the introduction of a new ClosureComparator, comparing
closures got a lot more difficult. Finally, @tstarling suggested
parts of the actual implementation of this deep-closure-comparator library. Thank you very much
for your support!
⭐ License
This project is licensed under GNU General Public License 3.0 (or later).
eliashaeussler/deep-closure-comparator 适用场景与选型建议
eliashaeussler/deep-closure-comparator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 26.86k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 eliashaeussler/deep-closure-comparator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 eliashaeussler/deep-closure-comparator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 26.86k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 35
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2026-01-04