/** * @param object|null $container */ public function setContainer($container = null) { // Setup container $delegates = [$this->container, new ReflectionContainer()]; $parentContainer = new Container(); $parentContainer->share(ContainerInterface::class, $parentContainer); if ($container) { // Unify container to PSR11 $acclimator = new ContainerAcclimator(); $container = $acclimator->acclimate($container); array_unshift($delegates, $container); } // Bind delegates $delegates = array_filter($delegates); foreach ($delegates as $delegate) { $parentContainer->delegate($delegate); } $this->container = $parentContainer; }