diff --git a/src/Container.php b/src/Container.php index 1b23835..350140d 100644 --- a/src/Container.php +++ b/src/Container.php @@ -58,7 +58,9 @@ final class Container implements ContainerInterface /** * @var array */ - private array $aliases = []; + private array $aliases = [ + ContainerInterface::class => self::class, + ]; /** * @var array> @@ -114,10 +116,7 @@ private function __construct() $this->parameterBuilder = ParameterBuilder::new($this); - $this->instantiator = Instantiator::new( - $this->reflector, - $this->parameterBuilder - ); + $this->instantiator = Instantiator::new($this->reflector, $this->parameterBuilder); } /** @@ -400,6 +399,7 @@ public function factory(string $service, string $serviceFactory): void public function get(string $service): object { $class = $this->resolve($service); + if (is_a($service, ContainerInterface::class, true)) { return $this; }