Skip to content

Commit 032eab6

Browse files
committed
Update all things to PHP 8.4
1 parent 38c24c9 commit 032eab6

38 files changed

+75
-162
lines changed

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",
3131
"psr/event-dispatcher": "^1.0",
@@ -84,7 +84,7 @@
8484
"[ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/cghooks add"
8585
],
8686
"analyse": "phpstan analyse --memory-limit 300M",
87-
"cs-fix": "php-cs-fixer fix",
87+
"cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix",
8888
"test": "phpunit --no-coverage"
8989
}
9090
}

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/AbstractFileLoader.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
abstract class AbstractFileLoader implements LoaderInterface
1111
{
12-
/**
13-
* {@inheritDoc}
14-
*/
1512
public function load($source): array
1613
{
1714
// TODO: flexible base path

src/OneBot/Config/Loader/DelegateLoader.php

Lines changed: 1 addition & 4 deletions
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) {
@@ -25,9 +25,6 @@ public function __construct(array $loaders = null)
2525
$this->loaders = $loaders ?? self::getDefaultLoaders();
2626
}
2727

28-
/**
29-
* {@inheritDoc}
30-
*/
3128
public function load($source): array
3229
{
3330
return $this->determineLoader($source)->load($source);

src/OneBot/Config/Loader/JsonFileLoader.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
class JsonFileLoader extends AbstractFileLoader
88
{
9-
/**
10-
* {@inheritDoc}
11-
*/
129
protected function loadFile(string $file)
1310
{
1411
try {

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/Config/Repository.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ public function __construct(array $config = [])
2121
$this->config = $config;
2222
}
2323

24-
/**
25-
* {@inheritDoc}
26-
*/
2724
public function get(string $key, $default = null)
2825
{
2926
// 在表层直接查找,找到就直接返回
@@ -51,9 +48,6 @@ public function get(string $key, $default = null)
5148
return $data;
5249
}
5350

54-
/**
55-
* {@inheritDoc}
56-
*/
5751
public function set(string $key, $value): void
5852
{
5953
if ($value === null) {
@@ -75,17 +69,11 @@ public function set(string $key, $value): void
7569
$data = $value;
7670
}
7771

78-
/**
79-
* {@inheritDoc}
80-
*/
8172
public function has(string $key): bool
8273
{
8374
return $this->get($key) !== null;
8475
}
8576

86-
/**
87-
* {@inheritDoc}
88-
*/
8977
public function all(): array
9078
{
9179
return $this->config;

src/OneBot/Driver/Event/DriverEvent.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ public static function getName(): string
2424
return static::$custom_name ?? static::class;
2525
}
2626

27-
/**
28-
* {@inheritDoc}
29-
*/
3027
public function isPropagationStopped(): bool
3128
{
3229
return $this->propagation_stopped;

0 commit comments

Comments
 (0)