mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-11 10:45:35 +08:00
Compare commits
14 Commits
3.2.5
...
fix/signal
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a57294e48 | ||
|
|
a249fb5bfb | ||
|
|
1183766701 | ||
|
|
a39e96acd2 | ||
|
|
9cd3f9accf | ||
|
|
a5b9260d14 | ||
|
|
5e3397e7ae | ||
|
|
d5e18a7229 | ||
|
|
228762ce7b | ||
|
|
3a05a0e6ba | ||
|
|
2da5ef3db1 | ||
|
|
4c37294275 | ||
|
|
f16dadf29e | ||
|
|
c238bb25d2 |
@@ -12,14 +12,14 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.base_ref }}
|
||||
|
||||
- name: Setup PHP
|
||||
uses: sunxyw/workflows/setup-environment@main
|
||||
with:
|
||||
php-version: 8.0
|
||||
php-version: 8.3
|
||||
php-extensions: swoole, posix, json
|
||||
operating-system: ubuntu-latest
|
||||
use-cache: true
|
||||
@@ -40,14 +40,14 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.base_ref }}
|
||||
|
||||
- name: Setup PHP
|
||||
uses: sunxyw/workflows/setup-environment@main
|
||||
with:
|
||||
php-version: 8.1
|
||||
php-version: 8.3
|
||||
php-extensions: swoole, posix, json
|
||||
operating-system: ubuntu-latest
|
||||
use-cache: true
|
||||
|
||||
4
.github/workflows/coding-style.yml
vendored
4
.github/workflows/coding-style.yml
vendored
@@ -27,14 +27,14 @@ jobs:
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup PHP
|
||||
uses: sunxyw/workflows/setup-environment@main
|
||||
with:
|
||||
php-version: 8.0
|
||||
php-version: 8.3
|
||||
php-extensions: swoole, posix, json
|
||||
operating-system: ubuntu-latest
|
||||
use-cache: true
|
||||
|
||||
4
.github/workflows/increment-build-number.yml
vendored
4
.github/workflows/increment-build-number.yml
vendored
@@ -16,14 +16,14 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.base_ref }}
|
||||
|
||||
- name: Setup PHP
|
||||
uses: sunxyw/workflows/setup-environment@main
|
||||
with:
|
||||
php-version: 8.1
|
||||
php-version: 8.3
|
||||
php-extensions: swoole, posix, json
|
||||
operating-system: ubuntu-latest
|
||||
use-cache: true
|
||||
|
||||
4
.github/workflows/static-analysis.yml
vendored
4
.github/workflows/static-analysis.yml
vendored
@@ -27,14 +27,14 @@ jobs:
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup PHP
|
||||
uses: sunxyw/workflows/setup-environment@main
|
||||
with:
|
||||
php-version: 8.0
|
||||
php-version: 8.3
|
||||
php-extensions: swoole, posix, json
|
||||
operating-system: ubuntu-latest
|
||||
use-cache: true
|
||||
|
||||
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@@ -33,13 +33,13 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
operating-system: [ ubuntu-latest, windows-latest, macos-latest ]
|
||||
php-version: [ 8.0, 8.1, 8.2 ]
|
||||
php-version: [ 8.1, 8.2, 8.3, 8.4 ]
|
||||
name: PHP ${{ matrix.php-version }} Test (${{ matrix.operating-system }})
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
||||
2
.github/workflows/vuepress-deploy.yml
vendored
2
.github/workflows/vuepress-deploy.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout master
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Deploy docs to GitHub Pages
|
||||
uses: jenkey2011/vuepress-deploy@master
|
||||
|
||||
@@ -68,6 +68,8 @@ return (new PhpCsFixer\Config())
|
||||
'php_unit_test_class_requires_covers' => false,
|
||||
'fully_qualified_strict_types' => false,
|
||||
'new_with_parentheses' => false,
|
||||
'operator_linebreak' => false,
|
||||
'php_unit_data_provider_method_order' => false,
|
||||
])
|
||||
->setFinder(
|
||||
PhpCsFixer\Finder::create()
|
||||
|
||||
@@ -125,7 +125,7 @@ bash <(curl -fsSL https://zhamao.xin/v3.sh)
|
||||
|
||||
框架和 SDK 是 炸毛机器人 项目的核心框架开源部分。炸毛机器人是作者写的一个高性能机器人,曾获全国计算机设计大赛一等奖。
|
||||
|
||||
作者的炸毛机器人已从2018年初起稳定运行了**五年**,并且持续迭代。
|
||||
作者的炸毛机器人已从2018年初起稳定运行了**七年**,并且持续迭代。
|
||||
|
||||
可以提交 [Issue](https://github.com/zhamao-robot/zhamao-framework/issues/new/choose) 或 [加群(670821194)](https://jq.qq.com/?_wv=1027&k=YkNI3AIr) 进行疑难解答。
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^8.0 || ^8.1 || ^8.2",
|
||||
"php": "^8.0 || ^8.1 || ^8.2 || ^8.3 || ^8.4 || ^8.5",
|
||||
"ext-json": "*",
|
||||
"ext-tokenizer": "*",
|
||||
"doctrine/dbal": "^2.13.1",
|
||||
@@ -35,18 +35,18 @@
|
||||
"require-dev": {
|
||||
"captainhook/captainhook": "^5.10",
|
||||
"captainhook/plugin-composer": "^5.3",
|
||||
"friendsofphp/php-cs-fixer": "^3.2 != 3.7.0",
|
||||
"friendsofphp/php-cs-fixer": "^3.64",
|
||||
"jangregor/phpstan-prophecy": "^1.0",
|
||||
"jetbrains/phpstorm-attributes": "^1.0",
|
||||
"mikey179/vfsstream": "^1.6",
|
||||
"phpspec/prophecy-phpunit": "^2.0",
|
||||
"phpspec/prophecy-phpunit": "^2.3",
|
||||
"phpstan/extension-installer": "^1.1",
|
||||
"phpstan/phpstan": "^1.1",
|
||||
"phpstan/phpstan": "^1.12",
|
||||
"phpstan/phpstan-deprecation-rules": "^1.0",
|
||||
"phpstan/phpstan-phpunit": "^1.1",
|
||||
"phpunit/phpunit": "^8.5 || ^9.0",
|
||||
"phpunit/phpunit": "^9.0",
|
||||
"roave/security-advisories": "dev-latest",
|
||||
"swoole/ide-helper": "^4.5"
|
||||
"swoole/ide-helper": "^5.0"
|
||||
},
|
||||
"replace": {
|
||||
"symfony/polyfill-php80": "*"
|
||||
@@ -99,7 +99,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"analyse": "phpstan analyse --memory-limit 300M",
|
||||
"cs-fix": "PHP_CS_FIXER_FUTURE_MODE=1 php-cs-fixer fix",
|
||||
"cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix",
|
||||
"test": "bin/phpunit-zm --no-coverage"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ Public 成员函数</h2></td></tr>
|
||||
</table><table class="memberdecls">
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-attribs" name="pub-attribs"></a>
|
||||
成员变量</h2></td></tr>
|
||||
<tr class="memitem:a835ac83b0f0a2c196532f370dc585aa0"><td class="memItemLeft" align="right" valign="top">const </td><td class="memItemRight" valign="bottom"><a class="el" href="class_z_m_1_1_framework.html#a835ac83b0f0a2c196532f370dc585aa0">VERSION_ID</a> = 724</td></tr>
|
||||
<tr class="memitem:a835ac83b0f0a2c196532f370dc585aa0"><td class="memItemLeft" align="right" valign="top">const </td><td class="memItemRight" valign="bottom"><a class="el" href="class_z_m_1_1_framework.html#a835ac83b0f0a2c196532f370dc585aa0">VERSION_ID</a> = 725</td></tr>
|
||||
<tr class="separator:a835ac83b0f0a2c196532f370dc585aa0"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:af71005841ce53adac00581ab0ba24c1f"><td class="memItemLeft" align="right" valign="top">const </td><td class="memItemRight" valign="bottom"><a class="el" href="class_z_m_1_1_framework.html#af71005841ce53adac00581ab0ba24c1f">VERSION</a> = '3.2.4'</td></tr>
|
||||
<tr class="separator:af71005841ce53adac00581ab0ba24c1f"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
@@ -522,7 +522,7 @@ Protected 属性</h2></td></tr>
|
||||
<div class="memproto">
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname">const VERSION_ID = 724</td>
|
||||
<td class="memname">const VERSION_ID = 725</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
|
||||
@@ -2,6 +2,25 @@
|
||||
|
||||
> 本页面由框架命令 `./zhamao generate:text update-log-md` 自动生成
|
||||
|
||||
## v3.2.6
|
||||
|
||||
> 更新时间:2025-03-17
|
||||
|
||||
* Fix built-in php and composer install plugin error by [@crazywhalecc](https://github.com/crazywhalecc) in [PR#384](https://github.com/zhamao-robot/zhamao-framework/pull/384)
|
||||
* Update php84 by [@crazywhalecc](https://github.com/crazywhalecc) in [PR#383](https://github.com/zhamao-robot/zhamao-framework/pull/383)
|
||||
|
||||
**源码变更记录**: <https://github.com/zhamao-robot/zhamao-framework/compare/3.2.5...3.2.6>
|
||||
|
||||
## v3.2.5
|
||||
|
||||
> 更新时间:2024-10-02
|
||||
|
||||
* Fix install env issues by [@DreamMiu](https://github.com/DreamMiu) in [PR#374](https://github.com/zhamao-robot/zhamao-framework/pull/374)
|
||||
* 修复 v3.sh 在无 PHP 环境下无法安装的问题 by [@crazywhalecc](https://github.com/crazywhalecc) in [PR#377](https://github.com/zhamao-robot/zhamao-framework/pull/377)
|
||||
* Fix plugin:make command, remove uppercase name by [@crazywhalecc](https://github.com/crazywhalecc) in [PR#378](https://github.com/zhamao-robot/zhamao-framework/pull/378)
|
||||
|
||||
**源码变更记录**: <https://github.com/zhamao-robot/zhamao-framework/compare/3.2.4...3.2.5>
|
||||
|
||||
## v3.2.4
|
||||
|
||||
> 更新时间:2023-06-13
|
||||
@@ -247,18 +266,3 @@
|
||||
|
||||
**源码变更记录**: <https://github.com/zhamao-robot/zhamao-framework/compare/3.0.0-beta6...3.0.0-beta7>
|
||||
|
||||
## v3.0.0-beta6
|
||||
|
||||
> 更新时间:2023-01-15
|
||||
|
||||
* 本次更新包含文档更新内容 5 个
|
||||
* 更新版权所有年份 by [@crazywhalecc](https://github.com/crazywhalecc) in [PR#244](https://github.com/zhamao-robot/zhamao-framework/pull/244)
|
||||
* 修复 Doxygen 缺少权限.. by [@sunxyw](https://github.com/sunxyw) in [PR#245](https://github.com/zhamao-robot/zhamao-framework/pull/245)
|
||||
* 新增 prompt 方法的选项参数 by [@crazywhalecc](https://github.com/crazywhalecc) in [PR#248](https://github.com/zhamao-robot/zhamao-framework/pull/248)
|
||||
* 优化 ZMRequest POST 数据时允许直接传入数组 by [@crazywhalecc](https://github.com/crazywhalecc) in [PR#249](https://github.com/zhamao-robot/zhamao-framework/pull/249)
|
||||
* 删除 Context by [@crazywhalecc](https://github.com/crazywhalecc) in [PR#250](https://github.com/zhamao-robot/zhamao-framework/pull/250)
|
||||
* 添加环境变量支持 by [@sunxyw](https://github.com/sunxyw) in [PR#255](https://github.com/zhamao-robot/zhamao-framework/pull/255)
|
||||
* 重构插件加载器、BotContext、AnnotationMap 新增方法、修复部分 Bug by [@crazywhalecc](https://github.com/crazywhalecc) in [PR#254](https://github.com/zhamao-robot/zhamao-framework/pull/254)
|
||||
|
||||
**源码变更记录**: <https://github.com/zhamao-robot/zhamao-framework/compare/3.0.0-beta5...3.0.0-beta6>
|
||||
|
||||
|
||||
@@ -301,7 +301,7 @@ function redis(string $name = 'default'): RedisWrapper
|
||||
* @param null|mixed $default 默认值
|
||||
* @return mixed|void|ZMConfig
|
||||
*/
|
||||
function config(null|array|string $key = null, mixed $default = null)
|
||||
function config(array|string|null $key = null, mixed $default = null)
|
||||
{
|
||||
$config = ZMConfig::getInstance();
|
||||
if (is_null($key)) {
|
||||
|
||||
@@ -20,8 +20,7 @@ use ZM\Annotation\Interfaces\ErgodicAnnotation;
|
||||
class Middleware extends AnnotationBase implements ErgodicAnnotation
|
||||
{
|
||||
/**
|
||||
* @param string[] $args
|
||||
* @param mixed $name
|
||||
* @param mixed $name
|
||||
*/
|
||||
public function __construct(
|
||||
/**
|
||||
|
||||
@@ -41,7 +41,7 @@ class CommandArgument extends AnnotationBase implements ErgodicAnnotation
|
||||
string $type = 'string',
|
||||
public bool $required = false,
|
||||
public string $prompt = '',
|
||||
public null|array|\Closure|float|int|string $default = '',
|
||||
public array|\Closure|float|int|string|null $default = '',
|
||||
public int $timeout = 60,
|
||||
public int $error_prompt_policy = 1
|
||||
) {
|
||||
|
||||
@@ -20,7 +20,6 @@ class HandleExceptions implements Bootstrapper
|
||||
E_USER_ERROR => ['PHP Error: ', 'error'],
|
||||
E_USER_WARNING => ['PHP Warning: ', 'warning'],
|
||||
E_USER_NOTICE => ['PHP Notice: ', 'notice'],
|
||||
E_STRICT => ['PHP Strict: ', 'notice'],
|
||||
E_RECOVERABLE_ERROR => ['PHP Recoverable Error: ', 'error'],
|
||||
E_DEPRECATED => ['PHP Deprecated: ', 'notice'],
|
||||
E_USER_DEPRECATED => ['PHP User Deprecated: ', 'notice'],
|
||||
@@ -30,7 +29,7 @@ class HandleExceptions implements Bootstrapper
|
||||
logger()->{$level_tip[1]}($error);
|
||||
// 如果 return false 则错误会继续递交给 PHP 标准错误处理
|
||||
return true;
|
||||
}, E_ALL | E_STRICT);
|
||||
});
|
||||
|
||||
// 重载异常处理器
|
||||
ExceptionHandler::getInstance()->overrideWith(new Handler());
|
||||
|
||||
@@ -25,7 +25,7 @@ trait CommandInteractTrait
|
||||
* @param string $message
|
||||
* @param mixed[] $context
|
||||
*/
|
||||
public function emergency($message, array $context = [])
|
||||
public function emergency($message, array $context = []): void
|
||||
{
|
||||
$this->log(LogLevel::EMERGENCY, $message, $context);
|
||||
}
|
||||
@@ -39,7 +39,7 @@ trait CommandInteractTrait
|
||||
* @param string $message
|
||||
* @param mixed[] $context
|
||||
*/
|
||||
public function alert($message, array $context = [])
|
||||
public function alert($message, array $context = []): void
|
||||
{
|
||||
$this->log(LogLevel::ALERT, $message, $context);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ trait CommandInteractTrait
|
||||
* @param string $message
|
||||
* @param mixed[] $context
|
||||
*/
|
||||
public function critical($message, array $context = [])
|
||||
public function critical($message, array $context = []): void
|
||||
{
|
||||
$this->log(LogLevel::CRITICAL, $message, $context);
|
||||
}
|
||||
@@ -64,7 +64,7 @@ trait CommandInteractTrait
|
||||
* @param string $message
|
||||
* @param mixed[] $context
|
||||
*/
|
||||
public function error($message, array $context = [])
|
||||
public function error($message, array $context = []): void
|
||||
{
|
||||
$this->log(LogLevel::ERROR, $message, $context);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ trait CommandInteractTrait
|
||||
* @param string $message
|
||||
* @param mixed[] $context
|
||||
*/
|
||||
public function warning($message, array $context = [])
|
||||
public function warning($message, array $context = []): void
|
||||
{
|
||||
$this->log(LogLevel::WARNING, $message, $context);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ trait CommandInteractTrait
|
||||
* @param string $message
|
||||
* @param mixed[] $context
|
||||
*/
|
||||
public function notice($message, array $context = [])
|
||||
public function notice($message, array $context = []): void
|
||||
{
|
||||
$this->log(LogLevel::NOTICE, $message, $context);
|
||||
}
|
||||
@@ -101,7 +101,7 @@ trait CommandInteractTrait
|
||||
*
|
||||
* @param string $message
|
||||
*/
|
||||
public function info($message, array $context = [])
|
||||
public function info($message, array $context = []): void
|
||||
{
|
||||
$this->log(LogLevel::INFO, $message, $context);
|
||||
}
|
||||
@@ -111,12 +111,12 @@ trait CommandInteractTrait
|
||||
*
|
||||
* @param string $message
|
||||
*/
|
||||
public function debug($message, array $context = [])
|
||||
public function debug($message, array $context = []): void
|
||||
{
|
||||
$this->log(LogLevel::DEBUG, $message, $context);
|
||||
}
|
||||
|
||||
public function log($level, $message, array $context = [])
|
||||
public function log($level, $message, array $context = []): void
|
||||
{
|
||||
$msg = match ($level) {
|
||||
'info' => "<info>{$message}</info>",
|
||||
|
||||
@@ -262,7 +262,6 @@ class ProxyServerCommand extends Command
|
||||
break;
|
||||
case CMD_UDP_ASSOCIATE:
|
||||
$connection->stage = STAGE_UDP_ASSOC;
|
||||
var_dump('CMD_UDP_ASSOCIATE ' . ($this->config['udp_port'] ?? 2222));
|
||||
if ($this->config['udp_port'] == 0) {
|
||||
$connection->udpWorker = new Worker('udp://0.0.0.0:0');
|
||||
/* @phpstan-ignore-next-line */
|
||||
@@ -274,7 +273,7 @@ class ProxyServerCommand extends Command
|
||||
$listenInfo = stream_socket_get_name($connection->udpWorker->getMainSocket(), false);
|
||||
[$bind_addr, $bind_port] = explode(':', $listenInfo);
|
||||
} else {
|
||||
$bind_port = $this->config['udp_port'] ?? 2222;
|
||||
$bind_port = $this->config['udp_port'];
|
||||
}
|
||||
$bind_addr = $this->config['wanIP'] ?? '192.168.1.1';
|
||||
|
||||
|
||||
@@ -32,7 +32,11 @@ final class ConsoleApplication extends Application
|
||||
// 初始化 Composer 变量
|
||||
if (file_exists(WORKING_DIR . '/runtime/composer.phar')) {
|
||||
echo '* Using native composer' . PHP_EOL;
|
||||
putenv('COMPOSER_EXECUTABLE=' . WORKING_DIR . '/runtime/composer.phar');
|
||||
if (WORKING_DIR . '/runtime/php' === PHP_BINARY) {
|
||||
putenv('COMPOSER_EXECUTABLE="' . WORKING_DIR . '/runtime/php ' . WORKING_DIR . '/runtime/composer.phar"');
|
||||
} else {
|
||||
putenv('COMPOSER_EXECUTABLE="' . WORKING_DIR . '/runtime/composer.phar"');
|
||||
}
|
||||
}
|
||||
|
||||
$this->registerCommandLoader();
|
||||
|
||||
@@ -87,7 +87,7 @@ class BotContext implements ContextInterface
|
||||
* @noinspection PhpDocMissingThrowsInspection
|
||||
* @noinspection PhpUnhandledExceptionInspection
|
||||
*/
|
||||
public function prompt(array|MessageSegment|string|\Stringable $prompt = '', int $timeout = 600, array|MessageSegment|string|\Stringable $timeout_prompt = '', int $option = ZM_PROMPT_NONE): null|array|OneBotEvent|string
|
||||
public function prompt(array|MessageSegment|string|\Stringable $prompt = '', int $timeout = 600, array|MessageSegment|string|\Stringable $timeout_prompt = '', int $option = ZM_PROMPT_NONE): array|OneBotEvent|string|null
|
||||
{
|
||||
if (!container()->has('bot.event')) {
|
||||
throw new OneBot12Exception('bot()->prompt() can only be used in message event');
|
||||
@@ -268,7 +268,7 @@ class BotContext implements ContextInterface
|
||||
* @return null|array|OneBotEvent|string 根据不同匹配类型返回不同的东西
|
||||
* @throws OneBot12Exception
|
||||
*/
|
||||
private function applyPromptReturn(mixed $result, int $option): null|array|OneBotEvent|string
|
||||
private function applyPromptReturn(mixed $result, int $option): array|OneBotEvent|string|null
|
||||
{
|
||||
// 必须是 OneBotEvent 且是消息类型
|
||||
if (!$result instanceof OneBotEvent || $result->type !== 'message') {
|
||||
|
||||
@@ -30,10 +30,13 @@ class SignalListener
|
||||
switch (Framework::getInstance()->getDriver()->getName()) {
|
||||
case 'swoole':
|
||||
Process::signal(SIGINT, [$this, 'onWorkerInt']);
|
||||
Process::signal(SIGTERM, [$this, 'onWorkerInt']);
|
||||
Process::signal(SIGHUP, [$this, 'onWorkerInt']);
|
||||
break;
|
||||
case 'workerman':
|
||||
Worker::$globalEvent->add(SIGINT, EventInterface::EV_SIGNAL, [$this, 'onWorkerInt']);
|
||||
Worker::$globalEvent->add(SIGTERM, EventInterface::EV_SIGNAL, fn () => Worker::stopAll(15));
|
||||
Worker::$globalEvent->add(SIGHUP, EventInterface::EV_SIGNAL, fn () => Worker::stopAll(15));
|
||||
if (function_exists('pcntl_signal')) {
|
||||
pcntl_signal(SIGUSR1, SIG_IGN, false);
|
||||
}
|
||||
@@ -51,10 +54,9 @@ class SignalListener
|
||||
{
|
||||
$driver = Framework::getInstance()->getDriver()->getName();
|
||||
if ($driver === 'swoole') {
|
||||
Process::signal(SIGINT, function () {
|
||||
$stopHandler = function () {
|
||||
echo "\r";
|
||||
logger()->notice('Master 进程收到中断信号 SIGINT');
|
||||
logger()->notice('正在停止服务器');
|
||||
logger()->notice('Master 进程收到中断信号,正在停止服务器');
|
||||
Framework::getInstance()->stop();
|
||||
if (extension_loaded('posix')) {
|
||||
Process::kill(posix_getpid(), SIGTERM);
|
||||
@@ -62,10 +64,13 @@ class SignalListener
|
||||
/* @phpstan-ignore-next-line */
|
||||
Process::kill(Framework::getInstance()->getDriver()->getSwooleServer()->master_pid, SIGTERM);
|
||||
}
|
||||
});
|
||||
};
|
||||
Process::signal(SIGINT, $stopHandler);
|
||||
Process::signal(SIGTERM, $stopHandler);
|
||||
Process::signal(SIGHUP, $stopHandler);
|
||||
} elseif ($driver === 'workerman') {
|
||||
if (!extension_loaded('pcntl') || !extension_loaded('posix')) {
|
||||
logger()->error('请安装 pcntl 和 posix 扩展以支持 SIGINT 监听');
|
||||
logger()->error('请安装 pcntl 和 posix 扩展以支持信号监听');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -73,15 +78,14 @@ class SignalListener
|
||||
logger()->warning('重启ing');
|
||||
Worker::reloadSelf();
|
||||
}, false);
|
||||
pcntl_signal(SIGTERM, function () {
|
||||
Worker::stopAll();
|
||||
}, false);
|
||||
pcntl_signal(SIGINT, function () {
|
||||
$stopMaster = function () {
|
||||
echo "\r";
|
||||
logger()->notice('Master 进程收到中断信号 SIGINT');
|
||||
logger()->notice('正在停止服务器');
|
||||
logger()->notice('Master 进程收到中断信号,正在停止服务器');
|
||||
Worker::stopAll();
|
||||
}, false);
|
||||
};
|
||||
pcntl_signal(SIGTERM, $stopMaster, false);
|
||||
pcntl_signal(SIGINT, $stopMaster, false);
|
||||
pcntl_signal(SIGHUP, $stopMaster, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,10 +47,10 @@ class Framework
|
||||
use Singleton;
|
||||
|
||||
/** @var int 版本ID */
|
||||
public const VERSION_ID = 725;
|
||||
public const VERSION_ID = 726;
|
||||
|
||||
/** @var string 版本名称 */
|
||||
public const VERSION = '3.2.4';
|
||||
public const VERSION = '3.2.7';
|
||||
|
||||
/**
|
||||
* @var RuntimePreferences 运行时偏好(环境信息&参数)
|
||||
@@ -61,7 +61,7 @@ class Framework
|
||||
protected array $argv;
|
||||
|
||||
/** @var null|Driver|SwooleDriver|WorkermanDriver OneBot驱动 */
|
||||
protected null|Driver|SwooleDriver|WorkermanDriver $driver = null;
|
||||
protected Driver|SwooleDriver|WorkermanDriver|null $driver = null;
|
||||
|
||||
/** @var array<array<string, string>> 启动注解列表 */
|
||||
protected array $setup_annotations = [];
|
||||
|
||||
@@ -31,7 +31,7 @@ class ProcessStateManager
|
||||
* @throws ZMKnownException
|
||||
* @internal
|
||||
*/
|
||||
public static function removeProcessState(int $type, null|int|string $id_or_name = null): void
|
||||
public static function removeProcessState(int $type, int|string|null $id_or_name = null): void
|
||||
{
|
||||
switch ($type) {
|
||||
case ZM_PROCESS_MASTER:
|
||||
|
||||
@@ -104,7 +104,7 @@ class LightCache implements KVInterface
|
||||
/**
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function set(string $key, mixed $value, null|\DateInterval|int $ttl = null): bool
|
||||
public function set(string $key, mixed $value, \DateInterval|int|null $ttl = null): bool
|
||||
{
|
||||
$this->validateKey($key);
|
||||
self::$caches[$this->name][$key] = $value;
|
||||
@@ -139,7 +139,7 @@ class LightCache implements KVInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function setMultiple(iterable $values, null|\DateInterval|int $ttl = null): bool
|
||||
public function setMultiple(iterable $values, \DateInterval|int|null $ttl = null): bool
|
||||
{
|
||||
foreach ($values as $k => $v) {
|
||||
if (!$this->set($k, $v, $ttl)) {
|
||||
|
||||
@@ -35,7 +35,7 @@ class KVRedis implements KVInterface
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function set(string $key, mixed $value, null|\DateInterval|int $ttl = null): bool
|
||||
public function set(string $key, mixed $value, \DateInterval|int|null $ttl = null): bool
|
||||
{
|
||||
/** @var ZMRedis $redis */
|
||||
$redis = RedisPool::pool($this->pool_name)->get();
|
||||
@@ -78,7 +78,7 @@ class KVRedis implements KVInterface
|
||||
RedisPool::pool($this->pool_name)->put($redis);
|
||||
}
|
||||
|
||||
public function setMultiple(iterable $values, null|\DateInterval|int $ttl = null): bool
|
||||
public function setMultiple(iterable $values, \DateInterval|int|null $ttl = null): bool
|
||||
{
|
||||
/** @var ZMRedis $redis */
|
||||
$redis = RedisPool::pool($this->pool_name)->get();
|
||||
|
||||
@@ -99,7 +99,7 @@ class MessageUtil
|
||||
return $ls;
|
||||
}
|
||||
|
||||
public static function getAltMessage(null|array|MessageSegment|string $message): string
|
||||
public static function getAltMessage(array|MessageSegment|string|null $message): string
|
||||
{
|
||||
if ($message === null) {
|
||||
return '';
|
||||
|
||||
@@ -49,6 +49,9 @@ class EventProviderTest extends TestCase
|
||||
|
||||
public function testAddEventListenerWithCallableArray(): void
|
||||
{
|
||||
if (PHP_VERSION_ID >= 80400) {
|
||||
$this->markTestSkipped('PHP 8.4.0 has a bug that cannot pass this test');
|
||||
}
|
||||
// no meaning for using ZMUtil, just for testing
|
||||
$event = new ZMUtil();
|
||||
$callback = [$this, 'testAddEventListenerWithCallableArray'];
|
||||
|
||||
Reference in New Issue
Block a user