@@ -47,12 +47,12 @@ class Artful
4747 HttpServiceProvider::class,
4848 ];
4949
50- private static null | Closure |ContainerInterface $ container = null ;
50+ private static Closure |ContainerInterface | null $ container = null ;
5151
5252 /**
5353 * @throws ContainerException
5454 */
55- private function __construct (array $ config , null | Closure |ContainerInterface $ container = null )
55+ private function __construct (array $ config , Closure |ContainerInterface | null $ container = null )
5656 {
5757 $ this ->registerServices ($ config , $ container );
5858
@@ -61,7 +61,11 @@ private function __construct(array $config, null|Closure|ContainerInterface $con
6161 }
6262
6363 /**
64- * @return mixed
64+ * @template T
65+ *
66+ * @param class-string<T> $service
67+ *
68+ * @return mixed|T
6569 *
6670 * @throws ContainerException
6771 * @throws ServiceNotFoundException
@@ -78,7 +82,7 @@ public static function __callStatic(string $service, array $config)
7882 /**
7983 * @throws ContainerException
8084 */
81- public static function config (array $ config = [], null | Closure |ContainerInterface $ container = null ): bool
85+ public static function config (array $ config = [], Closure |ContainerInterface | null $ container = null ): bool
8286 {
8387 if (self ::hasContainer () && !($ config ['_force ' ] ?? false )) {
8488 return false ;
@@ -144,6 +148,12 @@ public static function make(string $service, array $parameters = []): mixed
144148 }
145149
146150 /**
151+ * @template T
152+ *
153+ * @param class-string<T> $service
154+ *
155+ * @return mixed|T
156+ *
147157 * @throws ServiceNotFoundException
148158 * @throws ContainerException
149159 */
@@ -168,7 +178,7 @@ public static function has(string $service): bool
168178 return Artful::getContainer ()->has ($ service );
169179 }
170180
171- public static function setContainer (null | Closure |ContainerInterface $ container ): void
181+ public static function setContainer (Closure |ContainerInterface | null $ container ): void
172182 {
173183 self ::$ container = $ container ;
174184 }
@@ -224,7 +234,7 @@ public static function registerService(string $service, mixed $data = null): voi
224234 * @throws InvalidParamsException
225235 * @throws ServiceNotFoundException
226236 */
227- public static function shortcut (string $ shortcut , array $ params = []): null | Collection |MessageInterface |Rocket
237+ public static function shortcut (string $ shortcut , array $ params = []): Collection |MessageInterface |Rocket | null
228238 {
229239 if (!class_exists ($ shortcut ) || !in_array (ShortcutInterface::class, class_implements ($ shortcut ))) {
230240 throw new InvalidParamsException (Exception::PARAMS_SHORTCUT_INVALID , "参数异常: [ {$ shortcut }] 未实现 `ShortcutInterface` " );
@@ -240,7 +250,7 @@ public static function shortcut(string $shortcut, array $params = []): null|Coll
240250 * @throws ContainerException
241251 * @throws InvalidParamsException
242252 */
243- public static function artful (array $ plugins , array $ params ): null | Collection |MessageInterface |Rocket
253+ public static function artful (array $ plugins , array $ params ): Collection |MessageInterface |Rocket | null
244254 {
245255 Event::dispatch (new Event \ArtfulStart ($ plugins , $ params ));
246256
@@ -333,7 +343,7 @@ protected static function verifyPlugin(array $plugins): void
333343 /**
334344 * @throws ContainerException
335345 */
336- private function registerServices (array $ config , null | Closure |ContainerInterface $ container = null ): void
346+ private function registerServices (array $ config , Closure |ContainerInterface | null $ container = null ): void
337347 {
338348 foreach ($ this ->coreService as $ service ) {
339349 self ::registerService ($ service , ContainerServiceProvider::class == $ service ? $ container : $ config );
0 commit comments