diff --git a/src/ZM/API/CQ.php b/src/ZM/API/CQ.php index fcfefb5a..19980fb5 100644 --- a/src/ZM/API/CQ.php +++ b/src/ZM/API/CQ.php @@ -391,7 +391,7 @@ class CQ { $cqs = []; $offset = 0; - while (($head = mb_strpos(($submsg = mb_substr($msg, $offset)), '[CQ:')) !== false) { + while (($head = mb_strpos($submsg = mb_substr($msg, $offset), '[CQ:')) !== false) { $key_offset = mb_substr($submsg, $head); $tmpmsg = mb_strpos($key_offset, ']'); if ($tmpmsg === false) { diff --git a/src/ZM/Annotation/AnnotationParser.php b/src/ZM/Annotation/AnnotationParser.php index 227d1de7..38f385c1 100644 --- a/src/ZM/Annotation/AnnotationParser.php +++ b/src/ZM/Annotation/AnnotationParser.php @@ -25,6 +25,7 @@ use ZM\Event\EventManager; use ZM\Exception\AnnotationException; use ZM\Utils\Manager\RouteManager; use ZM\Utils\ZMUtil; + use function server; class AnnotationParser diff --git a/src/ZM/Command/BuildCommand.php b/src/ZM/Command/BuildCommand.php index f2f1e386..6fcf0f75 100644 --- a/src/ZM/Command/BuildCommand.php +++ b/src/ZM/Command/BuildCommand.php @@ -35,7 +35,7 @@ class BuildCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): int { $this->output = $output; - $target_dir = $input->getOption('target') ?? (WORKING_DIR); + $target_dir = $input->getOption('target') ?? WORKING_DIR; if (mb_strpos($target_dir, '../')) { $target_dir = realpath($target_dir); } diff --git a/src/ZM/Command/InitCommand.php b/src/ZM/Command/InitCommand.php index 26ffe578..8a7f411f 100644 --- a/src/ZM/Command/InitCommand.php +++ b/src/ZM/Command/InitCommand.php @@ -48,7 +48,7 @@ class InitCommand extends Command $info = pathinfo($file); @mkdir($base_path . $info['dirname'], 0777, true); echo 'Copying ' . $file . PHP_EOL; - $package_name = (json_decode(file_get_contents(__DIR__ . '/../../../composer.json'), true)['name']); + $package_name = json_decode(file_get_contents(__DIR__ . '/../../../composer.json'), true)['name']; copy($base_path . '/vendor/' . $package_name . $file, $base_path . $file); } else { echo 'Skipping ' . $file . ' , file exists.' . PHP_EOL; diff --git a/src/ZM/Container/ContainerTrait.php b/src/ZM/Container/ContainerTrait.php index d654dc32..0c3c0196 100644 --- a/src/ZM/Container/ContainerTrait.php +++ b/src/ZM/Container/ContainerTrait.php @@ -262,7 +262,7 @@ trait ContainerTrait $this->log(sprintf( '[%s] resolved (shared)%s', $abstract, - ($needs_contextual_build ? ' with ' . implode(', ', $parameters) : '') + $needs_contextual_build ? ' with ' . implode(', ', $parameters) : '' )); } return $this->shared[$abstract]; @@ -307,7 +307,7 @@ trait ContainerTrait $this->log(sprintf( '[%s] resolved%s', $abstract, - ($needs_contextual_build ? ' with ' . implode(', ', $parameters) : '') + $needs_contextual_build ? ' with ' . implode(', ', $parameters) : '' )); } @@ -383,7 +383,7 @@ trait ContainerTrait $this->log(sprintf( 'Called %s%s(%s)', ReflectionUtil::variableToString($callback), - ($default_method ? '@' . $default_method : ''), + $default_method ? '@' . $default_method : '', $str_parameters )); } diff --git a/src/ZM/Event/EventManager.php b/src/ZM/Event/EventManager.php index 09b60da4..e2bc78a6 100644 --- a/src/ZM/Event/EventManager.php +++ b/src/ZM/Event/EventManager.php @@ -34,7 +34,7 @@ class EventManager if ($event_obj->method instanceof Closure) { Console::debug("Adding event {$event_name} at @Anonymous"); } else { - Console::debug("Adding event {$event_name} at " . ($event_obj->class) . ':' . ($event_obj->method)); + Console::debug("Adding event {$event_name} at " . $event_obj->class . ':' . $event_obj->method); self::$event_map[$event_obj->class][$event_obj->method][] = $event_obj; } self::$events[$event_name][] = $event_obj; diff --git a/src/ZM/Event/SwooleEvent/OnManagerStart.php b/src/ZM/Event/SwooleEvent/OnManagerStart.php index 4c324f1a..1b1012f8 100644 --- a/src/ZM/Event/SwooleEvent/OnManagerStart.php +++ b/src/ZM/Event/SwooleEvent/OnManagerStart.php @@ -70,7 +70,7 @@ class OnManagerStart implements SwooleEvent } if (Framework::$argv['polling-watch']) { self::$watch_tick_id = swoole_timer_tick(3000, function () use ($server) { - $data = (DataProvider::scanDirFiles(DataProvider::getSourceRootDir() . '/src/')); + $data = DataProvider::scanDirFiles(DataProvider::getSourceRootDir() . '/src/'); $hash = md5(''); foreach ($data as $file) { $hash = md5($hash . md5_file($file)); diff --git a/src/ZM/Framework.php b/src/ZM/Framework.php index e6ce591a..25cd72b7 100644 --- a/src/ZM/Framework.php +++ b/src/ZM/Framework.php @@ -211,7 +211,7 @@ class Framework // 预览模式则直接提出 if ($args['preview'] ?? false) { - exit(); + exit; } // 初始化服务器 diff --git a/src/ZM/Utils/ZMUtil.php b/src/ZM/Utils/ZMUtil.php index 47df4fc9..757bcad9 100644 --- a/src/ZM/Utils/ZMUtil.php +++ b/src/ZM/Utils/ZMUtil.php @@ -11,6 +11,7 @@ use ZM\Framework; use ZM\Store\Lock\SpinLock; use ZM\Store\ZMAtomic; use ZM\Store\ZMBuf; + use function file_get_contents; use function get_included_files; use function is_callable; @@ -124,7 +125,7 @@ class ZMUtil continue 2; } } - } elseif (is_callable($rule) && !($rule($dir, $pathinfo))) { + } elseif (is_callable($rule) && !$rule($dir, $pathinfo)) { continue; } $dirname = $pathinfo['dirname'] == '.' ? '' : (str_replace('/', '\\', $pathinfo['dirname']) . '\\'); diff --git a/src/ZM/global_functions.php b/src/ZM/global_functions.php index 6253de9f..db16896b 100644 --- a/src/ZM/global_functions.php +++ b/src/ZM/global_functions.php @@ -57,7 +57,7 @@ function _zm_env_check() } if (version_compare(SWOOLE_VERSION, '4.6.7') < 0 && !extension_loaded('pcntl')) { Console::error(zm_internal_errcode('E00004') . 'Swoole 版本必须不低于 4.6.7 或 PHP 安装加载了 pcntl 扩展!'); - exit(); + exit; } }