From 857ec53870422b257ced049b43f8a4db85aa7167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 12 Jul 2021 17:17:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Annotation/Aspect.php | 7 +- Annotation/Asynchronous.php | 7 +- Annotation/Event.php | 7 +- Annotation/IAnnotation.php | 9 +- Annotation/Inject.php | 15 +- Annotation/Kafka.php | 13 +- Annotation/Loader.php | 591 ++++++++++++++++--------------- Annotation/LocalService.php | 6 +- Annotation/Model/Get.php | 11 +- Annotation/Model/Relation.php | 5 +- Annotation/Model/Set.php | 3 +- Annotation/Route/Document.php | 3 +- Annotation/Route/Filter.php | 4 +- Annotation/Route/Interceptor.php | 5 +- Annotation/Route/Limits.php | 3 +- Annotation/Route/Middleware.php | 3 +- Annotation/Route/Route.php | 4 +- Annotation/Route/RpcProducer.php | 12 +- Annotation/Rpc/Consumer.php | 9 +- Annotation/Rpc/RpcClient.php | 13 +- 20 files changed, 384 insertions(+), 346 deletions(-) diff --git a/Annotation/Aspect.php b/Annotation/Aspect.php index f1baa74e..12b76d05 100644 --- a/Annotation/Aspect.php +++ b/Annotation/Aspect.php @@ -28,9 +28,10 @@ defined('ASPECT_ERROR') or define('ASPECT_ERROR', 'Aspect annotation must implem } - - - public function execute(mixed $class, mixed $method = ''): mixed + /** + * @throws Exception + */ + public function execute(mixed $class, mixed $method = ''): bool { // TODO: Change the autogenerated stub if (!in_array(IAspect::class, class_implements($this->aspect))) { diff --git a/Annotation/Asynchronous.php b/Annotation/Asynchronous.php index b74cdc10..428e1eca 100644 --- a/Annotation/Asynchronous.php +++ b/Annotation/Asynchronous.php @@ -29,12 +29,13 @@ use Snowflake\Snowflake; /** - * @param array $handler + * @param mixed $class + * @param mixed|null $method * @return bool * @throws Exception */ - public function execute(mixed $class, mixed $method = null): mixed - { + public function execute(mixed $class, mixed $method = null): bool + { $async = Snowflake::app()->getAsync(); $async->addAsync($this->name, $class); return true; diff --git a/Annotation/Event.php b/Annotation/Event.php index 3698d28a..3775802b 100644 --- a/Annotation/Event.php +++ b/Annotation/Event.php @@ -29,12 +29,13 @@ use Snowflake\Event as SEvent; /** - * @param array $handler + * @param mixed $class + * @param mixed|null $method * @return bool * @throws Exception */ - public function execute(mixed $class, mixed $method = null): mixed - { + public function execute(mixed $class, mixed $method = null): bool + { // TODO: Implement execute() method. SEvent::on($this->name, [$class, $method], $this->params); return true; diff --git a/Annotation/IAnnotation.php b/Annotation/IAnnotation.php index 8a707b68..0887ce42 100644 --- a/Annotation/IAnnotation.php +++ b/Annotation/IAnnotation.php @@ -9,10 +9,11 @@ use Closure; interface IAnnotation { - /** - * @param array $handler - * @return mixed - */ + /** + * @param mixed $class + * @param mixed $method + * @return mixed + */ public function execute(mixed $class, mixed $method = ''): mixed; diff --git a/Annotation/Inject.php b/Annotation/Inject.php index 42c5581b..4dc1b5ef 100644 --- a/Annotation/Inject.php +++ b/Annotation/Inject.php @@ -5,6 +5,7 @@ namespace Annotation; use Exception; +use ReflectionException; use ReflectionProperty; use Snowflake\Snowflake; @@ -26,12 +27,14 @@ use Snowflake\Snowflake; } - /** - * @param array $handler - * @return mixed - * @throws Exception - */ - public function execute(mixed $class, mixed $method = null): mixed + /** + * @param mixed $class + * @param mixed|null $method + * @return bool + * @throws ReflectionException + * @throws Exception + */ + public function execute(mixed $class, mixed $method = null): bool { $injectValue = $this->parseInjectValue(); if (!($method instanceof ReflectionProperty)) { diff --git a/Annotation/Kafka.php b/Annotation/Kafka.php index 314571bb..a08adfce 100644 --- a/Annotation/Kafka.php +++ b/Annotation/Kafka.php @@ -4,6 +4,7 @@ namespace Annotation; +use Exception; use Kafka\ConsumerInterface; use Kafka\TaskContainer; use Snowflake\Snowflake; @@ -26,11 +27,13 @@ use Snowflake\Snowflake; } - /** - * @param array $handler - * @return mixed - */ - public function execute(mixed $class, mixed $method = null): mixed + /** + * @param mixed $class + * @param mixed|null $method + * @return bool + * @throws Exception + */ + public function execute(mixed $class, mixed $method = null): bool { if (!($class instanceof ConsumerInterface)) { return false; diff --git a/Annotation/Loader.php b/Annotation/Loader.php index ad809d38..3792fdcd 100644 --- a/Annotation/Loader.php +++ b/Annotation/Loader.php @@ -10,8 +10,11 @@ use Annotation\Model\Set; use Attribute; use DirectoryIterator; use Exception; +use ReflectionClass; +use ReflectionException; use ReflectionMethod; use Snowflake\Abstracts\BaseObject; +use Snowflake\Exception\NotFindClassException; use Snowflake\Snowflake; use Throwable; @@ -24,331 +27,343 @@ class Loader extends BaseObject { - private array $_classes = []; + private array $_classes = []; - private array $_directory = []; + private array $_directory = []; - /** - * @return array - */ - public function getDirectory(): array - { - return $this->_directory; - } - - /** - * @param $path - * @param $namespace - * @throws Exception - */ - public function loader($path, $namespace) - { - $this->_scanDir(new DirectoryIterator($path), $namespace); - } + private array $_annotationMaps = []; - /** - * @return array - */ - public function getClasses(): array - { - return $this->_classes; - } + /** + * @return array + */ + public function getDirectory(): array + { + return $this->_directory; + } + + /** + * @param $path + * @param $namespace + * @throws Exception + */ + public function loader($path, $namespace) + { + $this->_scanDir(new DirectoryIterator($path), $namespace); + } - /** - * @param string $class - * @param string $property - * @return mixed - */ - public function getProperty(string $class, string $property = ''): mixed - { - if (!isset($this->_classes[$class])) { - return null; - } - $properties = $this->_classes[$class]['property']; - if (!empty($property) && isset($properties[$property])) { - return $properties[$property]; - } - return $properties; - } + /** + * @return array + */ + public function getClasses(): array + { + return $this->_classes; + } - /** - * @param string $class - * @param mixed $handler - * @return Loader - */ - public function injectProperty(string $class, object $handler): static - { - $properties = $this->getProperty($class); - if (empty($properties)) { - return $this; - } - foreach ($properties as $property => $attributes) { - foreach ($attributes as $attribute) { - $attribute->execute($handler, $property); - } - } - return $this; - } + /** + * @param string $class + * @param string $property + * @return mixed + */ + public function getProperty(string $class, string $property = ''): mixed + { + if (!isset($this->_classes[$class])) { + return null; + } + $properties = $this->_classes[$class]['property']; + if (!empty($property) && isset($properties[$property])) { + return $properties[$property]; + } + return $properties; + } - /** - * @param string $class - * @param string $method - * @return mixed - */ - public function getMethod(string $class, string $method = ''): array - { - if (!isset($this->_classes[$class])) { - return []; - } - $properties = $this->_classes[$class]['methods']; - if (!empty($method) && isset($properties[$method])) { - return $properties[$method]; - } - return $properties; - } + /** + * @param string $class + * @param mixed $handler + * @return Loader + */ + public function injectProperty(string $class, object $handler): static + { + $properties = $this->getProperty($class); + if (empty($properties)) { + return $this; + } + foreach ($properties as $property => $attributes) { + foreach ($attributes as $attribute) { + $attribute->execute($handler, $property); + } + } + return $this; + } - /** - * @param string $class - * @return array - */ - public function getTarget(string $class): array - { - return $this->_classes[$class] ?? []; - } + /** + * @param string $class + * @param string $method + * @return mixed + */ + public function getMethod(string $class, string $method = ''): array + { + if (!isset($this->_classes[$class])) { + return []; + } + $properties = $this->_classes[$class]['methods']; + if (!empty($method) && isset($properties[$method])) { + return $properties[$method]; + } + return $properties; + } - /** - * @param DirectoryIterator $paths - * @param $namespace - * @throws Exception - */ - public function _scanDir(DirectoryIterator $paths, $namespace) - { - foreach ($paths as $path) { - if ($path->isDot() || str_starts_with($path->getFilename(), '.')) { - continue; - } - if ($path->isDir()) { - $iterator = new DirectoryIterator($path->getRealPath()); - $directory = rtrim($path->getRealPath(), '/'); - if (!isset($this->_directory[$directory])) { - $this->_directory[$directory] = []; - } - $this->_scanDir($iterator, $namespace); - } else { - $this->readFile($path, $namespace); - } - } - } + /** + * @param string $class + * @return array + */ + public function getTarget(string $class): array + { + return $this->_classes[$class] ?? []; + } - /** - * @param DirectoryIterator $path - * @param $namespace - * @throws Exception - */ - private function readFile(DirectoryIterator $path, $namespace) - { - try { - if ($path->getExtension() !== 'php') { - return; - } - $replace = $this->getReflect($path, $namespace); - if (empty($replace) || count($replace->getAttributes(Target::class)) < 1) { - return; - } - $this->appendFileToDirectory($path->getRealPath(), $replace->getName()); - - $_array['handler'] = $replace->newInstance(); - $_array['target'] = []; - $_array['methods'] = []; - $_array['property'] = []; - - $_array = $this->_targets($replace, $_array); - $_array = $this->_methods($replace, $_array); - $_array = $this->_properties($replace, $_array); - - $this->_classes[$replace->getName()] = $_array; - } catch (Throwable $throwable) { - $this->addError($throwable, 'throwable'); - } - } + /** + * @param DirectoryIterator $paths + * @param $namespace + * @throws Exception + */ + public function _scanDir(DirectoryIterator $paths, $namespace) + { + foreach ($paths as $path) { + if ($path->isDot() || str_starts_with($path->getFilename(), '.')) { + continue; + } + if ($path->isDir()) { + $iterator = new DirectoryIterator($path->getRealPath()); + $directory = rtrim($path->getRealPath(), '/'); + if (!isset($this->_directory[$directory])) { + $this->_directory[$directory] = []; + } + $this->_scanDir($iterator, $namespace); + } else { + $this->readFile($path, $namespace); + } + } + } - /** - * @param string $path - * @param string $namespace - * @return \ReflectionClass|null - * @throws \ReflectionException - * @throws \Snowflake\Exception\NotFindClassException - */ - private function getReflect(DirectoryIterator $path, string $namespace): ?\ReflectionClass - { - return Snowflake::getDi()->getReflect($this->explodeFileName($path, $namespace)); - } + /** + * @param DirectoryIterator $path + * @param $namespace + * @throws Exception + */ + private function readFile(DirectoryIterator $path, $namespace) + { + try { + if ($path->getExtension() !== 'php') { + return; + } + $replace = $this->getReflect($path, $namespace); + if (empty($replace) || count($replace->getAttributes(Target::class)) < 1) { + return; + } + $this->appendFileToDirectory($path->getRealPath(), $replace->getName()); + + $_array['handler'] = $replace->newInstance(); + $_array['target'] = []; + $_array['methods'] = []; + $_array['property'] = []; + + $_array = $this->_targets($replace, $_array); + $_array = $this->_methods($replace, $_array); + $_array = $this->_properties($replace, $_array); + + $this->_classes[$replace->getName()] = $_array; + } catch (Throwable $throwable) { + $this->addError($throwable, 'throwable'); + } + } - /** - * @param \ReflectionClass $replace - * @param array $_array - * @return array - */ - private function _targets(\ReflectionClass $replace, array $_array): array - { - foreach ($replace->getAttributes() as $attribute) { - if ($attribute->getName() == Attribute::class) { - continue; - } - if ($attribute->getName() == Target::class) { - continue; - } - $_array['target'][] = $attribute->newInstance(); - } - return $_array; - } + /** + * @param DirectoryIterator $path + * @param string $namespace + * @return ReflectionClass|null + * @throws ReflectionException + * @throws NotFindClassException + */ + private function getReflect(DirectoryIterator $path, string $namespace): ?ReflectionClass + { + return Snowflake::getDi()->getReflect($this->explodeFileName($path, $namespace)); + } - /** - * @param \ReflectionClass $replace - * @param array $_array - * @return array - */ - private function _methods(\ReflectionClass $replace, array $_array): array - { - $methods = $replace->getMethods(ReflectionMethod::IS_PUBLIC); - foreach ($methods as $method) { - $_method = []; - foreach ($method->getAttributes() as $attribute) { - if (!class_exists($attribute->getName())) { - continue; - } - $_method[] = $attribute->newInstance(); - } - $_array['methods'][$method->getName()] = $_method; - } - return $_array; - } + /** + * @param ReflectionClass $replace + * @param array $_array + * @return array + */ + private function _targets(ReflectionClass $replace, array $_array): array + { + foreach ($replace->getAttributes() as $attribute) { + if ($attribute->getName() == Attribute::class) { + continue; + } + if ($attribute->getName() == Target::class) { + continue; + } + $_array['target'][] = $attribute->newInstance(); + } + return $_array; + } - /** - * @param \ReflectionClass $replace - * @param array $_array - * @return array - */ - private function _properties(\ReflectionClass $replace, array $_array): array - { - $methods = $replace->getProperties(); - foreach ($methods as $method) { - $_property = []; - if ($method->isStatic()) continue; - foreach ($method->getAttributes() as $attribute) { - if (!class_exists($attribute->getName())) { - continue; - } - $_property[] = $attribute->newInstance(); - } - $_array['property'][$method->getName()] = $_property; - } - return $_array; - } + /** + * @param ReflectionClass $replace + * @param array $_array + * @return array + */ + private function _methods(ReflectionClass $replace, array $_array): array + { + $methods = $replace->getMethods(ReflectionMethod::IS_PUBLIC); + foreach ($methods as $method) { + $_method = []; + foreach ($method->getAttributes() as $attribute) { + if (!class_exists($attribute->getName())) { + continue; + } + $_method[] = $attribute->newInstance(); + } + $_array['methods'][$method->getName()] = $_method; + } + return $_array; + } - /** - * @param string $path - * @param string|array $outPath - * @throws Exception - */ - public function loadByDirectory(string $path, string|array $outPath = '') - { - try { - $path = '/' . trim($path, '/'); - foreach ($this->_directory as $key => $_path) { - $key = '/' . trim($key, '/'); - if (!str_starts_with($key, $path) || in_array($key, $outPath)) { - continue; - } - $this->execute($_path); - } - } catch (Throwable $exception) { - $this->addError($exception, 'throwable'); - } - } + /** + * @param ReflectionClass $replace + * @param array $_array + * @return array + */ + private function _properties(ReflectionClass $replace, array $_array): array + { + $methods = $replace->getProperties(); + foreach ($methods as $method) { + $_property = []; + if ($method->isStatic()) continue; + foreach ($method->getAttributes() as $attribute) { + if (!class_exists($attribute->getName())) { + continue; + } + $_property[] = $attribute->newInstance(); + } + $_array['property'][$method->getName()] = $_property; + } + return $_array; + } - /** - * @param DirectoryIterator $path - * @param string $namespace - * @return string - */ - private function explodeFileName(DirectoryIterator $path, string $namespace): string - { - $replace = str_replace(APP_PATH . 'app', '', $path->getRealPath()); - - $replace = str_replace('.php', '', $replace); - $replace = str_replace(DIRECTORY_SEPARATOR, '\\', $replace); - $explode = explode('\\', $replace); - array_shift($explode); - - return $namespace . '\\' . implode('\\', $explode); - } + /** + * @param string $path + * @param string|array $outPath + * @throws Exception + */ + public function loadByDirectory(string $path, string|array $outPath = '') + { + try { + $path = '/' . trim($path, '/'); + foreach ($this->_directory as $key => $_path) { + $key = '/' . trim($key, '/'); + if (!str_starts_with($key, $path) || in_array($key, $outPath)) { + continue; + } + $this->execute($_path); + } + } catch (Throwable $exception) { + $this->addError($exception, 'throwable'); + } + } - /** - * @param string $filePath - * @param string $className - */ - public function appendFileToDirectory(string $filePath, string $className) - { - $array = explode('/', $filePath); - unset($array[count($array) - 1]); + /** + * @param DirectoryIterator $path + * @param string $namespace + * @return string + */ + private function explodeFileName(DirectoryIterator $path, string $namespace): string + { + $replace = str_replace(APP_PATH . 'app', '', $path->getRealPath()); - $array = '/' . trim(implode('/', $array), '/'); + $replace = str_replace('.php', '', $replace); + $replace = str_replace(DIRECTORY_SEPARATOR, '\\', $replace); + $explode = explode('\\', $replace); + array_shift($explode); - $this->_directory[$array][] = $className; - } + return $namespace . '\\' . implode('\\', $explode); + } - /** - * @param array $classes - */ - private function execute(array $classes) - { - if (empty($classes)) { - return; - } - $annotation = Snowflake::getAnnotation(); + /** + * @param string $filePath + * @param string $className + */ + public function appendFileToDirectory(string $filePath, string $className) + { + $array = explode('/', $filePath); + unset($array[count($array) - 1]); - foreach ($classes as $className) { - $annotations = $this->_classes[$className] ?? null; - if ($annotations === null) { - continue; - } + $array = '/' . trim(implode('/', $array), '/'); - /** @var \Annotation\Attribute $value */ - foreach ($annotations['target'] ?? [] as $value) { - $value->execute($annotations['handler']); - } - foreach ($annotations['methods'] as $name => $attribute) { - foreach ($attribute as $value) { - if ($value instanceof Relation) { - $annotation->addRelate($className, $value->name, $name); - } else if ($value instanceof Get) { - $annotation->addGets($className, $value->name, $name); - } else if ($value instanceof Set) { - $annotation->addSets($className, $value->name, $name); - } else { - $value->execute($annotations['handler'], $name); - } - } - } - } - } + $this->_directory[$array][] = $className; + } + + + /** + * @param array $classes + * @throws Exception + */ + private function execute(array $classes) + { + if (empty($classes)) { + return; + } + $annotation = Snowflake::getAnnotation(); + + foreach ($classes as $className) { + $annotations = $this->_classes[$className] ?? null; + if ($annotations === null) { + continue; + } + foreach ($annotations['methods'] as $name => $attribute) { + $this->methods($annotations, $attribute, $annotation, $className, $name); + } + } + } + + + /** + * @param $annotations + * @param $attribute + * @param $annotation + * @param $className + * @param $name + */ + private function methods($annotations, $attribute, $annotation, $className, $name) + { + foreach ($attribute as $value) { + if ($value instanceof Relation) { + $annotation->addRelate($className, $value->name, $name); + } else if ($value instanceof Get) { + $annotation->addGets($className, $value->name, $name); + } else if ($value instanceof Set) { + $annotation->addSets($className, $value->name, $name); + } else { + $value->execute($annotations['handler'], $name); + } + } + } } diff --git a/Annotation/LocalService.php b/Annotation/LocalService.php index 33c0d8e9..e1689fb3 100644 --- a/Annotation/LocalService.php +++ b/Annotation/LocalService.php @@ -37,10 +37,10 @@ use Snowflake\Snowflake; /** * @param object $class * @param string $method - * @return mixed - * @throws \Exception + * @return bool + * @throws Exception */ - public function execute(mixed $class, mixed $method = null): mixed + public function execute(mixed $class, mixed $method = null): bool { $class = ['class' => $class::class]; if (!empty($this->args)) { diff --git a/Annotation/Model/Get.php b/Annotation/Model/Get.php index ef6165e1..e10f4257 100644 --- a/Annotation/Model/Get.php +++ b/Annotation/Model/Get.php @@ -7,6 +7,7 @@ namespace Annotation\Model; use Annotation\Annotation; use Attribute; use Database\ActiveRecord; +use Exception; use Snowflake\Snowflake; @@ -27,10 +28,12 @@ use Snowflake\Snowflake; } - /** - * @param array $handler - * @return ActiveRecord - */ + /** + * @param mixed $class + * @param mixed|null $method + * @return bool + * @throws Exception + */ public function execute(mixed $class, mixed $method = null): bool { $annotation = Snowflake::getAnnotation(); diff --git a/Annotation/Model/Relation.php b/Annotation/Model/Relation.php index 19520ba5..0ae61631 100644 --- a/Annotation/Model/Relation.php +++ b/Annotation/Model/Relation.php @@ -6,6 +6,7 @@ namespace Annotation\Model; use Annotation\Attribute; use Database\ActiveRecord; +use Exception; use JetBrains\PhpStorm\Pure; use Snowflake\Snowflake; @@ -28,8 +29,10 @@ use Snowflake\Snowflake; /** - * @param array $handler + * @param mixed $class + * @param mixed|null $method * @return bool + * @throws Exception */ public function execute(mixed $class, mixed $method = null): bool { diff --git a/Annotation/Model/Set.php b/Annotation/Model/Set.php index 0d83c642..bdb3554c 100644 --- a/Annotation/Model/Set.php +++ b/Annotation/Model/Set.php @@ -6,6 +6,7 @@ namespace Annotation\Model; use Annotation\Attribute; use Database\ActiveRecord; +use Exception; use Snowflake\Snowflake; #[\Attribute(\Attribute::TARGET_METHOD)] class Set extends Attribute @@ -25,7 +26,7 @@ use Snowflake\Snowflake; * @param mixed $class * @param mixed|null $method * @return bool - * @throws \Exception + * @throws Exception */ public function execute(mixed $class, mixed $method = null): bool { diff --git a/Annotation/Route/Document.php b/Annotation/Route/Document.php index 75e7a4d9..3a92b96b 100644 --- a/Annotation/Route/Document.php +++ b/Annotation/Route/Document.php @@ -35,7 +35,8 @@ use Annotation\Attribute; /** - * @param array $handler + * @param mixed $class + * @param mixed|null $method * @return array */ public function execute(mixed $class, mixed $method = null): array diff --git a/Annotation/Route/Filter.php b/Annotation/Route/Filter.php index 4deaa808..63fe7269 100644 --- a/Annotation/Route/Filter.php +++ b/Annotation/Route/Filter.php @@ -29,9 +29,9 @@ use Snowflake\Snowflake; /** - * @param array $handler + * @param mixed $class + * @param mixed|null $method * @return bool - * @throws Exception */ public function execute(mixed $class, mixed $method = null): bool { diff --git a/Annotation/Route/Interceptor.php b/Annotation/Route/Interceptor.php index 224b661d..c7974696 100644 --- a/Annotation/Route/Interceptor.php +++ b/Annotation/Route/Interceptor.php @@ -21,7 +21,7 @@ use Snowflake\Snowflake; * @param string|array $interceptor * @throws */ - #[Pure] public function __construct(public string|array $interceptor) + public function __construct(public string|array $interceptor) { if (is_string($this->interceptor)) { $this->interceptor = [$this->interceptor]; @@ -40,7 +40,8 @@ use Snowflake\Snowflake; /** - * @param array $handler + * @param mixed $class + * @param mixed|null $method * @return Interceptor */ public function execute(mixed $class, mixed $method = null): static diff --git a/Annotation/Route/Limits.php b/Annotation/Route/Limits.php index 19097d6e..f9f1ac94 100644 --- a/Annotation/Route/Limits.php +++ b/Annotation/Route/Limits.php @@ -39,7 +39,8 @@ use Snowflake\Snowflake; /** - * @param array $handler + * @param mixed $class + * @param mixed|null $method * @return Limits */ public function execute(mixed $class, mixed $method = null): static diff --git a/Annotation/Route/Middleware.php b/Annotation/Route/Middleware.php index e6558fdd..0395e321 100644 --- a/Annotation/Route/Middleware.php +++ b/Annotation/Route/Middleware.php @@ -40,7 +40,8 @@ use HttpServer\IInterface\Middleware as IMiddleware; /** - * @param array $handler + * @param mixed $class + * @param mixed|null $method * @return Middleware */ public function execute(mixed $class, mixed $method = null): static diff --git a/Annotation/Route/Route.php b/Annotation/Route/Route.php index 98c6e462..4c48bdc9 100644 --- a/Annotation/Route/Route.php +++ b/Annotation/Route/Route.php @@ -29,9 +29,9 @@ use Snowflake\Snowflake; /** - * @param array $handler + * @param mixed $class + * @param mixed|null $method * @return Router - * @throws ConfigException * @throws Exception */ public function execute(mixed $class, mixed $method = null): Router diff --git a/Annotation/Route/RpcProducer.php b/Annotation/Route/RpcProducer.php index 4a1e9825..5cb01b9f 100644 --- a/Annotation/Route/RpcProducer.php +++ b/Annotation/Route/RpcProducer.php @@ -35,12 +35,12 @@ use Snowflake\Snowflake; } - - /** - * @param array $handler - * @return Router - * @throws Exception - */ + /** + * @param mixed $class + * @param mixed|null $method + * @return Router + * @throws Exception + */ public function execute(mixed $class, mixed $method = null): Router { // TODO: Implement setHandler() method. diff --git a/Annotation/Rpc/Consumer.php b/Annotation/Rpc/Consumer.php index b498e733..446c3084 100644 --- a/Annotation/Rpc/Consumer.php +++ b/Annotation/Rpc/Consumer.php @@ -28,12 +28,13 @@ use Snowflake\Snowflake; /** - * @param array $handler - * @return mixed + * @param mixed $class + * @param mixed $method + * @return bool * @throws Exception */ - public function execute(mixed $class, mixed $method = ''): mixed - { + public function execute(mixed $class, mixed $method = ''): bool + { $rpc = Snowflake::app()->getRpc(); $rpc->addConsumer($this->cmd, [$class, $method]); return true; // TODO: Change the autogenerated stub diff --git a/Annotation/Rpc/RpcClient.php b/Annotation/Rpc/RpcClient.php index 8876d7ea..297078ed 100644 --- a/Annotation/Rpc/RpcClient.php +++ b/Annotation/Rpc/RpcClient.php @@ -37,12 +37,13 @@ use Snowflake\Snowflake; } - /** - * @param array $handler - * @return mixed - * @throws Exception - */ - public function execute(mixed $class, mixed $method = ''): mixed + /** + * @param mixed $class + * @param mixed $method + * @return bool + * @throws Exception + */ + public function execute(mixed $class, mixed $method = ''): bool { $rpc = Snowflake::app()->getRpc(); $rpc->addProducer($this->cmd, [$class, $method], $this->config);