willemabc / deep-copy-debugger
DeepCopy 功能强大,但调试困难。DeepCopyDebugger 使得查找错误的或缺失的过滤器变得容易。
v1.0.3
2022-12-08 11:31 UTC
Requires
- myclabs/deep-copy: ^1.0
README
DeepCopy 功能强大,但调试困难。尤其是当你需要在多个类中设置单个 DeepCopy 实例的过滤器,并使用通配符匹配器如 PropertyNameMatcher 时。DeepCopyDebugger 使得查找错误的或缺失的过滤器变得容易。
DeepCopyDebugger 的帮助方式如下
- 它可以返回 DeepCopy 实例上设置的所有过滤器的列表,按照设置顺序。
- 给定一个 DeepCopy 实例和一个 Doctrine 实体类,它可以返回所有属性以及每个单独属性的匹配过滤器。
- 也有方法只获取匹配的属性或只获取未匹配的属性。
用法
在调用 DeepCopy 实例上的 copy 方法之前,调用 DeepCopyDebugger 是很重要的!
$deepCopy = new DeepCopy();
// ... set your filters
$deepCopyDebugger = new DeepCopyDebugger($deepCopy);
dump($deepCopyDebugger->getFilterCollection());
dump($deepCopyDebugger->getFormattedFilterCollection());
dump($deepCopyDebugger->getMatchedAndUnmatchedEntityProperties(YourDoctrineEntity::class));
dump($deepCopyDebugger->getMatchedEntityProperties(YourDoctrineEntity::class));
dump($deepCopyDebugger->getUnmatchedEntityProperties(YourDoctrineEntity::class));
$deepCopy->copy($sourceObject);