add cs fixer and PHPStan and activate it (build 436)

This commit is contained in:
crazywhalecc
2022-03-15 18:05:33 +08:00
parent d01bd69aa5
commit 1706afbcd0
163 changed files with 4572 additions and 3588 deletions

View File

@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
use Doctrine\Common\Annotations\AnnotationReader;
use ZM\Annotation\Swoole\OnSetup;
use ZM\Annotation\Swoole\SwooleHandler;
@@ -8,25 +10,24 @@ use ZM\Exception\InitException;
use ZM\Utils\DataProvider;
use ZM\Utils\ZMUtil;
require_once ((!is_dir(__DIR__ . '/../../vendor')) ? getcwd() : (__DIR__ . "/../..")) . "/vendor/autoload.php";
require_once((!is_dir(__DIR__ . '/../../vendor')) ? getcwd() : (__DIR__ . '/../..')) . '/vendor/autoload.php';
try {
try {
(new ConsoleApplication('zhamao'))->initEnv();
} catch (InitException $e) {
}
$base_path = DataProvider::getSourceRootDir();
$scan_paths = [];
$composer = json_decode(file_get_contents($base_path . "/composer.json"), true);
foreach (($composer["autoload"]["psr-4"] ?? []) as $k => $v) {
if (is_dir($base_path . "/" . $v) && !in_array($v, $composer["extra"]["exclude_annotate"] ?? [])) {
$scan_paths[trim($k, "\\")] = $base_path . "/" . $v;
$composer = json_decode(file_get_contents($base_path . '/composer.json'), true);
foreach (($composer['autoload']['psr-4'] ?? []) as $k => $v) {
if (is_dir($base_path . '/' . $v) && !in_array($v, $composer['extra']['exclude_annotate'] ?? [])) {
$scan_paths[trim($k, '\\')] = $base_path . '/' . $v;
}
}
foreach (($composer["autoload-dev"]["psr-4"] ?? []) as $k => $v) {
if (is_dir($base_path . "/" . $v) && !in_array($v, $composer["extra"]["exclude_annotate"] ?? [])) {
$scan_paths[trim($k, "\\")] = $base_path . "/" . $v;
foreach (($composer['autoload-dev']['psr-4'] ?? []) as $k => $v) {
if (is_dir($base_path . '/' . $v) && !in_array($v, $composer['extra']['exclude_annotate'] ?? [])) {
$scan_paths[trim($k, '\\')] = $base_path . '/' . $v;
}
}
$all_event_class = [];
@@ -46,23 +47,23 @@ try {
$annotation = $method_annotations[0];
if ($annotation instanceof SwooleHandler) {
$event_list[] = [
"class" => $v,
"method" => $vs->getName(),
"event" => $annotation->event
'class' => $v,
'method' => $vs->getName(),
'event' => $annotation->event,
];
} elseif ($annotation instanceof OnSetup) {
$setup_list[] = [
"class" => $v,
"method" => $vs->getName()
'class' => $v,
'method' => $vs->getName(),
];
}
}
}
}
echo json_encode(["setup" => $setup_list, "event" => $event_list]);
echo json_encode(['setup' => $setup_list, 'event' => $event_list]);
} catch (Throwable $e) {
$stderr = fopen("php://stderr", "w");
fwrite($stderr, zm_internal_errcode("E00031") . $e->getMessage() . " in " . $e->getFile() . " at line " . $e->getLine() . PHP_EOL);
$stderr = fopen('php://stderr', 'w');
fwrite($stderr, zm_internal_errcode('E00031') . $e->getMessage() . ' in ' . $e->getFile() . ' at line ' . $e->getLine() . PHP_EOL);
fclose($stderr);
exit(1);
}
@@ -79,4 +80,4 @@ try {
在最开始单独启动进程,加载一遍所有类,获取需要在启动前就执行的类,然后在启动的时候执行。
这样就可以不在爷进程里面加载所有类,在爹进程里面 Fork 的子进程再加载所有类,每次 reload 时可以重新加载了。
以上均为乱写的,请勿完全当真,本人对待框架代码还是比较认真的。
*/
*/