From 80d0a614e0764de2de7d75b796b31f13a456265c Mon Sep 17 00:00:00 2001 From: JackyChen Date: Sat, 23 Mar 2024 23:28:09 +0800 Subject: [PATCH] Add double quote for the constant annotation --- src/Exceptions/ConstantException.php | 2 +- src/stubs/constant.stub | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Exceptions/ConstantException.php b/src/Exceptions/ConstantException.php index 1303cd5..bc0e578 100644 --- a/src/Exceptions/ConstantException.php +++ b/src/Exceptions/ConstantException.php @@ -55,7 +55,7 @@ public function getErrorMessage(int $code): string private static function parseAnnotationsFromDocComment($docComment): array { - $pattern = '/@(\w+)\((\d+|[^\)]+)\)/'; + $pattern = '/@(\w+)\((".*"|[^)]+)\)/'; preg_match_all($pattern, $docComment, $matches, PREG_SET_ORDER); $parsed_annotations = []; foreach ($matches as $match) { diff --git a/src/stubs/constant.stub b/src/stubs/constant.stub index 68a6bfd..223a2f7 100644 --- a/src/stubs/constant.stub +++ b/src/stubs/constant.stub @@ -8,7 +8,7 @@ use EverForge\ThinkConstant\Constant; class {%className%} extends Constant { /** - * @Message(失败) + * @Message("失败") */ public const SERVER_ERROR = 500; }