@@ -162,9 +162,8 @@ public static function __callStatic(string $component, array $arguments)
162162 return null ;
163163 }
164164
165- self ::$ instances [$ options ['component ' ]][$ class ] = new $ class (...$ arguments );
166- self ::$ aliases [$ options ['component ' ]][$ alias ] = $ class ;
167- self ::$ updated [$ options ['component ' ]] = true ;
165+ self ::createInstance ($ options ['component ' ], $ class , $ arguments );
166+ self ::$ aliases [$ options ['component ' ]][$ alias ] = $ class ;
168167
169168 // If a short classname is specified, also register FQCN to share the instance.
170169 if (! isset (self ::$ aliases [$ options ['component ' ]][$ class ])) {
@@ -192,8 +191,7 @@ private static function getDefinedInstance(array $options, string $alias, array
192191 return self ::$ instances [$ options ['component ' ]][$ class ];
193192 }
194193
195- self ::$ instances [$ options ['component ' ]][$ class ] = new $ class (...$ arguments );
196- self ::$ updated [$ options ['component ' ]] = true ;
194+ self ::createInstance ($ options ['component ' ], $ class , $ arguments );
197195
198196 return self ::$ instances [$ options ['component ' ]][$ class ];
199197 }
@@ -218,6 +216,15 @@ private static function getDefinedInstance(array $options, string $alias, array
218216 return null ;
219217 }
220218
219+ /**
220+ * Creates the shared instance.
221+ */
222+ private static function createInstance (string $ component , string $ class , array $ arguments ): void
223+ {
224+ self ::$ instances [$ component ][$ class ] = new $ class (...$ arguments );
225+ self ::$ updated [$ component ] = true ;
226+ }
227+
221228 /**
222229 * Is the component Config?
223230 *
0 commit comments