diff --git a/Handler/OnServer.php b/Handler/OnServer.php index 391586e..a19c23f 100644 --- a/Handler/OnServer.php +++ b/Handler/OnServer.php @@ -2,6 +2,7 @@ namespace Kiri\Server\Handler; +use Kiri\Di\Inject\Container; use Kiri\Events\EventDispatch; use Kiri\Exception\ConfigException; use Kiri\Server\Events\OnAfterReload; @@ -24,14 +25,8 @@ class OnServer extends Server { - /** - * @param EventDispatch $dispatch - * @throws \Exception - */ - public function __construct(public EventDispatch $dispatch) - { - parent::__construct(); - } + #[Container(EventDispatch::class)] + public EventDispatch $dispatch; /** diff --git a/Handler/OnServerManager.php b/Handler/OnServerManager.php index 79f03f1..77fe268 100644 --- a/Handler/OnServerManager.php +++ b/Handler/OnServerManager.php @@ -3,6 +3,7 @@ namespace Kiri\Server\Handler; use Kiri; +use Kiri\Di\Inject\Container; use Kiri\Events\EventDispatch; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; @@ -20,20 +21,16 @@ use Kiri\Server\Events\OnManagerStop; class OnServerManager extends Server { - /** - * @param EventDispatch $dispatch - * @throws \Exception - */ - public function __construct(public EventDispatch $dispatch) - { - parent::__construct(); - } + #[Container(EventDispatch::class)] + public EventDispatch $dispatch; + + /** * @param \Swoole\Server $server * @throws ConfigException * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface|ReflectionException + * @throws NotFoundExceptionInterface */ public function onManagerStart(\Swoole\Server $server) { @@ -48,7 +45,6 @@ class OnServerManager extends Server * @return void * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface - * @throws ReflectionException */ public function onManagerStop(\Swoole\Server $server): void {