php-di/invoker
Lightweight PHP library to call any callable with automatic dependency injection. Resolves function and method parameters by name and type-hints, integrates with PHP-DI, and supports default values for flexible invocations in frameworks, controllers, and CLI tools.
Full Changelog: https://github.com/PHP-DI/Invoker/compare/2.3.6...2.3.7
call_user_func_array with native invocation" by @mnapoli in https://github.com/PHP-DI/Invoker/pull/54Full Changelog: https://github.com/PHP-DI/Invoker/compare/2.3.5...2.3.6
call_user_func_array with native invocation by @dakujem in https://github.com/PHP-DI/Invoker/pull/52Full Changelog: https://github.com/PHP-DI/Invoker/compare/2.3.4...2.3.5
Full Changelog: https://github.com/PHP-DI/Invoker/compare/2.3.3...2.3.4
Full Changelog: https://github.com/PHP-DI/Invoker/compare/2.3.2...2.3.3
#36, #37, #38, #40 Improve error messages for classes implementing __callStatic()
#35 Allow psr/container v1|v2
Better PHP 8 support Support PHP 7.1 nullable parameters Support optional parameters before required ones (PHP-DI/PHP-DI#562)
PHP 8 compatibility
Compatibility with PSR-11 (which required a very small BC break)
Performance improvement: #12
#11 Explicit exception message for unsupported magic methods
TypeHintResolver. Resolves parameters by matching type-hints to entries in the array of parameters provided.#5 The logic that resolves callable from the container has been extracted in its own class: CallableResolver.
That will allow to separately resolve callables and invoke them.
Improvements to exception messages
Class::method syntax for callables (by @jdreesen)Big performance improvements (up to 30% faster from my benchmarks and profiling), especially for the most common use cases.
Added more specific exceptions allowing to catch them.
Also added Invoker::getContainer().
0.x versions do not ensure backward compatibility.
This release features mainly a new resolver ParameterNameContainerResolver. This resolver will inject container entries by searching for the name of the parameter:
$invoker->call(function ($twig) {
// ...
});
In this example it will ->get('twig') from the container and inject it.
Breaking changes:
AssociativeArrayParameterResolver to AssociativeArrayResolverDefaultValueParameterResolver to DefaultValueResolverNumericArrayParameterResolver to NumericArrayResolverParameterResolverChain to ResolverChainResolverChain::unshiftResolver() to prependResolver() and pushResolver() to appendResolver()ContainerParameterResolver to Container\TypeHintContainerResolverHow can I help you explore Laravel packages today?