From c2a0211517d7a389ba2c80d16580f6c4fef9a541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 22 Feb 2021 19:38:44 +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/Annotation.php | 56 +++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/Annotation/Annotation.php b/Annotation/Annotation.php index 13e33b0a..5f8eeb6f 100644 --- a/Annotation/Annotation.php +++ b/Annotation/Annotation.php @@ -4,6 +4,7 @@ namespace Annotation; +use Exception; use ReflectionAttribute; use ReflectionClass; use ReflectionException; @@ -114,26 +115,29 @@ class Annotation extends Component * @param string $class * @param string $alias * @return array - * @throws ReflectionException - * @throws NotFindPropertyException - * @throws NotFindClassException + * @throws Exception */ private function getReflect(string $class, string $alias): array { - $reflect = $this->reflectClass($class); - var_dump($class, $reflect); - if (empty($reflect)) { + try { + $reflect = $this->reflectClass($class); + var_dump($class, $reflect); + if (empty($reflect)) { + return []; + } + + $constructor = $reflect->getConstructor(); + if (!empty($constructor) && count($constructor->getParameters()) > 0) { + return []; + } + + $object = $reflect->newInstance(); + $this->resolveMethod($reflect, $class, $alias, $object); + return $this->targets($reflect); + } catch (\Throwable $throwable) { + $this->addError($throwable); return []; } - - $constructor = $reflect->getConstructor(); - if (!empty($constructor) && count($constructor->getParameters()) > 0) { - return []; - } - - $object = $reflect->newInstance(); - $this->resolveMethod($reflect, $class, $alias, $object); - return $this->targets($reflect); } @@ -146,20 +150,16 @@ class Annotation extends Component */ private function resolveMethod(ReflectionClass $reflect, $class, $alias, $object) { - try { - foreach ($reflect->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { - if ($method->class != $class) { - continue; - } - - $tmp = $this->resolveAnnotations($method, $alias, $object); - if (empty($tmp)) { - continue; - } - $this->_classes[$reflect->getName()][$method->getName()] = $tmp; + foreach ($reflect->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { + if ($method->class != $class) { + continue; } - } catch (\Throwable $throwable) { - $this->addError($throwable); + + $tmp = $this->resolveAnnotations($method, $alias, $object); + if (empty($tmp)) { + continue; + } + $this->_classes[$reflect->getName()][$method->getName()] = $tmp; } $this->resolveProperty($reflect, $object); }