From aa6805a29aa79ac786587c2879ab934c2e70a6af Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Thu, 23 May 2024 18:02:14 +0900 Subject: [PATCH] Remove InstallBuiltinModule and refactor Compiler The InstallBuiltinModule file has been removed and the Compiler file has been refactored. Instead of using InstallBuiltinModule, DiCompileModule is now installed directly in Compiler. Furthermore, the container generation logic in the Compiler has been updated to use a ContainerFactory. This contributes to --- src/Compiler.php | 9 +++------ src/InstallBuiltinModule.php | 29 ----------------------------- 2 files changed, 3 insertions(+), 35 deletions(-) delete mode 100644 src/InstallBuiltinModule.php diff --git a/src/Compiler.php b/src/Compiler.php index 567d1535..7b5bf9f9 100644 --- a/src/Compiler.php +++ b/src/Compiler.php @@ -4,10 +4,10 @@ namespace Ray\Compiler; -use Ray\Aop\Compiler as AopCompiler; use Ray\Compiler\Exception\CompileLockFailed; use Ray\Di\AbstractModule; use Ray\Di\AcceptInterface; +use Ray\Di\ContainerFactory; use Ray\Di\DependencyInterface; use function assert; @@ -37,11 +37,8 @@ public function compile(AbstractModule $module, string $scriptDir): Scripts } $scripts = new Scripts(); - $container = (new InstallBuiltinModule())($module)->getContainer(); - // Compile null objects - (new CompileNullObject())($container, $scriptDir); - // Compile aspects - $container->weaveAspects(new AopCompiler($scriptDir)); + $module->install(new DiCompileModule(true)); + $container = (new ContainerFactory())($module, $scriptDir); // Compile dependencies $compileVisitor = new CompileVisitor($container); $container->map(static function (DependencyInterface $dependency, string $key) use ($scripts, $compileVisitor): DependencyInterface { diff --git a/src/InstallBuiltinModule.php b/src/InstallBuiltinModule.php deleted file mode 100644 index caf08cbc..00000000 --- a/src/InstallBuiltinModule.php +++ /dev/null @@ -1,29 +0,0 @@ -install(new AssistedModule()); - $module->install(new ProviderSetModule()); - $module->install(new PramReaderModule()); - $hasMultiBindings = count($module->getContainer()->multiBindings); - if ($hasMultiBindings) { - // Apply MapModule if multiple bindings are present - $module->override(new MapModule()); - } - - return $module; - } -}