Skip to content

Commit db36e24

Browse files
authored
Update all things to PHP 8.4 (#112)
* Update all things to PHP 8.4 * Abandon develop
1 parent 3785a0d commit db36e24

30 files changed

+65
-81
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ updates:
44
directory: "/"
55
schedule:
66
interval: "daily"
7-
target-branch: "develop"
7+
target-branch: "master"
88
labels:
99
- "area/dependency"

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Test
33
on:
44
push:
55
branches:
6+
- master
67
- main
78
- develop
89
- '*-dev*'

choir-test.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
/** @noinspection PhpComposerExtensionStubsInspection */
44

55
declare(strict_types=1);
6+
use Choir\Http\Server;
7+
use Choir\Protocol\HttpConnection;
68

79
require_once 'vendor/autoload.php';
810

9-
$server = new \Choir\Http\Server('0.0.0.0', 20001, false, [
11+
$server = new Server('0.0.0.0', 20001, false, [
1012
'worker-num' => 8,
1113
// 'logger-level' => 'debug',
1214
]);
@@ -22,7 +24,7 @@
2224
// echo "http://127.0.0.1:8080/index.php?run={$id}&source=xhprof_testing\n";
2325
});
2426

25-
$server->on('request', function (Choir\Protocol\HttpConnection $connection) {
27+
$server->on('request', function (HttpConnection $connection) {
2628
$connection->end('hello world');
2729
});
2830

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"wiki": "https://github.com/botuniverse/php-libonebot/wiki"
2626
},
2727
"require": {
28-
"php": "^7.4 || ^8.0 || ^8.1 || ^8.2",
28+
"php": "^7.4 || ^8.0 || ^8.1 || ^8.2 || ^8.3 || ^8.4",
2929
"ext-json": "*",
3030
"psr/cache": "^1.0 || ^3.0",
3131
"psr/event-dispatcher": "^1.0",
@@ -85,7 +85,7 @@
8585
"[ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/cghooks add"
8686
],
8787
"analyse": "phpstan analyse --memory-limit 300M",
88-
"cs-fix": "php-cs-fixer fix",
88+
"cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix",
8989
"test": "phpunit --no-coverage"
9090
}
9191
}

demo/repl.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
declare(strict_types=1);
44

55
use OneBot\Driver\Event\DriverInitEvent;
6+
use OneBot\Driver\Swoole\SwooleDriver;
67
use OneBot\Util\Utils;
8+
use OneBot\V12\EventBuilder;
79
use OneBot\V12\Object\Action;
810
use OneBot\V12\Object\ActionResponse;
911
use OneBot\V12\OneBot;
1012
use OneBot\V12\OneBotBuilder;
1113
use OneBot\V12\Validator;
14+
use ZM\Logger\ConsoleLogger;
1215

1316
require_once __DIR__ . '/../vendor/autoload.php';
1417

@@ -23,11 +26,11 @@ function message_id(): string
2326
'self_id' => 'REPL-1',
2427
'db' => true,
2528
'logger' => [
26-
'class' => \ZM\Logger\ConsoleLogger::class,
29+
'class' => ConsoleLogger::class,
2730
'level' => 'info',
2831
],
2932
'driver' => [
30-
'class' => \OneBot\Driver\Swoole\SwooleDriver::class,
33+
'class' => SwooleDriver::class,
3134
'config' => [
3235
'init_in_user_process_block' => true,
3336
],
@@ -81,7 +84,7 @@ function message_id(): string
8184
$event->getDriver()->getEventLoop()->delReadEvent($x);
8285
return;
8386
}
84-
$event = (new \OneBot\V12\EventBuilder('message', 'private'))
87+
$event = (new EventBuilder('message', 'private'))
8588
->feed('message', trim($s))
8689
->feed('alt_message', trim($s))
8790
->feed('message_id', message_id())

demo/weixin.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use OneBot\V12\RetCode;
1616
use OneBot\V12\Validator;
1717
use Swoole\Coroutine\Channel;
18+
use ZM\Logger\ConsoleLogger;
1819

1920
require_once __DIR__ . '/../vendor/autoload.php';
2021

@@ -24,7 +25,7 @@
2425
'self_id' => '', // 后续会自动获取
2526
'db' => true,
2627
'logger' => [
27-
'class' => \ZM\Logger\ConsoleLogger::class,
28+
'class' => ConsoleLogger::class,
2829
'level' => 'info',
2930
],
3031
'driver' => [
@@ -118,7 +119,7 @@ function wx_make_xml_reply(Action $action, string $self_id): string
118119
return str_replace('{content}', '<![CDATA[' . $content . ']]>', $xml_template);
119120
}
120121

121-
function swoole_channel(string $name, int $size = 1): Swoole\Coroutine\Channel
122+
function swoole_channel(string $name, int $size = 1): Channel
122123
{
123124
global $channel;
124125
if (!isset($channel[$name])) {

src/OneBot/Config/Loader/DelegateLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class DelegateLoader implements LoaderInterface
1414
/**
1515
* @param null|array{string: LoaderInterface} $loaders 加载器列表,null则使用默认列表
1616
*/
17-
public function __construct(array $loaders = null)
17+
public function __construct(?array $loaders = null)
1818
{
1919
foreach ((array) $loaders as $key => $loader) {
2020
if (!$loader instanceof LoaderInterface) {

src/OneBot/Config/Loader/LoadException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@
44

55
namespace OneBot\Config\Loader;
66

7-
class LoadException extends \RuntimeException
8-
{
9-
}
7+
class LoadException extends \RuntimeException {}

src/OneBot/Driver/Event/Event.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@
44

55
namespace OneBot\Driver\Event;
66

7-
interface Event
8-
{
9-
}
7+
interface Event {}

src/OneBot/Driver/Event/Process/ManagerStartEvent.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,4 @@
66

77
use OneBot\Driver\Event\DriverEvent;
88

9-
class ManagerStartEvent extends DriverEvent
10-
{
11-
}
9+
class ManagerStartEvent extends DriverEvent {}

0 commit comments

Comments
 (0)