strict to phpstan-level-4

This commit is contained in:
crazywhalecc
2022-04-03 01:47:38 +08:00
parent 0bab2e74b0
commit 3451434997
19 changed files with 67 additions and 59 deletions

View File

@@ -145,10 +145,11 @@ class EventDispatcher
/**
* @param mixed $v
* @param null $rule_func
* @param null|mixed $rule_func
* @param mixed ...$params
* @throws InterruptException
* @throws AnnotationException
* @throws Error
* @return bool
* @noinspection PhpMissingReturnTypeInspection
*/

View File

@@ -1,7 +1,6 @@
<?php
/**
* @noinspection PhpPropertyOnlyWrittenInspection
* @noinspection PhpUnusedParameterInspection
* @noinspection PhpComposerExtensionStubsInspection
*/
@@ -34,7 +33,12 @@ class OnManagerStart implements SwooleEvent
{
private static $last_hash = '';
private static $watch = -1;
private static $watch_tick_id = -1;
public static function getWatchTickId(): int
{
return self::$watch_tick_id;
}
public function onCall(Server $server)
{
@@ -65,7 +69,7 @@ class OnManagerStart implements SwooleEvent
}
}
if (Framework::$argv['polling-watch']) {
self::$watch = swoole_timer_tick(3000, function () use ($server) {
self::$watch_tick_id = swoole_timer_tick(3000, function () use ($server) {
$data = (DataProvider::scanDirFiles(DataProvider::getSourceRootDir() . '/src/'));
$hash = md5('');
foreach ($data as $file) {

View File

@@ -4,10 +4,9 @@ declare(strict_types=1);
namespace ZM\Event\SwooleEvent;
use Error;
use Exception;
use Swoole\Coroutine;
use Swoole\WebSocket\Frame;
use Throwable;
use ZM\Annotation\Swoole\OnMessageEvent;
use ZM\Annotation\Swoole\OnSwooleEvent;
use ZM\Annotation\Swoole\SwooleHandler;
@@ -53,11 +52,7 @@ class OnMessage implements SwooleEvent
$dispatcher1->dispatchEvents($conn);
$dispatcher->dispatchEvents($conn);
// Console::success("Used ".round((microtime(true) - $starttime) * 1000, 3)." ms!");
} catch (Exception $e) {
$error_msg = $e->getMessage() . ' at ' . $e->getFile() . '(' . $e->getLine() . ')';
Console::error(zm_internal_errcode('E00017') . 'Uncaught exception ' . get_class($e) . ' when calling "message": ' . $error_msg);
Console::trace();
} catch (Error $e) {
} catch (Throwable $e) {
$error_msg = $e->getMessage() . ' at ' . $e->getFile() . '(' . $e->getLine() . ')';
Console::error(zm_internal_errcode('E00017') . 'Uncaught ' . get_class($e) . ' when calling "message": ' . $error_msg);
Console::trace();

View File

@@ -6,9 +6,8 @@ declare(strict_types=1);
namespace ZM\Event\SwooleEvent;
use Error;
use Exception;
use Swoole\Server;
use Throwable;
use ZM\Annotation\Swoole\SwooleHandler;
use ZM\Console\Console;
use ZM\Event\SwooleEvent;
@@ -25,11 +24,7 @@ class OnPipeMessage implements SwooleEvent
$data = json_decode($data, true);
try {
WorkerManager::workerAction($src_worker_id, $data);
} catch (Exception $e) {
$error_msg = $e->getMessage() . ' at ' . $e->getFile() . '(' . $e->getLine() . ')';
Console::error(zm_internal_errcode('E00021') . 'Uncaught exception ' . get_class($e) . ' when calling "pipeMessage": ' . $error_msg);
Console::trace();
} catch (Error $e) {
} catch (Throwable $e) {
$error_msg = $e->getMessage() . ' at ' . $e->getFile() . '(' . $e->getLine() . ')';
Console::error(zm_internal_errcode('E00021') . 'Uncaught ' . get_class($e) . ' when calling "pipeMessage": ' . $error_msg);
Console::trace();

View File

@@ -13,7 +13,7 @@ use ReflectionException;
use Swoole\Coroutine;
use Swoole\Database\PDOConfig;
use Swoole\Process;
use Swoole\Server;
use Swoole\WebSocket\Server;
use ZM\Annotation\AnnotationParser;
use ZM\Annotation\Swoole\OnMessageEvent;
use ZM\Annotation\Swoole\OnStart;
@@ -68,12 +68,7 @@ class OnWorkerStart implements SwooleEvent
return;
}
// DataProvider::saveBuffer();
/* @var Server $server */
if (server() === null) {
$server->shutdown();
} else {
server()->shutdown();
}
$server->shutdown();
});
Console::verbose("Worker #{$server->worker_id} starting");