add cs fixer and PHPStan and activate it (build 436)

This commit is contained in:
crazywhalecc
2022-03-15 18:05:33 +08:00
parent d01bd69aa5
commit 1706afbcd0
163 changed files with 4572 additions and 3588 deletions

View File

@@ -1,22 +1,23 @@
<?php
declare(strict_types=1);
namespace ZM\Event;
use ZM\Annotation\AnnotationBase;
class EventTracer
{
/**
* 获取当前注解事件的注解类如CQCommand对象
* @return AnnotationBase|null
* @return null|AnnotationBase
*/
public static function getCurrentEvent() {
public static function getCurrentEvent()
{
$list = debug_backtrace();
foreach ($list as $v) {
if ((($v["object"] ?? null) instanceof EventDispatcher) && $v["function"] == "dispatchEvent") {
return $v["args"][0];
if ((($v['object'] ?? null) instanceof EventDispatcher) && $v['function'] == 'dispatchEvent') {
return $v['args'][0];
}
}
return null;
@@ -24,22 +25,26 @@ class EventTracer
/**
* 获取当前注解事件的中间件列表
* @return array|mixed|null
* @return null|array|mixed
*/
public static function getCurrentEventMiddlewares() {
public static function getCurrentEventMiddlewares()
{
$current_event = self::getCurrentEvent();
if (!isset($current_event->class, $current_event->method)) return null;
if (!isset($current_event->class, $current_event->method)) {
return null;
}
return EventManager::$middleware_map[$current_event->class][$current_event->method] ?? [];
}
public static function getEventTraceList() {
public static function getEventTraceList()
{
$result = [];
$list = debug_backtrace();
foreach ($list as $v) {
if ((($v["object"] ?? null) instanceof EventDispatcher) && $v["function"] == "dispatchEvent") {
$result[] = $v["args"][0];
if ((($v['object'] ?? null) instanceof EventDispatcher) && $v['function'] == 'dispatchEvent') {
$result[] = $v['args'][0];
}
}
return $result;
}
}
}