This PR adds injectable classes to container, that have their biggest impact on Container::call, because till now, you could pass some values, which would be passed along with injected ones. Now, if param has type that implements \Lemon\Contracts\Kernel\Injectable, it would (instead of just passing the value) convert passed value into given type via Injectable::fromInjection static method.
class User implements Injectable
{
public static function fromInjection(Container $container, mixed $value): self
{
return $container->get(UserFactory::class)->get($value);
}
}
It basicaly converts the value into provided type with container.
This PR adds injectable classes to container, that have their biggest impact on
Container::call
, because till now, you could pass some values, which would be passed along with injected ones. Now, if param has type that implements\Lemon\Contracts\Kernel\Injectable
, it would (instead of just passing the value) convert passed value into given type viaInjectable::fromInjection
static method.Example
and
User
looks like this:It basicaly converts the value into provided type with container.