From 74deb2d2242bc6117eb179f2041a193cf74ea6e6 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Thu, 23 May 2024 17:03:19 +0900 Subject: [PATCH] Apply MapModule for multiple bindings Implemented a condition check to apply the MapModule if multiple bindings are present in the InstallBuiltinModule file. This is done to enhance the functionality and ensure smoother module operations. --- src/CompileVisitor.php | 2 +- src/InstallBuiltinModule.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CompileVisitor.php b/src/CompileVisitor.php index 7c1612e2..be04ad2d 100644 --- a/src/CompileVisitor.php +++ b/src/CompileVisitor.php @@ -70,7 +70,7 @@ public function visitInstance($value): string return 'return null;'; } - assert(! is_object($value), 'Invalid instance type:' . gettype($value)); + assert(is_object($value), 'Invalid instance type:' . gettype($value)); return sprintf('return unserialize(\'%s\');', serialize($value)); } diff --git a/src/InstallBuiltinModule.php b/src/InstallBuiltinModule.php index 9c711bbb..caf08cbc 100644 --- a/src/InstallBuiltinModule.php +++ b/src/InstallBuiltinModule.php @@ -20,6 +20,7 @@ public function __invoke(AbstractModule $module): AbstractModule $module->install(new PramReaderModule()); $hasMultiBindings = count($module->getContainer()->multiBindings); if ($hasMultiBindings) { + // Apply MapModule if multiple bindings are present $module->override(new MapModule()); }