public function disable(Module $module, bool $recollect = true, bool $recursive = false): bool
    {
        $action = function (Module $module) {
            $installer = $module->installer();
            if ($installer === null) {
                return true;
            }

            if (!class_exists($installer) || !is_subclass_of($installer, Installer::class, true)) {
                return false;
            }

            /** @var Installer $installer */
            $installer = new $installer($module);
            try {
                $installer->disable();
                return true;
            } catch (Throwable $e) {
                $installer->disableError($e);
                return false;
            }
        };

        $callback = function (Module $module) use ($recollect) {
            $this->notify($module, 'enabled', false);

            if ($recollect) {
                $this->getCollector()->recollect();
            }

            $this->emit('module.disabled.' . $module->name());
        };

        $manager = $this->moduleManager();

        if ($recursive) {
            foreach ($manager->recursiveDependants($module) as $dependant) {
                if ($dependant->isEnabled()) {
                    if (!$manager->disable($dependant, $action, $callback)) {
                        return false;
                    }
                }
                if ($dependant->isInstalled()) {
                    if (!$this->uninstall($dependant, $recollect, false)) {
                        return false;
                    }
                }
            }
        }

        return $manager->disable($module, $action, $callback);
    }