@@ -83,25 +83,25 @@ class_exists(ContainerConfigurator::class);
8383 }
8484
8585 if (\is_object ($ result ) && \is_callable ($ result )) {
86- $ result = $ this ->executeCallback ($ result , new ContainerConfigurator ($ this ->container , $ this , $ this ->instanceof , $ path , $ resource , $ this ->env ), $ path );
86+ $ result = $ this ->callConfigurator ($ result , new ContainerConfigurator ($ this ->container , $ this , $ this ->instanceof , $ path , $ resource , $ this ->env ), $ path );
8787 }
8888 if ($ result instanceof ConfigBuilderInterface) {
89- $ this ->loadExtensionConfig ($ result ->getExtensionAlias (), ContainerConfigurator::processValue ($ result ->toArray ()));
89+ $ this ->loadExtensionConfig ($ result ->getExtensionAlias (), ContainerConfigurator::processValue ($ result ->toArray ()), $ path );
9090 } elseif (is_iterable ($ result )) {
9191 foreach ($ result as $ key => $ config ) {
9292 if ($ config instanceof ConfigBuilderInterface) {
9393 if (\is_string ($ key ) && $ config ->getExtensionAlias () !== $ key ) {
9494 throw new InvalidArgumentException (\sprintf ('The extension alias "%s" of the "%s" config builder does not match the key "%s" in file "%s". ' , $ config ->getExtensionAlias (), get_debug_type ($ config ), $ key , $ path ));
9595 }
96- $ this ->loadExtensionConfig ($ config ->getExtensionAlias (), ContainerConfigurator::processValue ($ config ->toArray ()));
96+ $ this ->loadExtensionConfig ($ config ->getExtensionAlias (), ContainerConfigurator::processValue ($ config ->toArray ()), $ path );
9797 } elseif (!\is_string ($ key ) || !\is_array ($ config )) {
9898 throw new InvalidArgumentException (\sprintf ('The configuration returned in file "%s" must yield only string-keyed arrays or ConfigBuilderInterface values. ' , $ path ));
9999 } else {
100- $ this ->loadExtensionConfig ($ key , ContainerConfigurator::processValue ($ config ));
100+ $ this ->loadExtensionConfig ($ key , ContainerConfigurator::processValue ($ config ), $ path );
101101 }
102102 }
103103 } elseif (null !== $ result ) {
104- throw new InvalidArgumentException (\sprintf ('The return value in config file "%s" is invalid. ' , $ path ));
104+ throw new InvalidArgumentException (\sprintf ('The return value in config file "%s" is invalid: "%s" given . ' , $ path, get_debug_type ( $ result ) ));
105105 }
106106
107107 $ this ->loadExtensionConfigs ();
@@ -129,7 +129,7 @@ public function supports(mixed $resource, ?string $type = null): bool
129129 /**
130130 * Resolve the parameters to the $callback and execute it.
131131 */
132- private function executeCallback (callable $ callback , ContainerConfigurator $ containerConfigurator , string $ path ): mixed
132+ private function callConfigurator (callable $ callback , ContainerConfigurator $ containerConfigurator , string $ path ): mixed
133133 {
134134 $ callback = $ callback (...);
135135 $ arguments = [];
@@ -202,7 +202,9 @@ private function executeCallback(callable $callback, ContainerConfigurator $cont
202202
203203 ++$ this ->importing ;
204204 try {
205- return $ callback (...$ arguments );
205+ $ result = $ callback (...$ arguments );
206+
207+ return \in_array ($ result , $ configBuilders , true ) ? null : $ result ;
206208 } catch (\Throwable $ e ) {
207209 $ configBuilders = [];
208210 throw $ e ;
0 commit comments