injector
injector copied to clipboard
Support PHP 8.4 lazy objects
I think it will be useful to have an ability to create lazy objects.
It might look like:
-
New methods:
class Injector { // ... public function makeGhost(string $class, array $arguments = []): object {} public function makeProxy(string $class, array $arguments = []): object {} } -
A new parameter of the
makemethodenum Laziness { case Regular; // or Disable case Proxy; case Ghost; } class Injector { // ... public function make(string $class, array $arguments = [], Laziness $laziness = Laziness::Disable): object } -
A new option:
$injector ->withLaziness(Laziness::Proxy) ->make(...)But in this case the option won't affect
$injector->invoke()(does make sense?)