add api docs (#80)

This commit is contained in:
sunxyw
2022-03-27 16:42:36 +08:00
committed by GitHub
parent 5ddc514545
commit 4fbe2aa5af
147 changed files with 6425 additions and 1 deletions

View File

@@ -0,0 +1,41 @@
# ZM\Utils\CoMessage
## yieldByWS
```php
public function yieldByWS(int $timeout, array $hang, array $compare): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| timeout | int | |
| hang | array | |
| compare | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## resumeByWS
```php
public function resumeByWS(): bool
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |

View File

@@ -0,0 +1 @@
# ZM\Utils\CoroutinePool

View File

@@ -0,0 +1,198 @@
# ZM\Utils\DataProvider
## getResourceFolder
```php
public function getResourceFolder(): string
```
### 描述
返回资源目录
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | |
## getWorkingDir
```php
public function getWorkingDir(): false|string
```
### 描述
返回工作目录,不带最右边文件夹的斜杠(/
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| false|string | |
## getFrameworkRootDir
```php
public function getFrameworkRootDir(): false|string
```
### 描述
获取框架所在根目录
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| false|string | |
## getSourceRootDir
```php
public function getSourceRootDir(): false|string
```
### 描述
获取源码根目录除Phar模式外均与工作目录相同
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| false|string | |
## getFrameworkLink
```php
public function getFrameworkLink(): null|array|false|mixed
```
### 描述
获取框架反代链接
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| null|array|false|mixed | |
## getDataFolder
```php
public function getDataFolder(string $second): null|array|false|mixed|string
```
### 描述
获取zm_data数据目录如果二级目录不为空则自动创建目录并返回
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| second | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| null|array|false|mixed|string | |
## saveToJson
```php
public function saveToJson(mixed $filename, mixed $file_array): false|int
```
### 描述
将变量保存在zm_data下的数据目录传入数组
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| filename | mixed | |
| file_array | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| false|int | |
## loadFromJson
```php
public function loadFromJson(mixed $filename): null|mixed
```
### 描述
从json加载变量到内存
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| filename | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| null|mixed | |
## scanDirFiles
```php
public function scanDirFiles(mixed $dir, bool|string $relative, bool $recursive): array|false
```
### 描述
递归或非递归扫描目录,可返回相对目录的文件列表或绝对目录的文件列表
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| dir | mixed | |
| relative | bool|string | |
| recursive | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|false | |
## isRelativePath
```php
public function isRelativePath(mixed $path): bool
```
### 描述
检查路径是否为相对路径(根据第一个字符是否为"/"来判断)
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| path | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |

View File

@@ -0,0 +1,50 @@
# ZM\Utils\HttpUtil
## parseUri
```php
public function parseUri(mixed $request, mixed $response, mixed $uri, mixed $node, mixed $params): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| request | mixed | |
| response | mixed | |
| uri | mixed | |
| node | mixed | |
| params | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## handleStaticPage
```php
public function handleStaticPage(mixed $uri, Response|\Swoole\Http\Response $response, array $settings): bool
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| uri | mixed | |
| response | Response|\Swoole\Http\Response | |
| settings | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |

View File

@@ -0,0 +1 @@
# ZM\Utils\Macroable

View File

@@ -0,0 +1,42 @@
# ZM\Utils\Manager\CronManager
## initCronTasks
```php
public function initCronTasks(): mixed
```
### 描述
初始化 Cron 注解
必须在 WorkerStart 事件中调用
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## startExecute
```php
public function startExecute(ZM\Annotation\Cron\Cron $v, ZM\Event\EventDispatcher $dispatcher, Cron\CronExpression $cron): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| v | ZM\Annotation\Cron\Cron | |
| dispatcher | ZM\Event\EventDispatcher | |
| cron | Cron\CronExpression | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,62 @@
# ZM\Utils\Manager\ModuleManager
## getConfiguredModules
```php
public function getConfiguredModules(): array
```
### 描述
扫描src目录下的所有已经被标注的模块
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## packModule
```php
public function packModule(mixed $module): bool
```
### 描述
打包模块
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| module | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## unpackModule
```php
public function unpackModule(mixed $module, array $options): array|false
```
### 描述
解包模块
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| module | mixed | |
| options | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|false | |

View File

@@ -0,0 +1 @@
# ZM\Utils\Manager\ProcessManager

View File

@@ -0,0 +1 @@
# ZM\Utils\Manager\RouteManager

View File

@@ -0,0 +1 @@
# ZM\Utils\Manager\TaskManager

View File

@@ -0,0 +1,64 @@
# ZM\Utils\Manager\WorkerManager
## workerAction
```php
public function workerAction(mixed $src_worker_id, mixed $data): mixed
```
### 描述
Worker 进程间通信触发的动作类型函数
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| src_worker_id | mixed | |
| data | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## sendActionToWorker
```php
public function sendActionToWorker(mixed $worker_id, mixed $action, mixed $data): mixed
```
### 描述
给 Worker 进程发送动作指令(包括自身,自身将直接执行)
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| worker_id | mixed | |
| action | mixed | |
| data | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## resumeAllWorkerCoroutines
```php
public function resumeAllWorkerCoroutines(): mixed
```
### 描述
向所有 Worker 进程发送动作指令
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,203 @@
# ZM\Utils\MessageUtil
## downloadCQImage
```php
public function downloadCQImage(mixed $msg, null $path): array|false
```
### 描述
下载消息中 CQ 码的所有图片,通过 url
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| msg | mixed | |
| path | null | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|false | |
## containsImage
```php
public function containsImage(mixed $msg): bool
```
### 描述
检查消息中是否含有图片 CQ 码
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| msg | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## getImageCQFromLocal
```php
public function getImageCQFromLocal(mixed $file, int $type): string
```
### 描述
通过本地地址返回图片的 CQ 码
type == 0 : 返回图片的 base64 CQ 码
type == 1 : 返回图片的 file://路径 CQ 码(路径必须为绝对路径)
type == 2 : 返回图片的 http://xxx CQ 码(默认为 /images/ 路径就是文件对应所在的目录)
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| file | mixed | |
| type | int | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | |
## splitCommand
```php
public function splitCommand(mixed $msg): array|string[]
```
### 描述
分割字符,将用户消息通过空格或换行分割为数组
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| msg | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|string[] | |
## matchCommand
```php
public function matchCommand(mixed $msg, mixed $obj): ZM\Entity\MatchResult
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| msg | mixed | |
| obj | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZM\Entity\MatchResult | |
## addShortCommand
```php
public function addShortCommand(mixed $command, string $reply): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| command | mixed | |
| reply | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## strToArray
```php
public function strToArray(mixed $msg, false $trim_text, bool $ignore_space): array
```
### 描述
字符串转数组
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| msg | mixed | |
| trim_text | false | |
| ignore_space | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## arrayToStr
```php
public function arrayToStr(array $array): string
```
### 描述
数组转字符串
纪念一下这段代码完全由AI生成没有人知道它是怎么写的这句话是我自己写的不知道是不是有人知道的
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| array | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | |
## generateCommandHelp
```php
public function generateCommandHelp(): array
```
### 描述
根据注解树生成命令列表、帮助
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | 帮助信息,每个元素对应一个命令的帮助信息,格式为:命令名(其他触发条件):命令描述 |

View File

@@ -0,0 +1,79 @@
# ZM\Utils\SignalListener
## signalMaster
```php
public function signalMaster(Swoole\Server $server): mixed
```
### 描述
监听Master进程的Ctrl+C
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| server | Swoole\Server | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## signalManager
```php
public function signalManager(): mixed
```
### 描述
监听Manager进程的Ctrl+C
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## signalWorker
```php
public function signalWorker(mixed $worker_id, Swoole\Server $server): mixed
```
### 描述
监听Worker/TaskWorker进程的Ctrl+C
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| worker_id | mixed | |
| server | Swoole\Server | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## processKillerPrompt
```php
public function processKillerPrompt(): mixed
```
### 描述
按5次Ctrl+C后强行杀死框架的处理函数
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,17 @@
# ZM\Utils\SingletonTrait
## getInstance
```php
public function getInstance(): self
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| self | |

View File

@@ -0,0 +1,195 @@
# ZM\Utils\Terminal
## executeCommand
```php
public function executeCommand(string $cmd): bool
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| cmd | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## help
```php
public function help(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## status
```php
public function status(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## testlog
```php
public function testlog(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## call
```php
public function call(mixed $it): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| it | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## level
```php
public function level(mixed $it): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| it | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## bc
```php
public function bc(mixed $it): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| it | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## echoI
```php
public function echoI(mixed $it): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| it | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## stop
```php
public function stop(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## reload
```php
public function reload(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,76 @@
# ZM\Utils\ZMUtil
## stop
```php
public function stop(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## reload
```php
public function reload(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getReloadableFiles
```php
public function getReloadableFiles(): string[]|string[][]
```
### 描述
在工作进程中返回可以通过reload重新加载的php文件列表
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string[]|string[][] | |
## getClassesPsr4
```php
public function getClassesPsr4(mixed $dir, mixed $base_namespace, null|mixed $rule, bool $return_path_value): string[]
```
### 描述
使用Psr-4标准获取目录下的所有类
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| dir | mixed | |
| base_namespace | mixed | |
| rule | null|mixed | |
| return_path_value | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string[] | |