mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-21 15:45:36 +08:00
update to build 406 version
This commit is contained in:
@@ -12,7 +12,7 @@ abstract class AnnotationBase
|
||||
|
||||
public $class;
|
||||
|
||||
public function __toString(): string {
|
||||
public function __toString() {
|
||||
$str = __CLASS__ . ": ";
|
||||
foreach ($this as $k => $v) {
|
||||
$str .= "\n\t" . $k . " => ";
|
||||
|
||||
@@ -9,7 +9,12 @@ use ZM\Console\Console;
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
use ReflectionMethod;
|
||||
use ZM\Annotation\Http\{HandleAfter, HandleBefore, HandleException, Middleware, MiddlewareClass, RequestMapping};
|
||||
use ZM\Annotation\Http\HandleAfter;
|
||||
use ZM\Annotation\Http\HandleBefore;
|
||||
use ZM\Annotation\Http\HandleException;
|
||||
use ZM\Annotation\Http\Middleware;
|
||||
use ZM\Annotation\Http\MiddlewareClass;
|
||||
use ZM\Annotation\Http\RequestMapping;
|
||||
use ZM\Annotation\Interfaces\Level;
|
||||
use ZM\Annotation\Module\Closed;
|
||||
use ZM\Http\RouteManager;
|
||||
@@ -125,7 +130,7 @@ class AnnotationParser
|
||||
Console::debug("解析注解完毕!");
|
||||
}
|
||||
|
||||
public function generateAnnotationEvents(): array {
|
||||
public function generateAnnotationEvents() {
|
||||
$o = [];
|
||||
foreach ($this->annotation_map as $module => $obj) {
|
||||
foreach (($obj["class_annotations"] ?? []) as $class_annotation) {
|
||||
|
||||
@@ -26,7 +26,7 @@ class CQAfter extends AnnotationBase implements Level
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLevel(): int {
|
||||
public function getLevel() {
|
||||
return $this->level;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,6 @@ class CQCommand extends AnnotationBase implements Level
|
||||
/**
|
||||
* @param int $level
|
||||
*/
|
||||
public function setLevel(int $level) { $this->level = $level; }
|
||||
public function setLevel($level) { $this->level = $level; }
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class CQMessage extends AnnotationBase implements Level
|
||||
|
||||
public function getLevel(): int { return $this->level; }
|
||||
|
||||
public function setLevel(int $level) {
|
||||
public function setLevel($level) {
|
||||
$this->level = $level;
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class CQMetaEvent extends AnnotationBase implements Level
|
||||
/**
|
||||
* @param int $level
|
||||
*/
|
||||
public function setLevel(int $level) {
|
||||
public function setLevel($level) {
|
||||
$this->level = $level;
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ class CQNotice extends AnnotationBase implements Level
|
||||
/**
|
||||
* @param int $level
|
||||
*/
|
||||
public function setLevel(int $level) {
|
||||
public function setLevel($level) {
|
||||
$this->level = $level;
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ class CQRequest extends AnnotationBase implements Level
|
||||
/**
|
||||
* @param int $level
|
||||
*/
|
||||
public function setLevel(int $level) {
|
||||
public function setLevel($level) {
|
||||
$this->level = $level;
|
||||
}
|
||||
}
|
||||
@@ -8,5 +8,5 @@ interface Level
|
||||
{
|
||||
public function getLevel();
|
||||
|
||||
public function setLevel(int $level);
|
||||
public function setLevel($level);
|
||||
}
|
||||
@@ -43,7 +43,7 @@ abstract class OnSwooleEventBase extends AnnotationBase implements Level, Rule
|
||||
/**
|
||||
* @param int $level
|
||||
*/
|
||||
public function setLevel(int $level) {
|
||||
public function setLevel($level) {
|
||||
$this->level = $level;
|
||||
}
|
||||
}
|
||||
@@ -32,23 +32,23 @@ class BuildCommand extends Command
|
||||
if (mb_strpos($target_dir, "../")) $target_dir = realpath($target_dir);
|
||||
if ($target_dir === false) {
|
||||
$output->writeln(TermColor::color8(31) . "Error: No such file or directory (" . __DIR__ . '/../../../resources/' . ")" . TermColor::RESET);
|
||||
return Command::FAILURE;
|
||||
return 1;
|
||||
}
|
||||
$output->writeln("Target: " . $target_dir . " , Version: " . ($version = json_decode(file_get_contents(__DIR__ . "/../../../composer.json"), true)["version"]));
|
||||
if (mb_substr($target_dir, -1, 1) !== '/') $target_dir .= "/";
|
||||
if (ini_get('phar.readonly') == 1) {
|
||||
$output->writeln(TermColor::color8(31) . "You need to set \"phar.readonly\" to \"Off\"!");
|
||||
$output->writeln(TermColor::color8(31) . "See: https://stackoverflow.com/questions/34667606/cant-enable-phar-writing");
|
||||
return Command::FAILURE;
|
||||
return 1;
|
||||
}
|
||||
if (!is_dir($target_dir)) {
|
||||
$output->writeln(TermColor::color8(31) . "Error: No such file or directory ($target_dir)" . TermColor::RESET);
|
||||
return Command::FAILURE;
|
||||
return 1;
|
||||
}
|
||||
$filename = "server.phar";
|
||||
$this->build($target_dir, $filename);
|
||||
|
||||
return Command::SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function build($target_dir, $filename) {
|
||||
|
||||
@@ -20,7 +20,7 @@ class CheckConfigCommand extends Command
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||
if (LOAD_MODE !== 1) {
|
||||
$output->writeln("<error>仅限在Composer依赖模式中使用此命令!</error>");
|
||||
return Command::FAILURE;
|
||||
return 1;
|
||||
}
|
||||
$current_cfg = getcwd() . "/config/";
|
||||
$remote_cfg = include_once FRAMEWORK_ROOT_DIR . "/config/global.php";
|
||||
@@ -42,7 +42,7 @@ class CheckConfigCommand extends Command
|
||||
$output->writeln("<info>配置文件暂无更新!</info>");
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,6 +26,6 @@ abstract class DaemonCommand extends Command
|
||||
die();
|
||||
}
|
||||
$this->daemon_file = $file;
|
||||
return Command::SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,6 @@ class DaemonReloadCommand extends DaemonCommand
|
||||
parent::execute($input, $output);
|
||||
system("kill -USR1 " . intval($this->daemon_file["pid"]));
|
||||
$output->writeln("<info>成功重载!</info>");
|
||||
return Command::SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,6 @@ class DaemonStatusCommand extends DaemonCommand
|
||||
if (isset($stdout[count($stdout) - $i]))
|
||||
echo $stdout[count($stdout) - $i] . PHP_EOL;
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,6 @@ class DaemonStopCommand extends DaemonCommand
|
||||
system("kill -INT " . intval($this->daemon_file["pid"]));
|
||||
unlink(DataProvider::getWorkingDir() . "/.daemon_pid");
|
||||
$output->writeln("<info>成功停止!</info>");
|
||||
return Command::SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,10 +83,10 @@ class InitCommand extends Command
|
||||
echo PHP_EOL;
|
||||
} else {
|
||||
echo("Error occurred. Please check your updates.\n");
|
||||
return Command::FAILURE;
|
||||
return 1;
|
||||
}
|
||||
$output->writeln("<info>Done!</info>");
|
||||
return Command::SUCCESS;
|
||||
return 0;
|
||||
} elseif (LOAD_MODE === 2) { //从phar启动的框架包,初始化的模式
|
||||
$phar_link = new Phar(__DIR__);
|
||||
$current_dir = pathinfo($phar_link->getPath())["dirname"];
|
||||
@@ -104,7 +104,7 @@ class InitCommand extends Command
|
||||
}
|
||||
}
|
||||
$output->writeln("initialization must be started with composer-project mode!");
|
||||
return Command::FAILURE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
private function getExtractFiles(): array {
|
||||
|
||||
@@ -89,10 +89,10 @@ class PureHttpCommand extends Command
|
||||
$server->start();
|
||||
// return this if there was no problem running the command
|
||||
// (it's equivalent to returning int(0))
|
||||
return Command::SUCCESS;
|
||||
return 0;
|
||||
|
||||
// or return this if some error happened during the execution
|
||||
// (it's equivalent to returning int(1))
|
||||
// return Command::FAILURE;
|
||||
// return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,10 +40,10 @@ class RunServerCommand extends Command
|
||||
if (($opt = $input->getOption("env")) !== null) {
|
||||
if (!in_array($opt, ["production", "staging", "development", ""])) {
|
||||
$output->writeln("<error> \"--env\" option only accept production, development, staging and [empty] ! </error>");
|
||||
return Command::FAILURE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
(new Framework($input->getOptions()))->start();
|
||||
return Command::SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class SystemdCommand extends Command
|
||||
$path = $this->generate();
|
||||
$output->writeln("<info>成功生成 systemd 文件,位置:".$path."</info>");
|
||||
$output->writeln("<info>有关如何使用 systemd 配置文件,请访问 `https://github.com/zhamao-robot/zhamao-framework/issues/36`</info>");
|
||||
return Command::SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function generate() {
|
||||
|
||||
@@ -19,8 +19,8 @@ use ZM\Command\SystemdCommand;
|
||||
|
||||
class ConsoleApplication extends Application
|
||||
{
|
||||
const VERSION_ID = 405;
|
||||
const VERSION = "2.4.4";
|
||||
const VERSION_ID = 406;
|
||||
const VERSION = "2.4.5";
|
||||
|
||||
public function __construct(string $name = 'UNKNOWN') {
|
||||
define("ZM_VERSION_ID", self::VERSION_ID);
|
||||
|
||||
@@ -28,9 +28,9 @@ class OnClose implements SwooleEvent
|
||||
/** @noinspection PhpUnreachableStatementInspection */
|
||||
public function onCall($server, $fd) {
|
||||
unset(Context::$context[Co::getCid()]);
|
||||
Console::debug("Calling Swoole \"close\" event from fd=" . $fd);
|
||||
$conn = ManagerGM::get($fd);
|
||||
if ($conn === null) return;
|
||||
Console::debug("Calling Swoole \"close\" event from fd=" . $fd);
|
||||
set_coroutine_params(["server" => $server, "connection" => $conn, "fd" => $fd]);
|
||||
|
||||
$dispatcher1 = new EventDispatcher(OnCloseEvent::class);
|
||||
|
||||
@@ -59,7 +59,7 @@ class OnWorkerStart implements SwooleEvent
|
||||
try {
|
||||
register_shutdown_function(function () use ($server) {
|
||||
$error = error_get_last();
|
||||
if ($error["type"] != 0) {
|
||||
if (($error["type"] ?? -1) != 0) {
|
||||
Console::error("Internal fatal error: " . $error["message"] . " at " . $error["file"] . "({$error["line"]})");
|
||||
}
|
||||
//DataProvider::saveBuffer();
|
||||
|
||||
@@ -8,8 +8,8 @@ define("ZM_DATA", ZMConfig::get("global", "zm_data"));
|
||||
define("APP_VERSION", LOAD_MODE == 1 ? (json_decode(file_get_contents(DataProvider::getWorkingDir() . "/composer.json"), true)["version"] ?? "unknown") : "unknown");
|
||||
define("CRASH_DIR", ZMConfig::get("global", "crash_dir"));
|
||||
define("MAIN_WORKER", ZMConfig::get("global", "worker_cache")["worker"] ?? 0);
|
||||
@mkdir(ZM_DATA);
|
||||
@mkdir(CRASH_DIR);
|
||||
if (!is_dir(ZM_DATA)) @mkdir(ZM_DATA);
|
||||
if (!is_dir(CRASH_DIR)) @mkdir(CRASH_DIR);
|
||||
|
||||
define("CONN_WEBSOCKET", 0);
|
||||
define("CONN_HTTP", 1);
|
||||
|
||||
Reference in New Issue
Block a user