diff --git a/src/Cli/CronJobs/ModuleLicensesCronJob.php b/src/Cli/CronJobs/ModuleLicensesCronJob.php index ddfbc49b..9b8d2a0a 100644 --- a/src/Cli/CronJobs/ModuleLicensesCronJob.php +++ b/src/Cli/CronJobs/ModuleLicensesCronJob.php @@ -1,5 +1,6 @@ get('db'); * $cache = $container->get('cache'); * $container->set('plex.service', function($c) { - * return new PlexService($c->get('db'), $c->get('settings')); + * return new \PlexService($c->get('db'), $c->get('settings')); * }); * } * } @@ -227,24 +231,24 @@ class ServiceContainer implements ContainerInterface { * highest priority wraps outermost (called first by callers). * * Example: - * $c->decorate('stream.service', FingerprintDecorator::class, priority: 20); - * $c->decorate('stream.service', LoggingDecorator::class, priority: 10); - * // Call order: FingerprintDecorator → LoggingDecorator → original + * $c->decorate('stream.service', \FingerprintDecorator::class, priority: 20); + * $c->decorate('stream.service', \LoggingDecorator::class, priority: 10); + * // Call order: \FingerprintDecorator → \LoggingDecorator → original * * @param string $id Service identifier * @param class-string|callable $decorator Class-string or callable($inner, $container): mixed * @param int $priority Higher = outer layer (default 0) - * @throws RuntimeException If the service is protected or not registered as a factory + * @throws \RuntimeException If the service is protected or not registered as a factory */ public function decorate(string $id, string|callable $decorator, int $priority = 0): static { if (in_array($id, $this->protectedServices, true)) { - throw new ContainerException( + throw new \ContainerException( "ServiceContainer: сервис '{$id}' защищён от декорирования модулями." ); } if (!isset($this->factories[$id]) && !array_key_exists($id, $this->resolved)) { - throw new ContainerException( + throw new \ContainerException( "ServiceContainer: невозможно декорировать незарегистрированный сервис '{$id}'." ); } @@ -275,7 +279,7 @@ class ServiceContainer implements ContainerInterface { * @param string $id Идентификатор * @return mixed * @throws NotFoundException Если сервис не зарегистрирован - * @throws RuntimeException Если обнаружена циклическая зависимость или фабрика бросила исключение + * @throws \RuntimeException Если обнаружена циклическая зависимость или фабрика бросила исключение */ public function get(string $id): mixed { // 1. Уже разрешён (singleton) — мгновенный возврат @@ -295,12 +299,12 @@ class ServiceContainer implements ContainerInterface { try { $service = call_user_func($this->factories[$id], $this); $service = $this->applyDecorators($id, $service); - } catch (XcVmException $e) { + } catch (\XcVmException $e) { unset($this->creating[$id]); throw $e; - } catch (Exception $e) { + } catch (\Exception $e) { unset($this->creating[$id]); - throw new ServiceCreationException( + throw new \ServiceCreationException( "ServiceContainer: ошибка при создании сервиса '{$id}': " . $e->getMessage(), 0, $e @@ -485,14 +489,14 @@ class ServiceContainer implements ContainerInterface { // ───────────────────────────────────────────────────────── /** - * Throw a CircularDependencyException describing the resolution chain. + * Throw a \CircularDependencyException describing the resolution chain. * * @param string $id Service id whose creation closed the cycle. * @return never - * @throws CircularDependencyException Always. + * @throws \CircularDependencyException Always. */ private function throwCircularDependency(string $id): never { - throw new CircularDependencyException( + throw new \CircularDependencyException( "ServiceContainer: циклическая зависимость при создании сервиса '{$id}'. " . "Цепочка: " . implode(' → ', array_keys($this->creating)) . " → {$id}" ); diff --git a/src/Core/Database/DatabaseHandler.php b/src/Core/Database/DatabaseHandler.php index 1a9f5257..19b52430 100644 --- a/src/Core/Database/DatabaseHandler.php +++ b/src/Core/Database/DatabaseHandler.php @@ -1,6 +1,7 @@ get($class); } catch (\Throwable $e) { diff --git a/src/Core/Init/LegacyInitializer.php b/src/Core/Init/LegacyInitializer.php index 184ece8e..1b1011d0 100644 --- a/src/Core/Init/LegacyInitializer.php +++ b/src/Core/Init/LegacyInitializer.php @@ -1,5 +1,6 @@ function (\ServiceContainer $c) { $c->get('db')->execute('ALTER TABLE ...'); }, - * '2.0.0' => function (\ServiceContainer $c) { $c->get('db')->execute('CREATE TABLE ...'); }, + * '1.1.0' => function (\XcVm\Core\Container\ServiceContainer $c) { $c->get('db')->execute('ALTER TABLE ...'); }, + * '2.0.0' => function (\XcVm\Core\Container\ServiceContainer $c) { $c->get('db')->execute('CREATE TABLE ...'); }, * ]; * } * @@ -33,9 +34,9 @@ interface MigratableInterface { * * Keys are semver strings (e.g. "1.1.0"). Values are callables * that perform the schema or data change for that version step. - * Each callable receives the \ServiceContainer — use it to access db, settings, etc. + * Each callable receives the \XcVm\Core\Container\ServiceContainer — use it to access db, settings, etc. * - * @return array + * @return array */ public function getMigrations(): array; } diff --git a/src/Core/Module/ModuleLoader.php b/src/Core/Module/ModuleLoader.php index 4f511fa8..a99e227e 100644 --- a/src/Core/Module/ModuleLoader.php +++ b/src/Core/Module/ModuleLoader.php @@ -1,6 +1,7 @@ registerNavbar($navbarRegistry); @@ -620,10 +621,10 @@ class ModuleLoader { * registration time the listener is silently skipped (graceful degradation). * * @param ServiceProviderInterface $module - * @param \ServiceContainer $container + * @param \XcVm\Core\Container\ServiceContainer $container * @return void */ - private function registerEventSubscribers(ServiceProviderInterface $module, \ServiceContainer $container): void { + private function registerEventSubscribers(ServiceProviderInterface $module, \XcVm\Core\Container\ServiceContainer $container): void { // Verify the container holds an actual \EventDispatcher instance (not just the class name). // Static calls below route to the same instance via \EventDispatcher::getInstance(). if (!$container->has('events') || !$container->get('events') instanceof \EventDispatcher) { diff --git a/src/Core/Module/ModuleManager.php b/src/Core/Module/ModuleManager.php index e522adf3..ee7a90b0 100644 --- a/src/Core/Module/ModuleManager.php +++ b/src/Core/Module/ModuleManager.php @@ -1,6 +1,7 @@ modulesPath = $modulesPath ?: (defined('MAIN_HOME') ? MAIN_HOME . 'Modules' : dirname(__DIR__, 2) . '/Modules'); $this->overridesPath = $overridesPath ?: (defined('CONFIG_PATH') ? CONFIG_PATH . 'modules.php' : dirname(__DIR__, 2) . '/config/modules.php'); @@ -480,7 +481,7 @@ class ModuleManager { * Delegates the full download → key-unwrap → extract flow to the * XC_VM C extension, then runs installModule() to register it. * Fires \PackageInstalledEvent and hot-reloads the module into the - * current \ServiceContainer without requiring a PHP-FPM restart. + * current \XcVm\Core\Container\ServiceContainer without requiring a PHP-FPM restart. * * @param string $slug Module slug as listed on the platform. * @param string $version Exact version string (e.g. "1.2.0"), or '' for the latest. @@ -815,7 +816,7 @@ class ModuleManager { } /** - * Hot-reload a newly installed module into the running \ServiceContainer. + * Hot-reload a newly installed module into the running \XcVm\Core\Container\ServiceContainer. * * Loads and boots the module within the current request so it becomes * immediately usable without a PHP-FPM restart. @@ -853,7 +854,7 @@ class ModuleManager { * @return void */ private function hotReload(string $slug, string $modulePath): void { - $container = \ServiceContainer::getInstance(); + $container = \XcVm\Core\Container\ServiceContainer::getInstance(); $loader = new ModuleLoader(); if (!$loader->load($slug, $modulePath)) { diff --git a/src/Modules/plex/PlexModule.php b/src/Modules/plex/PlexModule.php index d688e42a..94a9ec8d 100644 --- a/src/Modules/plex/PlexModule.php +++ b/src/Modules/plex/PlexModule.php @@ -5,7 +5,7 @@ use XcVm\Core\Module\NavbarRegistry; use XcVm\Core\Module\NavbarItem; use XcVm\Core\Module\BaseModule; -use ServiceContainer; +use XcVm\Core\Container\ServiceContainer; use XcVm\Core\Http\Router; use CommandRegistry; use PlexService; diff --git a/src/Modules/tmdb/TmdbModule.php b/src/Modules/tmdb/TmdbModule.php index a594bf0f..e1b5556a 100644 --- a/src/Modules/tmdb/TmdbModule.php +++ b/src/Modules/tmdb/TmdbModule.php @@ -3,7 +3,7 @@ namespace XcVm\Module\Tmdb; use XcVm\Core\Module\BaseModule; -use ServiceContainer; +use XcVm\Core\Container\ServiceContainer; use XcVm\Core\Http\Router; use CommandRegistry; use TmdbController; diff --git a/src/Modules/watch/WatchModule.php b/src/Modules/watch/WatchModule.php index fdb49503..42fc1d89 100644 --- a/src/Modules/watch/WatchModule.php +++ b/src/Modules/watch/WatchModule.php @@ -5,7 +5,7 @@ use XcVm\Core\Module\NavbarRegistry; use XcVm\Core\Module\NavbarItem; use XcVm\Core\Module\BaseModule; -use ServiceContainer; +use XcVm\Core\Container\ServiceContainer; use XcVm\Core\Http\Router; use CommandRegistry; use WatchService; diff --git a/src/Public/Controllers/Admin/ModulesController.php b/src/Public/Controllers/Admin/ModulesController.php index 8456bda9..7de2440a 100644 --- a/src/Public/Controllers/Admin/ModulesController.php +++ b/src/Public/Controllers/Admin/ModulesController.php @@ -1,5 +1,6 @@ assertInterfaceMethod($rc, 'boot', ['ServiceContainer'], 'void'); + $this->assertInterfaceMethod($rc, 'boot', ['XcVm\Core\Container\ServiceContainer'], 'void'); } public function testServiceProviderInterfaceHasGetEventSubscribers(): void { diff --git a/tests/Unit/ListensToAttributeTest.php b/tests/Unit/ListensToAttributeTest.php index 9b619598..cf90f16a 100644 --- a/tests/Unit/ListensToAttributeTest.php +++ b/tests/Unit/ListensToAttributeTest.php @@ -1,5 +1,6 @@