From 381062c6c5c18770315096a347431b07b564db38 Mon Sep 17 00:00:00 2001 From: jerry Date: Sat, 2 Jan 2021 16:36:25 +0800 Subject: [PATCH] update to 2.1.3 version fix an AnnotationParser bug which is stupid --- composer.json | 2 +- docs/update/v2.md | 28 +++++++++++++++++++++++++- src/ZM/Annotation/AnnotationParser.php | 8 ++++---- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 8bf6d504..80a0c499 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "High performance QQ robot and web server development framework", "minimum-stability": "stable", "license": "Apache-2.0", - "version": "2.1.2", + "version": "2.1.3", "extra": { "exclude_annotate": [ "src/ZM" diff --git a/docs/update/v2.md b/docs/update/v2.md index aa5a7b3c..f832d10f 100644 --- a/docs/update/v2.md +++ b/docs/update/v2.md @@ -1,8 +1,34 @@ # 更新日志(v2 版本) +## v2.1.3 + +> 更新时间:2021.1.2 + +- 修复:注解解析器在某种特殊情况下导致的 bug + +## v2.1.2 + +> 更新时间:2021.1.2 + +- 修复:引入包模式启动时会导致的满屏报错 + +## v2.1.1 + +> 更新时间:2021.1.2 + +- 修复:自定义加载注解选定 composer.json 文件错误的 bug + +## v2.1.0 + +> 更新时间:2021.1.2 + +- 新增:`@OnOpenEvent`,`@OnCloseEvent`,`@OnMessageEvent`,`@OnRequestEvent` +- 优化事件分发器,修复一些事件分发过程中的 bug +- 修复 `@CQBefore` 事件的 bug + ## v2.0.3 -> 更新事件:2020.12.31 +> 更新时间:2020.12.31 - 修复:CQBefore 注解事件在 level 低于 200 时无法调用的 bug - 修复:CQMetaEvent 注解事件调用时报错的 bug diff --git a/src/ZM/Annotation/AnnotationParser.php b/src/ZM/Annotation/AnnotationParser.php index d2c8aa0a..a1b2361d 100644 --- a/src/ZM/Annotation/AnnotationParser.php +++ b/src/ZM/Annotation/AnnotationParser.php @@ -88,7 +88,7 @@ class AnnotationParser //预处理1:将适用于每一个函数的注解到类注解重新注解到每个函数下面 if ($vs instanceof ErgodicAnnotation) { - foreach ($this->annotation_map[$v]["methods"] as $method) { + foreach (($this->annotation_map[$v]["methods"] ?? []) as $method) { $copy = clone $vs; $copy->method = $method->getName(); $this->annotation_map[$v]["methods_annotations"][$method->getName()][] = $copy; @@ -107,7 +107,7 @@ class AnnotationParser } //预处理3:处理每个函数上面的特殊注解,就是需要操作一些东西的 - foreach ($this->annotation_map[$v]["methods_annotations"] as $method_name => $methods_annotations) { + foreach (($this->annotation_map[$v]["methods_annotations"] ?? []) as $method_name => $methods_annotations) { foreach ($methods_annotations as $method_anno) { /** @var AnnotationBase $method_anno */ $method_anno->class = $v; @@ -135,11 +135,11 @@ class AnnotationParser public function generateAnnotationEvents() { $o = []; foreach ($this->annotation_map as $module => $obj) { - foreach ($obj["class_annotations"] as $class_annotation) { + foreach (($obj["class_annotations"] ?? []) as $class_annotation) { if ($class_annotation instanceof ErgodicAnnotation) continue; else $o[get_class($class_annotation)][] = $class_annotation; } - foreach ($obj["methods_annotations"] as $method_name => $methods_annotations) { + foreach (($obj["methods_annotations"] ?? []) as $method_name => $methods_annotations) { foreach ($methods_annotations as $annotation) { $o[get_class($annotation)][] = $annotation; }