thecodingmachine / service-provider-utils
This package contains a set of tools to work with container-interop's service-providers.
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-11-07 00:53:19 UTC
README
Service-provider utils
This package contains a set of tools to work with container-interop's service-providers.
Installation
You can install this package through Composer:
{ "require": { "thecodingmachine/service-provider-utils": "~1.0" } }
The packages adheres to the SemVer specification, and there will be full backward compatibility between minor versions.
Usage
This package contains a single utility method that analyses a factory (i.e. a callable) and returns if the second argument (the $previous
argument) is used or not.
// $previous is not used in this callable $callable = function(ContainerInterface $container, $previous) { return new MyService(); }); $factoryAnalyser = new FactoryAnalyzer(); $isPreviousUsed = $factoryAnalyser->isPreviousArgumentUsed($callable); // $isPreviousUsed === false
Note: this function can sometimes return false positives, in particular if your body contains calls to func_get_args
or refences by variable name ($$foo
). It should however never return false negatives.