From b9d3add0731e4d6f5d0217190073958d8b5da3cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Sun, 16 Apr 2023 23:38:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Annotate/AbstractRequestMethod.php | 3 +++ src/Annotate/AutoController.php | 3 +++ src/Validator/BindForm.php | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/Annotate/AbstractRequestMethod.php b/src/Annotate/AbstractRequestMethod.php index 81dbbb0..544e523 100644 --- a/src/Annotate/AbstractRequestMethod.php +++ b/src/Annotate/AbstractRequestMethod.php @@ -27,6 +27,9 @@ abstract class AbstractRequestMethod $middlewareManager = \Kiri::getDi()->get(MiddlewareManager::class); foreach ($middleware as $value) { + if (!class_exists($value->getName())) { + continue; + } /** @var Middleware $instance */ $instance = $value->newInstance(); diff --git a/src/Annotate/AutoController.php b/src/Annotate/AutoController.php index 4a9bc80..6b133a4 100644 --- a/src/Annotate/AutoController.php +++ b/src/Annotate/AutoController.php @@ -17,6 +17,9 @@ class AutoController foreach ($reflection->getMethods() as $method) { $attributes = $method->getAttributes(); foreach ($attributes as $attribute) { + if (!class_exists($attribute->getName())) { + continue; + } $attribute->newInstance()->dispatch($object, $method->getName()); } } diff --git a/src/Validator/BindForm.php b/src/Validator/BindForm.php index 86fe9d3..b73b451 100644 --- a/src/Validator/BindForm.php +++ b/src/Validator/BindForm.php @@ -35,6 +35,9 @@ class BindForm implements InjectParameterInterface $validator->setFormData($reflect->newInstanceWithoutConstructor()); foreach ($reflect->getProperties() as $property) { foreach ($property->getAttributes() as $attribute) { + if (!class_exists($attribute->getName())) { + continue; + } $rule = $attribute->newInstance(); if ($rule instanceof ValidatorInterface) { $validator->addRule($property->getName(), $rule);