private function dispatchLazily(array $boundClassesToBindingData, bool $run)
    {
        foreach ($boundClassesToBindingData as $boundClass => $bindingData) {
            $bootstrapperClass = $bindingData['bootstrapper'];
            $target = $bindingData['target'];

            $factory = function () use ($boundClass, $bootstrapperClass, $target, $run) {
                // To make sure this factory isn't used anymore to resolve the bound class, unbind it
                // Otherwise, we'd get into an infinite loop every time we tried to resolve it
                if ($target === null) {
                    $this->container->unbind($boundClass);
                } else {
                    $this->container->for($target, function (IContainer $container) use ($boundClass) {
                        $container->unbind($boundClass);
                    });
                }

                $bootstrapper = $this->bootstrapperResolver->resolve($bootstrapperClass);

                if (!in_array($bootstrapper, $this->bootstrapperObjects)) {
                    $this->bootstrapperObjects[] = $bootstrapper;
                }

                if (!isset($this->dispatchedBootstrappers[$bootstrapperClass])) {
                    $bootstrapper->registerBindings($this->container);

                    if ($run) {
                        $this->container->callMethod($bootstrapper, 'run', [], true);
                    }

                    $this->dispatchedBootstrappers[$bootstrapperClass] = true;
                }

                if ($target === null) {
                    return $this->container->resolve($boundClass);
                } else {
                    return $this->container->for($target, function (IContainer $container) use ($boundClass) {
                        return $container->resolve($boundClass);
                    });
                }
            };

            if ($target === null) {
                $this->container->bindFactory($boundClass, $factory);
            } else {
                $this->container->for($target, function (IContainer $container) use ($boundClass, $factory) {
                    $container->bindFactory($boundClass, $factory);
                });
            }
        }
    }