@@ -76,6 +76,8 @@ public static function global(): self
7676 }
7777
7878 /**
79+ * Get an object by registered ID name
80+ *
7981 * @param string $id
8082 *
8183 * @return mixed|object
@@ -100,7 +102,7 @@ public function get(string $id)
100102 }
101103 }
102104
103- // storage
105+ // storage it.
104106 $ this ->objects [$ id ] = $ obj ;
105107 return $ obj ;
106108 }
@@ -128,17 +130,6 @@ protected function createObject($value): array
128130 }
129131
130132 $ obj = null ;
131- // array config:
132- // [
133- // 'class' => string,
134- // // option for create.
135- // '__opt' => [
136- // 'callInit' => true,
137- // 'argsForNew' => [$arg0, $arg1],
138- // ],
139- // // props settings ...
140- // 'propName' => value,
141- // ]
142133 if (is_array ($ value )) {
143134 $ count = count ($ value );
144135
@@ -173,6 +164,31 @@ protected function createObject($value): array
173164 }
174165
175166 /**
167+ * Register an service definition to the box.
168+ *
169+ * **$definition**:
170+ *
171+ * - Closure
172+ * - Object and has __invoke()
173+ * - string: an function name
174+ * - array: callable array [class, method]
175+ * - array: config array
176+ *
177+ * ```php
178+ * [
179+ * 'class' => string,
180+ * // option for create object.
181+ * '__opt' => [
182+ * 'callInit' => true,
183+ * 'argsForNew' => [$arg0, $arg1],
184+ * ],
185+ * // props settings ...
186+ * 'propName' => value,
187+ * ]
188+ * ```
189+ *
190+ * - more, any type as config data.
191+ *
176192 * @param string $id
177193 * @param mixed $definition
178194 * @param bool $override
0 commit comments