thecodingmachine / service-provider-utils
此包包含一组用于与 container-interop 的服务提供者一起工作的工具。
1.0.x-dev
2016-04-19 15:29 UTC
Requires
- php-di/invoker: ^1.3
Requires (Dev)
- phpunit/phpunit: ~5.0
- satooshi/php-coveralls: ^1.0
This package is auto-updated.
Last update: 2024-09-07 00:32:36 UTC
README
服务提供者工具
此包包含一组用于与 container-interop 的服务提供者 一起工作的工具。
安装
您可以通过 Composer 安装此包
{ "require": { "thecodingmachine/service-provider-utils": "~1.0" } }
此包遵守 SemVer 规范,并且不同小版本之间将保持完全的向后兼容性。
使用
此包包含一个单一的工具方法,该方法分析一个工厂(即一个可调用对象)并返回是否使用了第二个参数(即 $previous
参数)。
// $previous is not used in this callable $callable = function(ContainerInterface $container, $previous) { return new MyService(); }); $factoryAnalyser = new FactoryAnalyzer(); $isPreviousUsed = $factoryAnalyser->isPreviousArgumentUsed($callable); // $isPreviousUsed === false
注意:此函数有时可能会返回假阳性,尤其是在您的代码体中包含对 func_get_args
的调用或通过变量名引用(例如 $$foo
)时。但是,它永远不会返回假阴性。