@@ -76,6 +76,8 @@ public static function global(): self
76
76
}
77
77
78
78
/**
79
+ * Get an object by registered ID name
80
+ *
79
81
* @param string $id
80
82
*
81
83
* @return mixed|object
@@ -100,7 +102,7 @@ public function get(string $id)
100
102
}
101
103
}
102
104
103
- // storage
105
+ // storage it.
104
106
$ this ->objects [$ id ] = $ obj ;
105
107
return $ obj ;
106
108
}
@@ -128,17 +130,6 @@ protected function createObject($value): array
128
130
}
129
131
130
132
$ 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
- // ]
142
133
if (is_array ($ value )) {
143
134
$ count = count ($ value );
144
135
@@ -173,6 +164,31 @@ protected function createObject($value): array
173
164
}
174
165
175
166
/**
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
+ *
176
192
* @param string $id
177
193
* @param mixed $definition
178
194
* @param bool $override
0 commit comments