Compare commits

...

244 Commits

Author SHA1 Message Date
crazywhalecc
fb936e97ac remove prefer for composer 2022-12-20 23:49:41 +08:00
crazywhalecc
8ca4f7400a increment build number (build 638) 2022-12-20 15:46:29 +00:00
Jerry
61b48676ae Merge pull request #188 from zhamao-robot/v3-beta1
Beta 1 发布
2022-12-20 23:45:43 +08:00
crazywhalecc
257e59b79f remove debug log 2022-12-20 23:42:29 +08:00
crazywhalecc
c19791c31d remove debug log 2022-12-20 23:41:58 +08:00
crazywhalecc
c99747c1f6 add class alias helper generate command 2022-12-20 23:36:43 +08:00
crazywhalecc
a9b6989966 Merge remote-tracking branch 'origin/v3-beta1' into v3-beta1
# Conflicts:
#	src/Globals/global_class_alias.php
2022-12-20 23:22:55 +08:00
crazywhalecc
c9bf0fb13c prerelease of beta1 2022-12-20 23:19:55 +08:00
sunxyw
04247048d4 increment build number (build 637) 2022-12-20 15:05:27 +00:00
sunxyw
b2a6c2f5e0 add container class_alias support (#189) 2022-12-20 23:04:26 +08:00
crazywhalecc
865c306e14 prerelease of beta1 2022-12-20 20:10:40 +08:00
sunxyw
588fc919d9 increment build number (build 636) 2022-12-19 12:23:38 +00:00
sunxyw
8ff7da4d23 PHP80 小修 (#187)
* migrate-php80

fix styles
fix static analyse

* fix some bugs
2022-12-19 20:22:47 +08:00
sunxyw
da516b487d update readme test badge src (#186) 2022-12-19 15:20:01 +08:00
crazywhalecc
06615cbb29 increment build number (build 635) 2022-12-19 06:02:03 +00:00
crazywhalecc
463ee0cced update api docs 2022-12-19 06:01:59 +00:00
Jerry
208ccd6642 Merge pull request #185 from zhamao-robot/plugin-update-post
完善插件加载系统
2022-12-19 14:01:02 +08:00
crazywhalecc
cd2bb1b570 add plugin loader support 2022-12-19 01:45:27 +08:00
crazywhalecc
52a195aca2 fix DBException syntax error 2022-12-19 01:43:47 +08:00
crazywhalecc
fbc3cf00a2 increment build number (build 634) 2022-12-18 12:14:53 +00:00
crazywhalecc
ede5f456a8 update api docs 2022-12-18 12:14:51 +00:00
Jerry
2633e91d4d Merge pull request #184 from zhamao-robot/plugin-update-pre
插件和 OneBot 12 适配器前置内容
2022-12-18 20:13:50 +08:00
crazywhalecc
39b3a74d34 refactor with php-libonebot factory classes 2022-12-18 18:33:51 +08:00
crazywhalecc
3ecd224ce6 separate onebot 12 adapter things 2022-12-18 18:31:35 +08:00
sunxyw
49c7033eaa update dependencies (#180)
* update dependencies

* revert swoole-helper update
2022-12-18 15:58:48 +08:00
crazywhalecc
20ca848df9 increment build number (build 633) 2022-12-17 16:42:49 +00:00
crazywhalecc
5b0e3ed636 update api docs 2022-12-17 16:42:47 +00:00
Jerry
14840715bc Merge pull request #181 from zhamao-robot/8.0-upgrade
兼容 8.x PHP 一些改动
2022-12-18 00:41:56 +08:00
crazywhalecc
ed4537e5d5 update some strict parameters and separate easter eggs 2022-12-18 00:17:28 +08:00
crazywhalecc
58d4b4427d update default download native php to 8.1 2022-12-18 00:15:55 +08:00
crazywhalecc
8c6aba9361 rename Instant to ZM 2022-12-18 00:15:34 +08:00
crazywhalecc
1173949bba rename Instant to ZM 2022-12-18 00:15:19 +08:00
crazywhalecc
279956456c remove unused files 2022-12-18 00:11:54 +08:00
crazywhalecc
3f8c557a96 add requirement tokenizer 2022-12-18 00:11:33 +08:00
sunxyw
ff93201ab1 increment build number (build 632) 2022-12-17 16:00:09 +00:00
sunxyw
cd94539e99 update api docs 2022-12-17 16:00:07 +00:00
sunxyw
adc1d176e3 Merge pull request #179 from zhamao-robot/migrate-symfony-console-v6
迁移 Symfony Console V6
2022-12-17 23:59:19 +08:00
sunxyw
44c25f7fdd make commands lazily loaded 2022-12-17 22:30:19 +08:00
sunxyw
3806983bc2 change commands definition to attribute 2022-12-17 21:53:24 +08:00
sunxyw
c6f877700e add contributing document (#178) 2022-12-17 19:45:04 +08:00
sunxyw
c2fb90dfc7 increment build number (build 631) 2022-12-17 11:43:42 +00:00
sunxyw
ca61e6a238 update api docs 2022-12-17 11:43:41 +00:00
sunxyw
9399e54da8 Merge pull request #176 from zhamao-robot/docker-compose-support
增加 Docker Compose 支持
2022-12-17 19:42:42 +08:00
sunxyw
385f217b96 remove symfony/polyfill-php80 2022-12-17 16:29:28 +08:00
sunxyw
65bb6a2473 improve Command phpdoc 2022-12-17 16:27:49 +08:00
sunxyw
a430cf59c4 add docker init to InitCommand 2022-12-16 21:58:19 +08:00
sunxyw
4bf328ef67 refactor InitCommand 2022-12-16 18:05:51 +08:00
sunxyw
ebb724415d split InitException to SingletonViolationException 2022-12-16 17:59:12 +08:00
sunxyw
daa07dcb2b add docker compose support 2022-12-16 15:29:10 +08:00
sunxyw
635f081437 increment build number (build 630) 2022-11-18 07:22:16 +00:00
sunxyw
c7b4ca2a82 Merge pull request #173 from zhamao-robot/advance-exception
改进异常
2022-11-18 15:21:33 +08:00
sunxyw
b5c91531fa fix comment position 2022-11-18 15:16:48 +08:00
sunxyw
8199e91ce0 remove todo from InterruptException 2022-11-17 21:11:11 +08:00
sunxyw
44c32c1711 fix styles 2022-11-15 23:14:31 +08:00
sunxyw
5a3da43640 fix unused argument 2022-11-15 23:11:24 +08:00
sunxyw
352f3e920e deprecate ZMKnownException 2022-11-15 21:51:15 +08:00
sunxyw
5f4a00c77e refactor ZMException 2022-11-15 21:48:46 +08:00
crazywhalecc
aeea6f5dc1 increment build number (build 629) 2022-11-14 02:10:52 +00:00
Jerry
ea74a531b4 Merge pull request #172 from zhamao-robot/orgianze-bootstrap
重新组织 Bootstraper
2022-11-14 10:09:52 +08:00
sunxyw
02003b2bd3 reduce useless method 2022-11-12 01:15:40 +08:00
sunxyw
723dfd30a2 fix styles 2022-11-08 17:33:25 +08:00
sunxyw
aa29dc99f3 orgianze bootstrapper 2022-11-08 17:28:07 +08:00
crazywhalecc
74ba4d0145 increment build number (build 628) 2022-11-06 02:15:29 +00:00
crazywhalecc
5705f5227f update api docs 2022-11-06 02:15:28 +00:00
Jerry
3bb34b46ee Merge pull request #170 from zhamao-robot/proxy-server
添加代理、升级到 PHP8.0
2022-11-06 10:14:47 +08:00
crazywhalecc
4d0ea99f47 fix posix killer 2022-11-04 12:35:17 +08:00
sunxyw
fe70c07113 Merge pull request #171 from zhamao-robot/update-workflow
更新Workflow
2022-11-04 11:36:49 +08:00
sunxyw
27c6bf1864 add PHP8.2 support 2022-11-03 17:37:52 +08:00
sunxyw
f4ded4c6d7 drop PHP7.4 support 2022-11-03 17:36:09 +08:00
sunxyw
4a2c7f5ecb bump fkirc/skip-duplicate-actions to v5 2022-11-03 17:35:38 +08:00
crazywhalecc
7a051380e2 fix php version requirements 2022-11-03 10:36:08 +08:00
crazywhalecc
35dec947df add proxy server command and update lowest version of PHP >= 8.0 2022-11-03 10:18:17 +08:00
crazywhalecc
6b34427855 increment build number (build 627) 2022-10-02 10:35:36 +00:00
crazywhalecc
59a9f30089 update api docs 2022-10-02 10:35:35 +00:00
Jerry Ma
779564ebb6 Merge pull request #169 from zhamao-robot/state-and-windows
add state and ctrl+C support for windows
2022-10-02 18:34:49 +08:00
crazywhalecc
a4f992b9e5 add state and ctrl+C support for windows 2022-09-26 22:44:41 +08:00
sunxyw
cf3f09600b increment build number (build 626) 2022-09-23 14:12:45 +00:00
sunxyw
83c1d63408 update api docs 2022-09-23 14:12:42 +00:00
sunxyw
43337c34c8 fix config upstream changes (#168) 2022-09-23 22:11:26 +08:00
crazywhalecc
bb431ccf53 increment build number (build 625) 2022-09-23 09:09:14 +00:00
crazywhalecc
ba69cc93ee update api docs 2022-09-23 09:09:12 +00:00
Jerry Ma
406de8f4df Merge pull request #167 from zhamao-robot/fix-relative-path-check-in-windows
修复 isRelativePath 在 Windows 环境判断相反的 Bug
2022-09-23 17:08:13 +08:00
crazywhalecc
fd05fe6e25 fix 2022-09-23 12:50:44 +08:00
sunxyw
10a0ee9142 increment build number (build 624) 2022-09-11 11:33:47 +00:00
sunxyw
836d4dc1ef Merge pull request #165 from zhamao-robot/refactor-workflow
重构 Workflow
2022-09-11 19:32:56 +08:00
sunxyw
a18fcdb21e adjust workflow php version 2022-09-10 16:04:15 +08:00
sunxyw
6c9cd06e4a simplify incrememt build number 2022-09-09 21:03:51 +08:00
sunxyw
44c1ac054c avoid duplicate workflow runs 2022-09-09 20:55:44 +08:00
sunxyw
9d77d60887 fix styles 2022-09-09 18:59:46 +08:00
sunxyw
8f7fd97ebe refactor workflow 2022-09-09 18:54:55 +08:00
sunxyw
87e3b2249c increment build number (build 623) 2022-08-28 06:12:39 +00:00
sunxyw
5e12af77a4 drop config array access support (#163) 2022-08-28 14:12:01 +08:00
sunxyw
47244373d7 add custom phpunit printer (#164) 2022-08-28 13:03:58 +08:00
sunxyw
a72530598a increment build number (build 622) 2022-08-27 18:20:38 +00:00
sunxyw
2679facf24 update api docs 2022-08-27 18:20:37 +00:00
sunxyw
cf9db4b0d4 add config trace (#159)
* add config trace

* fix config tracer bug
2022-08-28 02:19:26 +08:00
crazywhalecc
f341c8585e increment build number (build 621) 2022-08-27 12:34:51 +00:00
crazywhalecc
28f7b47034 update api docs 2022-08-27 12:34:50 +00:00
Jerry Ma
99954f9140 Merge pull request #162 from zhamao-robot/windows-support-relative-path
FileSystem.php isRelativePath() 对 Windows 的兼容性
2022-08-27 20:34:02 +08:00
Jerry Ma
85b21d63ed Merge pull request #161 from zhamao-robot/fix-config-overwrite-bug
修复 Framework 中 Config 重写的 Bug
2022-08-27 20:33:48 +08:00
Jerry Ma
ef443d9912 Merge pull request #160 from zhamao-robot/sqlite-support
Sqlite 支持
2022-08-27 20:33:36 +08:00
crazywhalecc
db2b22c822 FileSystem.php isRelativePath() compatibility for windows 2022-08-27 20:03:22 +08:00
crazywhalecc
24156884e4 fix config overwrite bug in framework init 2022-08-27 19:56:29 +08:00
crazywhalecc
6413567353 change global config for database 2022-08-27 19:51:09 +08:00
crazywhalecc
84f84dad40 add sqlite extensions for github action 2022-08-27 19:50:40 +08:00
crazywhalecc
dd01653da9 add SQLiteDriver.php and change MySQLDriver.php 2022-08-27 19:47:45 +08:00
crazywhalecc
085472a12c refactor MySQL component to support SQLite at the same time 2022-08-27 19:45:23 +08:00
crazywhalecc
e9b6965678 remove redundant library 2022-08-27 19:39:02 +08:00
sunxyw
1a9680c09a increment build number (build 620) 2022-08-27 08:26:49 +00:00
sunxyw
40f8fe22ee update api docs 2022-08-27 08:26:48 +00:00
sunxyw
be6002dd64 Merge pull request #157 from zhamao-robot/fix-config-loading
修正&改进配置加载
2022-08-27 16:25:43 +08:00
sunxyw
96ebb770b6 add environment aliases 2022-08-27 01:12:38 +08:00
sunxyw
9bcdb254c9 increment build number (build 619) 2022-08-26 16:54:30 +00:00
sunxyw
87e71f1eb8 add repl command (#155) 2022-08-27 00:53:45 +08:00
sunxyw
451ce104c5 fix config loading 2022-08-27 00:42:43 +08:00
sunxyw
7920711988 increment build number (build 618) 2022-08-23 15:43:41 +00:00
sunxyw
6e78f2caf2 update api docs 2022-08-23 15:43:37 +00:00
sunxyw
2727b056eb Merge pull request #146 from zhamao-robot/refactor-config
基于 LibOB Config 类重构 ZMConfig
2022-08-23 23:42:30 +08:00
sunxyw
975d0e3540 allow multiple set config 2022-08-23 18:18:20 +08:00
sunxyw
eb7e700e7c replace legacy config 2022-08-23 18:02:00 +08:00
sunxyw
18892a14c2 ready to replace legacy config 2022-08-23 17:51:20 +08:00
sunxyw
6cbde80a1c delete outdated config classes 2022-08-23 17:36:45 +08:00
sunxyw
6fc875aa72 fix windows compatibility 2022-08-23 16:00:55 +08:00
sunxyw
29f5c3c758 change confusing name global to default 2022-08-23 15:59:55 +08:00
sunxyw
afa6411004 add array replace feature 2022-08-23 15:37:31 +08:00
crazywhalecc
67526c30da increment build number (build 617) 2022-08-22 13:39:34 +00:00
Jerry Ma
dc67dbc489 Merge pull request #152 from zhamao-robot/more-windows-support
add phpunit windows support
2022-08-22 21:38:21 +08:00
crazywhalecc
05ac2feebd add windows exit code support 2022-08-22 21:32:00 +08:00
crazywhalecc
6f30c04899 fix php 7.4 stuck bug 2022-08-22 21:27:23 +08:00
crazywhalecc
dfce8e9749 remove default mysql host 2022-08-22 21:22:49 +08:00
crazywhalecc
aae326133b cs-fix 2022-08-22 21:03:33 +08:00
crazywhalecc
15383a6b92 add phpunit windows support 2022-08-22 20:54:14 +08:00
sunxyw
5d8a1deb35 add yaml and toml config support 2022-08-22 17:15:10 +08:00
sunxyw
b09d12aad5 add config patch support 2022-08-22 17:02:50 +08:00
sunxyw
488acc3e69 fix incorrect onebot namespace 2022-08-22 16:30:45 +08:00
sunxyw
32534c870d add clearer exception 2022-08-22 16:29:27 +08:00
sunxyw
74af1516ac add get file load type test 2022-08-22 16:12:50 +08:00
sunxyw
07b2f175f3 add more test cases 2022-08-22 16:12:49 +08:00
sunxyw
1a1c65afce fix code styles 2022-08-22 16:12:49 +08:00
sunxyw
90282b858e fix inappropriate config group name 2022-08-22 16:12:49 +08:00
sunxyw
f819922d8a add basic usable config 2022-08-22 16:12:48 +08:00
sunxyw
aa8fdf557e add load order to config 2022-08-22 16:12:48 +08:00
sunxyw
4896cf0ad3 simply refactor ZMConfig 2022-08-22 16:12:47 +08:00
crazywhalecc
2e61e2a366 increment build number (build 616) 2022-08-22 07:46:48 +00:00
Jerry Ma
172a7444c9 Merge pull request #151 from zhamao-robot/windows-support
修复对 Windows 环境开发的支持
2022-08-22 15:45:57 +08:00
crazywhalecc
3ea5b16487 increment build number (build 615) 2022-08-22 07:39:45 +00:00
crazywhalecc
e83a169fd6 update api docs 2022-08-22 07:39:44 +00:00
Jerry Ma
53c1c0103c Merge pull request #149 from zhamao-robot/feature/class-alias
添加类别名
2022-08-22 15:38:49 +08:00
crazywhalecc
e467402a15 fix typo 2022-08-22 15:32:29 +08:00
crazywhalecc
d5fc16dccb change arg pass 2022-08-22 15:23:41 +08:00
crazywhalecc
3be84edb5a remove swoole pdo proxy 2022-08-22 13:37:48 +08:00
crazywhalecc
fe3bb22311 add windows development support 2022-08-22 13:35:07 +08:00
sunxyw
86c2cf96a9 fix gendoc incompatibility (#150) 2022-08-22 13:06:48 +08:00
crazywhalecc
67ba8340cc cs fix 2022-08-21 20:17:05 +08:00
crazywhalecc
ac69640253 add alias 2022-08-21 20:15:55 +08:00
crazywhalecc
64965bcc93 increment build number (build 614) 2022-08-21 08:42:32 +00:00
Jerry Ma
2eb73f3746 Merge pull request #148 from zhamao-robot/feature/mysql
完善 MySQL 连接池和组件
2022-08-21 16:41:22 +08:00
crazywhalecc
8f761c31e3 reset PHPDoc 2022-08-21 16:25:05 +08:00
crazywhalecc
528b61862a remove deprecated php version for integration-test 2022-08-21 16:20:21 +08:00
crazywhalecc
c7003a7139 add mysql support 2022-08-21 16:08:20 +08:00
crazywhalecc
75e65b082e fix middleware closure reference not working 2022-08-21 16:07:01 +08:00
crazywhalecc
22d38b783d update function name, add --print-process-pid option 2022-08-21 16:05:58 +08:00
crazywhalecc
ebdada57a6 add bot crafting command 2022-08-21 16:04:20 +08:00
crazywhalecc
28f8850013 increment build number (build 613) 2022-08-20 11:00:45 +00:00
Jerry Ma
540977c637 Merge pull request #147 from zhamao-robot/refactor/phpunit-test-rebuild
Refactor/phpunit test rebuild
2022-08-20 18:59:50 +08:00
crazywhalecc
4ba74e9f3e refactor phpunit-swoole to phpunit-zm and move old test cases 2022-08-20 17:49:33 +08:00
crazywhalecc
cecdb1681c increment build number (build 612) 2022-08-15 07:07:37 +00:00
crazywhalecc
2947da2a00 update api docs 2022-08-15 07:07:36 +00:00
crazywhalecc
da6000b4da fix container and coroutine 2022-08-15 15:06:45 +08:00
crazywhalecc
8be7207c3c increment build number (build 611) 2022-08-14 10:16:55 +00:00
crazywhalecc
0a806a74b1 update api docs 2022-08-14 10:16:53 +00:00
crazywhalecc
d56f9d6e6e fix param for annotation handler 2022-08-14 18:15:45 +08:00
crazywhalecc
dc742763a8 add pipeline feature for middleware 2022-08-14 18:15:45 +08:00
crazywhalecc
0b9b87ba23 upgrade cs-check php version 2022-08-14 18:15:45 +08:00
crazywhalecc
346be22ea9 change comment 2022-08-14 18:15:45 +08:00
crazywhalecc
b2c95d96b1 refactor all base things 2022-08-14 18:15:45 +08:00
crazywhalecc
1c801bb205 remove mkdocs config 2022-08-14 18:15:45 +08:00
crazywhalecc
163d240a9c change LICENSE copyright 2022-08-14 18:15:45 +08:00
crazywhalecc
19fc3a6d40 add PhpStorm meta config 2022-08-14 18:15:45 +08:00
crazywhalecc
4c9bc002f4 update composer.json 2022-08-14 18:15:45 +08:00
crazywhalecc
b3a5d50ba8 rename bin/start to bin/zhamao 2022-08-14 18:15:45 +08:00
crazywhalecc
f7919129b6 patch 2.x new features on 3.0 2022-08-14 18:15:45 +08:00
crazywhalecc
dccb1d91e2 update docs 2022-08-14 18:15:45 +08:00
crazywhalecc
41b058aeaf update to 3.0.0-alpha2 (build 610): refactor driver 2022-08-14 18:15:45 +08:00
sunxyw
f2a12634a4 increment build number (build 609) 2022-07-09 11:51:35 +00:00
sunxyw
8d33f45388 update api docs 2022-07-09 11:51:33 +00:00
sunxyw
cb7e230214 Merge pull request #135 from zhamao-robot/replace-console-with-logger
替换 zhamao/console 为 zhamao/logger
2022-07-09 19:50:18 +08:00
sunxyw
badd05a014 skip unfit tests for now 2022-06-09 00:25:17 +08:00
sunxyw
47ffe9a2ec temporarily fix logger infinite loop 2022-06-09 00:20:58 +08:00
sunxyw
4fe74eb5fe replace console with logger 2022-06-08 23:14:25 +08:00
sunxyw
1c40896dc0 increment build number (build 608) 2022-05-31 08:34:45 +00:00
sunxyw
872b4ce1c6 update api docs 2022-05-31 08:34:43 +00:00
sunxyw
c0fed1a391 Merge pull request #133 from zhamao-robot/fix-adapter-overflow
修复 OneBot11Adapter 无限回调溢出及其他小补丁
2022-05-31 16:33:40 +08:00
sunxyw
d1f584e490 fix phpstan false positive in ModuleUnpacker 2022-05-31 00:58:44 +08:00
sunxyw
79f5011d58 fix adapter overflow 2022-05-31 00:52:15 +08:00
sunxyw
e350edd41f fix container example command not working 2022-05-31 00:51:53 +08:00
sunxyw
23a6e56478 fix logger constructor 2022-05-31 00:51:26 +08:00
sunxyw
80050f11f2 increment build number (build 607) 2022-05-28 09:33:44 +00:00
sunxyw
25c46cc978 update api docs 2022-05-28 09:33:43 +00:00
sunxyw
458c42ae7c optimize container services register (#129)
* optimize container services register

* fix ConnectionObject not exists

* fix phpdoc
2022-05-28 17:33:01 +08:00
sunxyw
febeeadc7b increment build number (build 606) 2022-05-24 06:37:35 +00:00
sunxyw
044643559d Merge pull request #131 from zhamao-robot/refactor-framework-entry
轻量重构 Framework 类
2022-05-24 14:36:35 +08:00
sunxyw
782e668abf improve remote terminal logging 2022-05-23 11:54:07 +08:00
sunxyw
fa6af88566 fix dynamic logger call 2022-05-23 11:52:02 +08:00
sunxyw
c106c4fc2a cleanup framework class logging 2022-05-23 11:52:01 +08:00
sunxyw
09780f64de refactor framework class logging 2022-05-23 11:52:01 +08:00
sunxyw
81d4558b2f add master support for logger 2022-05-23 11:52:01 +08:00
sunxyw
3de0e37fd5 increment build number (build 605) 2022-05-23 01:52:21 +00:00
sunxyw
fcfd2f8ba5 update api docs 2022-05-23 01:52:19 +00:00
sunxyw
7e7e461237 remove deprecated global functions (#130) 2022-05-23 09:51:26 +08:00
sunxyw
2afab030bd increment build number (build 604) 2022-05-16 15:28:58 +00:00
sunxyw
5cbeee6e86 add logging config (#127) 2022-05-16 23:28:02 +08:00
sunxyw
87bbffefc3 increment build number (build 603) 2022-05-15 17:53:12 +00:00
sunxyw
a2877cab70 Merge pull request #126 from zhamao-robot/add-phpstan-extensions
添加 PHPStan 相关扩展
2022-05-16 01:52:30 +08:00
sunxyw
4f10b6dbc3 fix use of deprecated methods 2022-05-15 16:40:12 +08:00
sunxyw
24a213a8ff drop use of deprecated DBAL iterator 2022-05-15 16:39:26 +08:00
sunxyw
cf21044cf7 add phpunit extensions 2022-05-15 16:38:37 +08:00
crazywhalecc
289a5d7051 increment build number (build 602) 2022-05-14 17:17:29 +00:00
crazywhalecc
b5ae76d298 update api docs 2022-05-14 17:17:27 +00:00
Jerry Ma
598cf60e10 Merge pull request #125 from zhamao-robot/v3-refactor-command
框架V3部分重构
2022-05-15 01:16:39 +08:00
crazywhalecc
c4ca2103e4 fix phpunit-swoole class name 2022-05-15 00:16:01 +08:00
crazywhalecc
4b55a3e525 add $ZM_CUSTOM_PHP_PATH env support 2022-05-14 23:52:37 +08:00
crazywhalecc
376b81f841 change another table printer 2022-05-14 23:51:47 +08:00
crazywhalecc
ee6035c59a add openswoole support 2022-05-14 23:51:17 +08:00
crazywhalecc
a757330788 move process state related function to ProcessManager 2022-05-14 23:43:15 +08:00
crazywhalecc
bf141202f8 change worker start message 2022-05-14 23:42:15 +08:00
crazywhalecc
1be3127177 use zhamao/logger table printer instead 2022-05-14 23:41:24 +08:00
crazywhalecc
c74a43cd74 remove and refactor daemon/server command, add useful messages 2022-05-14 23:40:22 +08:00
crazywhalecc
1b520d3c96 add zhamao/logger dependency 2022-05-14 23:20:58 +08:00
sunxyw
b7418a2a3a fix increment build number wrong branch 2022-05-10 17:55:06 +08:00
Jerry Ma
eee67cdb53 Merge pull request #124 from zhamao-robot/refactor-zmconfig
重构 ZMConfig
2022-05-10 17:04:20 +08:00
crazywhalecc
1d70bc4ed7 change risky test 2022-05-10 16:03:37 +08:00
crazywhalecc
d06b0dd6d6 change include_once to require 2022-05-10 14:53:23 +08:00
crazywhalecc
cbbac0554e fix Console debug for ZMConfig get 2022-05-10 01:04:18 +08:00
crazywhalecc
5f16766997 update errcode docs 2022-05-10 00:32:42 +08:00
crazywhalecc
dcd6cae0f6 add global function is_assoc_array 2022-05-10 00:32:20 +08:00
crazywhalecc
cc43993d5b MessageUtilTest use smaller image to boost 2022-05-10 00:31:40 +08:00
crazywhalecc
2478ffe331 fix WorkerStop read global config bug 2022-05-10 00:31:03 +08:00
crazywhalecc
18ae960f86 refactor ZMConfig 2022-05-10 00:30:33 +08:00
sunxyw
fcb226e357 increment build number (build 601) 2022-05-09 16:53:51 +08:00
sunxyw
58c04b7a7b fix incorrect build branch 2022-05-09 16:42:34 +08:00
sunxyw
a6401fa9ef add adapter feature (#121) 2022-05-09 16:39:09 +08:00
sunxyw
2481124ada update workflows for future develop (#123)
* update workflows for future develop

* fix updated build id path
2022-05-09 16:36:32 +08:00
crazywhalecc
488fde47e5 create 3.x main branch and move VERSION constants 2022-05-08 21:15:16 +08:00
352 changed files with 14421 additions and 14999 deletions

42
.github/workflows/coding-style.yml vendored Normal file
View File

@@ -0,0 +1,42 @@
name: Code Style
on:
push:
pull_request:
workflow_dispatch:
jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: same_content_newer
skip_after_successful_duplicate: true
paths: '["src/**", "tests/**"]'
do_not_skip: '["workflow_dispatch", "schedule"]'
cs-fix:
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: Code Style
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup PHP
uses: sunxyw/workflows/setup-environment@main
with:
php-version: 8.0
php-extensions: swoole, posix, json
operating-system: ubuntu-latest
use-cache: true
- name: Code Style
uses: sunxyw/workflows/coding-style@main

View File

@@ -4,6 +4,7 @@ on:
pull_request:
branches:
- master
- '*-develop'
types:
- closed
paths:
@@ -16,54 +17,38 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ github.base_ref }}
- name: Setup PHP
uses: "shivammathur/setup-php@v2"
uses: sunxyw/workflows/setup-environment@main
with:
php-version: '8.1'
extensions: swoole, posix, json
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer Dependencies
run: "composer install --prefer-dist --no-progress --optimize-autoloader"
php-version: 8.0
php-extensions: swoole, posix, json
operating-system: ubuntu-latest
use-cache: true
- name: Generate API Docs
id: generate-api-docs
continue-on-error: true
run: bin/gendoc
- name: Commit api docs
if: steps.generate-api-docs.outcome == 'success'
continue-on-error: true
run: |
git config --global user.name 'Github Build Bot'
git config --global user.email 'noreply@github.com'
git add docs
git commit -m "update api docs"
git push
- name: Commit API Docs
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: update api docs
branch: ${{ github.base_ref }}
- name: Increment build number
run: sed -i -r 's/(.*)(\VERSION_ID\s=\s)([0-9]+)(.*)/echo "\1\2$((\3+1))\4"/ge' src/ZM/ConsoleApplication.php
id: increment-build-number
run: |
sed -i -r 's/(.*)(\VERSION_ID\s=\s)([0-9]+)(.*)/echo "\1\2$((\3+1))\4"/ge' src/ZM/Framework.php
BUILD_ID=$(cat src/ZM/Framework.php | grep "VERSION_ID = " | sed 's/[^0-9]//g')
echo "::set-output name=build_id::$BUILD_ID"
- name: Commit build number
run: |
BUILD_ID=$(cat src/ZM/ConsoleApplication.php | grep "VERSION_ID = " | sed 's/[^0-9]//g')
git config --global user.name 'Github Build Bot'
git config --global user.email 'noreply@github.com'
git add src/ZM/ConsoleApplication.php
git commit -m "increment build number (build $BUILD_ID)"
git push
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: increment build number (build ${{ steps.increment-build-number.outputs.build_id }})
branch: ${{ github.base_ref }}

View File

@@ -1,101 +0,0 @@
name: Integration and Style Test
on:
push:
branches:
- master
paths:
- '**/**.php'
pull_request:
branches:
- master
types:
- opened
- synchronize
- reopened
- ready_for_review
- review_requested
paths:
- '**/**.php'
jobs:
integration:
name: Integration Test (PHP ${{ matrix.php-versions }}) (OS ${{ matrix.operating-system }})
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ "ubuntu-latest", "macos-latest" ]
php-versions: [ "7.2", "7.3", "7.4", "8.0", "8.1" ]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup PHP
uses: "shivammathur/setup-php@v2"
with:
php-version: ${{ matrix.php-versions }}
extensions: swoole, posix, json
env:
SWOOLE_CONFIGURE_OPTS: --enable-openssl
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Validate composer.json
run: "composer validate --strict"
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer Dependencies
run: "composer install --prefer-dist --no-progress --optimize-autoloader"
- name: Run Static Analysis
run: "composer analyse"
- name: Run PHPUnit
run: "composer test"
cs-check:
name: PHP CS Fixer Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup PHP 7.2
uses: "shivammathur/setup-php@v2"
with:
php-version: "7.2"
extensions: swoole, posix, json
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Validate composer.json
run: "composer validate --strict"
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer Dependencies
run: "composer install --prefer-dist --no-progress --optimize-autoloader"
- name: Run PHP CS Fixer Check
run: "composer cs-fix -- --dry-run --diff"

42
.github/workflows/static-analysis.yml vendored Normal file
View File

@@ -0,0 +1,42 @@
name: Static Analysis
on:
push:
pull_request:
workflow_dispatch:
jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: same_content_newer
skip_after_successful_duplicate: true
paths: '["src/**", "tests/**"]'
do_not_skip: '["workflow_dispatch", "schedule"]'
analyse:
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: Static Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup PHP
uses: sunxyw/workflows/setup-environment@main
with:
php-version: 8.0
php-extensions: swoole, posix, json
operating-system: ubuntu-latest
use-cache: true
- name: Static Analysis
uses: sunxyw/workflows/static-analysis@main

54
.github/workflows/test.yml vendored Normal file
View File

@@ -0,0 +1,54 @@
name: Test
on:
push:
branches:
- main
- develop
- '*-dev*'
pull_request:
types:
- opened
- reopened
- review_requested
workflow_dispatch:
jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: same_content_newer
skip_after_successful_duplicate: true
paths: '["src/**", "tests/**", "bin/phpunit-zm"]'
do_not_skip: '["workflow_dispatch", "schedule"]'
test:
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
strategy:
matrix:
operating-system: [ ubuntu-latest, windows-latest, macos-latest ]
php-version: [ 8.0, 8.1, 8.2 ]
name: PHP ${{ matrix.php-version }} Test (${{ matrix.operating-system }})
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup PHP
uses: sunxyw/workflows/setup-environment@main
with:
php-version: ${{ matrix.php-version }}
php-extensions: swoole, posix, json
operating-system: ${{ matrix.operating-system }}
use-cache: true
- name: Test
uses: sunxyw/workflows/test@main

View File

@@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Deploy docs to GitHub Pages
uses: jenkey2011/vuepress-deploy@master
@@ -34,7 +34,7 @@ jobs:
REMOTE_USER: ${{ secrets.ZHAMAO_XIN_USER }}
TARGET: ${{ secrets.ZHAMAO_XIN_TARGET }}
- name: deploy script file
uses: wlixcc/SFTP-Deploy-Action@v1.0
uses: wlixcc/SFTP-Deploy-Action@v1.2
with:
username: ${{ secrets.ZHAMAO_XIN_USER }}
server: ${{ secrets.ZHAMAO_XIN_HOST }}

3
.gitignore vendored
View File

@@ -7,6 +7,7 @@
/tmp/
/temp/
/site/
/plugins/
# 框架审计文件
audit.log
@@ -78,3 +79,5 @@ package-lock.json
### ASDF ###
/.tool-version
.DS_Store

11
.phpstorm.meta.php Normal file
View File

@@ -0,0 +1,11 @@
<?php
namespace PHPSTORM_META {
use OneBot\V12\Object\Event\OneBotEvent;
use ZM\Context\Context;
override(Context::__call(0), map([
'getBotEvent' => OneBotEvent::class,
]));
}

View File

@@ -1,17 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Reload Zhamao Server" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="./zhamao server:reload &amp;&amp; exit" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="" />
<option name="SCRIPT_OPTIONS" value="" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="EXECUTE_IN_TERMINAL" value="true" />
<option name="EXECUTE_SCRIPT_FILE" value="false" />
<envs />
<method v="2" />
</configuration>
</component>

View File

@@ -1,17 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Zhamao Server" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="./zhamao server" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="./zhamao" />
<option name="SCRIPT_OPTIONS" value="server" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="EXECUTE_IN_TERMINAL" value="true" />
<option name="EXECUTE_SCRIPT_FILE" value="false" />
<envs />
<method v="2" />
</configuration>
</component>

View File

@@ -1,17 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run watcher" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="bin/watcher" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="" />
<option name="SCRIPT_OPTIONS" value="" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="/bin/zsh" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="EXECUTE_IN_TERMINAL" value="true" />
<option name="EXECUTE_SCRIPT_FILE" value="false" />
<envs />
<method v="2" />
</configuration>
</component>

View File

@@ -1,17 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Stop Zhamao Server" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="./zhamao server:stop &amp;&amp; exit" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="" />
<option name="SCRIPT_OPTIONS" value="" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="EXECUTE_IN_TERMINAL" value="true" />
<option name="EXECUTE_SCRIPT_FILE" value="false" />
<envs />
<method v="2" />
</configuration>
</component>

68
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,68 @@
# 炸毛框架贡献指南
首先很高兴你愿意读这篇文章,因为我们需要更多的开发者来帮助我们开发和维护。
如果你还没加入我们的 [QQ 群670821194][qq-group],我们建议你加入一下,以便和其他开发者实时交流和协作。
## 测试
我们目前采用 PHPUnit 作为测试框架,如果你编写了新的功能或改变了现有的行为,我们希望你可以编写相应的测试代码。
## 提交变更
请使用 [GitHub Pull Request][new-pr] 提交你的更改,并附上恰当的说明(例如一个简明的列表列出所作的改动)。
同时,请不要忘记在提交前执行代码格式检查 `composer cs-fix` 和静态分析检查 `composer analyse`
。虽然我们的自动化流程会在你推送到仓库后自动运行检查,但我仍然建议你提前在本地运行,以节省可能的修改成本。
对了,请尽量为你的每个函数、方法加上 PHPDoc 注释。
## 具体贡献流程
#### **你发现了个 BUG**
- **如果你发现的是安全漏洞,请不要在 GitHub 上回报!** 请直接联系 [@crazywhalecc](https://github.com/crazywhalecc)。
- **确保该问题还没被其他人回报。** 你可以在 [Issue 列表][issues] 中搜索相关关键词来检查。
- 如果你没能找到一个已有的 Issue 来描述你遇到的问题,[请新建一个 Issue][new-issue]。请务必包含**标题和清晰的描述**
,尽可能多的相关信息,以及一个**代码示例**或者一个**可执行的测试用例**,来描述你遇到的问题。
- 如果可以的话,请使用相关的 Issue 模板来创建 Issue。
#### **你修复了个 BUG**
- 在 GitHub 上提交一个 Pull Request。
- 确保 PR 的描述清楚地描述了问题和解决方案。如果有相关的 Issue请在 PR 描述中包含 Issue 编号。
#### **你想添加新功能或改变现有功能?**
- 虽然你可以直接提交 PR但我们建议你先与我们的开发者讨论你的想法以避免你的努力白费。你可以在 [QQ 群][qq-group]
中与我们的开发者交流,或者在 [GitHub Issue][issues] 中提出你的想法。
- 如果你的想法被采纳,你可以在 GitHub 上[提交一个 Pull Request][new-pr]。
#### **你对源码有疑问?**
- 你可以在 [QQ 群][qq-group] 中与我们的开发者讨论,或者你也可以在 [GitHub Issue][issues] 中提出你的疑问。
#### **你想为文档做贡献?**
- 非常欢迎^^
- 你可以直接[提交一个 Pull Request][new-pr]。
炸毛框架是由志愿开发者共同维护的项目。我们欢迎你加入我们的开发。
感谢~ :heart: :heart: :heart:
炸毛框架开发团队
[issues]: https://github.com/zhamao-robot/zhamao-framework/issues
[new-pr]: https://github.com/zhamao-robot/zhamao-framework/pull/new/master
[new-issue]: https://github.com/zhamao-robot/zhamao-framework/issues/new
[qq-group]: https://jq.qq.com/?_wv=1027&k=KdIGy0UK

View File

@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Copyright 2022 CrazyBot Developer Team
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@@ -9,7 +9,7 @@
</a>
<a href="https://github.com/zhamao-robot/zhamao-framework/actions">
<img src="https://img.shields.io/github/workflow/status/zhamao-robot/zhamao-framework/Integration%20and%20Style%20Test?label=Test&style=flat-square" alt="Integration Test">
<img src="https://img.shields.io/github/actions/workflow/status/zhamao-robot/zhamao-framework/test.yml?branch=v3-develop&label=Test&style=flat-square" alt="Integration Test">
</a>
<a href="https://packagist.org/packages/zhamao/framework">
@@ -50,28 +50,22 @@
## 简介
炸毛框架使用 PHP 编写,采用 Swoole 扩展为基础,主要面向 API 服务,聊天机器人OneBot 兼容的 QQ 机器人对接),包含 Websocket、HTTP
炸毛框架使用 PHP 编写,主要面向 API 服务,聊天机器人,包含 Websocket、HTTP
等监听和请求库,用户代码采用模块化处理,使用注解可以方便地编写各类功能。
框架主要用途为 HTTP 服务器,机器人搭建框架。尤其对于 QQ 机器人消息处理较为方便和全面,提供了众多会话机制和内部调用机制,可以以各种方式设计你自己的模块
框架主要用途为 HTTP 服务器,机器人搭建框架。尤其对于聊天机器人消息处理较为方便和全面,提供了众多会话机制和内部调用机制,可以以各种方式设计你自己的插件
```php
/**
* @CQCommand("你好")
*/
#[\BotCommand('你好')]
public function hello() {
ctx()->reply("你好,我是炸毛!"); // 简单的命令式回复
}
/**
* @RequestMapping("/index")
*/
#[\Route('/index')]
public function index() {
return "<h1>hello!</h1>"; // 快速的 HTTP 服务开发
}
```
> 从 2.7.0 版本开始,框架已支持同时使用 Annotation 和原生 Attribute 注解,供开发者根据需要自由选用。
## 开始
框架目前支持 Linux、WSL、macOS 环境直接运行,上述环境可直接使用下方一键安装脚本。
@@ -113,22 +107,20 @@ bash <(curl -fsSL https://zhamao.xin/go.sh)
## 特点
- 原生支持多个机器人客户端同时连接
- 使用 Swoole 多工作进程机制和协程加持,尽可能简单的情况下提升了性能
- 灵活的注解事件绑定机制,可同时使用 Annotation 和原生 Attribute 注解
- 易用的上下文,模块内随处可
- 采用模块化编写,可自由搭配其他 Composer 组件,也可单文件面向过程编写
- 完善的插件系统,可编写插件后打包或分发,供他人使
- 采用插件化编写,可自由搭配其他 Composer 组件,也可单文件面向过程编写
- 支持模块打包、热加载,分享模块更方便
- 常驻内存,全局缓存变量随处使用,提供多种缓存方案
- 自带 MySQL、Redis 等数据库连接池等数据库连接方案
- 自带 MySQL、SQLite、Redis 等数据库连接池
- 本身为 HTTP 服务器、WebSocket 服务器,可以构建属于自己的 HTTP API 接口
- 静态文件服务器,可将前端合并到一起
- 自带 PHP + Swoole 环境无需手动编译安装by [crazywhalecc/static-php-cli](https://github.com/crazywhalecc/static-php-cli)
- 自带 PHP 环境无需手动编译安装by [crazywhalecc/static-php-cli](https://github.com/crazywhalecc/static-php-cli)
## 下载源码
框架源码可直接克隆本仓库进行编辑,如果你在国内,访问 GitHub 和克隆仓库比较慢,可以将 `github.com` 替换为 `fgit.zhamao.me` 进行加速。
例如:`git clone https://fgit.zhamao.me/zhamao-robot/zhamao-framework.git --depth 1`
例如:`git clone https://hub.fastgit.xyz/zhamao-robot/zhamao-framework.git --depth 1`
## 贡献和捐赠
@@ -152,12 +144,12 @@ bash <(curl -fsSL https://zhamao.xin/go.sh)
作者的炸毛机器人已从2018年初起稳定运行了**四年半**,并且持续迭代。
欢迎随时在 HTTP-API 插件群里提问,当然更好的话可以加作者 QQ[627577391](http://wpa.qq.com/msgrd?v=3&uin=627577391&site=qq&menu=yes)
可以加作者 QQ[627577391](http://wpa.qq.com/msgrd?v=3&uin=627577391&site=qq&menu=yes)
或提交 [Issue](https://github.com/zhamao-robot/zhamao-framework/issues/new/choose) 进行疑难解答。
本项目在更新内容时,请及时关注 GitHub 动态,更新前请将自己的模块代码做好备份。
本项目在更新内容时,请及时关注 GitHub 动态,更新前请将自己的插件或项目代码做好备份。
项目框架采用 Apache-2.0 协议开源,在分发或重写修改等操作时需遵守协议。项目模块部分(`Module` 文件夹) 在非借鉴框架内代码时可不遵守 Apache-2.0 协议进行分发和修改(声明版权)。
项目框架采用 Apache-2.0 协议开源,在分发或重写修改等操作时需遵守协议。项目插件部分(`src/Globals``src/ZM` 文件夹外的其他文件夹) 在非借鉴框架内代码时可不遵守 Apache-2.0 协议进行分发和修改(声明版权)。
**注意**:在你使用 mirai 等 `AGPL-3.0` 协议的机器人软件与框架连接时,使用本框架需要将你编写或修改的部分使用 `AGPL-3.0` 协议重新分发。
@@ -167,6 +159,6 @@ bash <(curl -fsSL https://zhamao.xin/go.sh)
<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/PhpStorm.svg" width="300">
感谢 [php-libonebot](https://github.com/botuniverse/php-libonebot) 开发者 @sunxyw 中为项目开发规范化提出的一些建议。
感谢开发者 @sunxyw 中为项目开发规范化提出的一些建议。
<!-- ![star](https://starchart.cc/zhamao-robot/zhamao-framework.svg) -->
![star](https://starchart.cc/zhamao-robot/zhamao-framework.svg)

View File

@@ -82,6 +82,20 @@ if (file_exists($root . '/vendor/jasny/phpdoc-parser/composer.json')) {
}
}
function remove_temp_phpdoc_package()
{
if ($GLOBALS['phpdoc_package_temp_installed']) {
echo '正在移除 PHPDoc 解析库,请稍候...' . PHP_EOL;
passthru('composer remove --quiet jasny/phpdoc-parser', $exit_code);
if ($exit_code !== 0) {
echo '移除失败请手动移除composer remove jasny/phpdoc-parser' . PHP_EOL;
}
echo '移除完成';
}
}
register_shutdown_function('remove_temp_phpdoc_package');
// 从这里开始是主要生成逻辑
require_once $root . '/vendor/autoload.php';
@@ -89,7 +103,7 @@ require_once $root . '/vendor/autoload.php';
use Jasny\PhpdocParser\PhpdocParser;
use Jasny\PhpdocParser\Set\PhpDocumentor;
use Jasny\PhpdocParser\Tag\Summery;
use ZM\Console\Console;
use ZM\Logger\ConsoleLogger;
$opts = getopt('', ['show-warnings', 'show-debug']);
@@ -99,7 +113,7 @@ if (array_key_exists('show-warnings', $opts)) {
$show_warnings = false;
}
Console::init(array_key_exists('show-debug', $opts) ? 4 : 2);
ob_logger_register(new ConsoleLogger(array_key_exists('show-debug', $opts) ? 'debug' : 'info'));
$errors = [];
$warnings = [];
@@ -120,7 +134,7 @@ function error(string $message)
{
global $errors;
$errors[] = $message;
Console::error($message);
logger()->error($message);
}
function warning(string $message)
@@ -128,7 +142,7 @@ function warning(string $message)
global $warnings, $show_warnings;
$warnings[] = $message;
if ($show_warnings) {
Console::warning($message);
logger()->warning($message);
}
}
@@ -160,7 +174,7 @@ function get_class_metas(string $class_name, PhpdocParser $parser): array
continue;
}
Console::verbose('正在解析方法:' . $class_name . '::' . $method->getName());
logger()->debug('正在解析方法:' . $class_name . '::' . $method->getName());
// 获取方法的注释并解析
$doc = $method->getDocComment();
@@ -169,6 +183,8 @@ function get_class_metas(string $class_name, PhpdocParser $parser): array
continue;
}
try {
// 解析器对于多余空格的解析似乎有问题,这里去除一下多余的空格
$doc = preg_replace('/\s(?=\s)/', '\\1', $doc);
$meta = $parser->parse($doc);
} catch (\Exception $e) {
error('解析失败:' . $class_name . '::' . $method->getName() . '' . $e->getMessage());
@@ -231,7 +247,7 @@ function get_class_metas(string $class_name, PhpdocParser $parser): array
* 将方法的元数据转换为 Markdown 格式
*
* @param string $method 方法名
* @param array $meta 元数据
* @param array $meta 元数据
*/
function convert_meta_to_markdown(string $method, array $meta): string
{
@@ -285,7 +301,7 @@ function generate_sidebar_config(string $title, array $items): array
];
}
Console::info('开始生成!');
logger()->info('开始生成!');
// 遍历类并将元数据添加至数组中
foreach (new \RecursiveIteratorIterator($fs) as $file) {
@@ -314,9 +330,9 @@ foreach (new \RecursiveIteratorIterator($fs) as $file) {
}
// 获取完整类名
$path = ltrim($path, $root . '/');
$path = str_replace($root . '/', '', $path);
$class = str_replace(['.php', 'src/', '/'], ['', '', '\\'], $path);
Console::verbose('正在解析类:' . $class);
logger()->debug('正在解析类:' . $class);
$meta = get_class_metas($class, $parser);
// 忽略不包含任何方法的类
if (empty($meta)) {
@@ -346,7 +362,7 @@ foreach ($markdown as $class => $methods) {
if (!file_exists(dirname($file)) && !mkdir($concurrent_directory = dirname($file), 0777, true) && !is_dir($concurrent_directory)) {
throw new \RuntimeException(sprintf('无法建立目录 %s', $concurrent_directory));
}
Console::verbose('正在生成文档:' . $file);
logger()->debug('正在生成文档:' . $file);
$text = implode("\n\n", $methods);
file_put_contents($file, $text);
}
@@ -373,29 +389,21 @@ $file = $root . '/docs/.vuepress/api.js';
file_put_contents($file, $config);
if (count($warnings)) {
Console::warning('生成过程中发现 ' . count($warnings) . ' 次警告');
logger()->warning('生成过程中发现 ' . count($warnings) . ' 次警告');
if (!$show_warnings) {
Console::info('生成器默认忽略了警告,你可以通过 gendoc --show-warnings 来查看警告');
logger()->info('生成器默认忽略了警告,你可以通过 gendoc --show-warnings 来查看警告');
}
}
if (count($errors)) {
Console::error('生成过程中发现错误:');
logger()->error('生成过程中发现错误:');
foreach ($errors as $error) {
Console::error($error);
logger()->error($error);
}
}
Console::success('API 文档生成完毕');
Console::success(sprintf('共生成 %d 个类,共 %d 个方法', $class_count, $method_count));
logger()->notice('API 文档生成完毕');
logger()->notice(sprintf('共生成 %d 个类,共 %d 个方法', $class_count, $method_count));
// 完成生成,进行善后
if ($phpdoc_package_temp_installed) {
echo '正在移除 PHPDoc 解析库,请稍候...' . PHP_EOL;
passthru('composer remove --quiet jasny/phpdoc-parser', $exit_code);
if ($exit_code !== 0) {
echo '移除失败请手动移除composer remove jasny/phpdoc-parser' . PHP_EOL;
}
echo '移除完成';
}
exit(0);

View File

@@ -1,111 +0,0 @@
#!/usr/bin/env php
<?php
/** For Swoole coroutine tests */
// 如果改成 true则会在终端显示所有炸毛框架的 Log
const ZM_TEST_LOG_DEBUG = false;
use PHPUnit\Runner\Version;
use PHPUnit\TextUI\TestRunner;
use Swoole\Coroutine;
use ZM\Annotation\Swoole\OnStart;
use ZM\Command\RunServerCommand;
use ZM\Console\Console;
use ZM\ConsoleApplication;
use ZM\Event\EventManager;
use ZM\Framework;
use ZM\Store\ZMAtomic;
use ZM\Utils\ZMUtil;
$root = dirname(__DIR__);
Coroutine::set([
'log_level' => SWOOLE_LOG_INFO,
'trace_flags' => 0,
]);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
if (PHP_VERSION_ID <= 70100) {
fwrite(
STDERR,
sprintf(
'This version of PHPUnit is supported on PHP 7.1 and above.' . PHP_EOL .
'You are using PHP %s (%s).' . PHP_EOL,
PHP_VERSION,
PHP_BINARY
)
);
exit(1);
}
if (!ini_get('date.timezone')) {
ini_set('date.timezone', 'Asia/Shanghai');
}
require $root . '/vendor/autoload.php';
const ZM_VERSION_ID = ConsoleApplication::VERSION_ID;
const ZM_VERSION = ConsoleApplication::VERSION;
// 模拟define
const ZM_PROCESS_MASTER = 1;
const ZM_PROCESS_MANAGER = 2;
const ZM_PROCESS_WORKER = 4;
const ZM_PROCESS_USER = 8;
const ZM_PROCESS_TASKWORKER = 16;
define('FRAMEWORK_ROOT_DIR', $root);
define('WORKING_DIR', $root);
const SOURCE_ROOT_DIR = WORKING_DIR;
define('LOAD_MODE', is_dir(SOURCE_ROOT_DIR . '/src/ZM') ? 0 : 1);
chdir(__DIR__ . '/../');
$options = array_map(function ($x) {
return $x->getDefault();
}, RunServerCommand::exportDefinition()->getOptions());
$options['disable-safe-exit'] = true;
$options['worker-num'] = 1;
$options['private-mode'] = true;
$options['log-error'] = true;
spl_autoload_register(static function ($class) {
$map = [
TestRunner::class => 'vendor/phpunit/phpunit/src/TextUI/TestRunner.php',
Version::class => 'vendor/phpunit/phpunit/src/Runner/Version.php',
];
if (isset($map[$class])) {
$source = file_get_contents(SOURCE_ROOT_DIR . '/' . $map[$class]);
$source = str_replace(['#StandWith', 'Ukraine', 'declare(strict_types=1);'], '', $source);
eval('?>' . $source);
}
}, true, true);
Console::setLevel(0);
$framework = new Framework($options);
$start = new OnStart();
$start->method = function () {
try {
Console::setLevel(ZM_TEST_LOG_DEBUG ? 4 : 0);
$retcode = PHPUnit\TextUI\Command::main(false);
} finally {
Console::setLevel(0);
ZMUtil::stop(($retcode ?? 1) !== 0);
}
};
EventManager::addEvent(OnStart::class, $start);
$framework->start();
Swoole\Event::wait();
if (ZMAtomic::get('stop_signal')->get() === 2) {
exit(1);
}

65
bin/phpunit-zm Executable file
View File

@@ -0,0 +1,65 @@
#!/usr/bin/env php
<?php
/** For Swoole coroutine tests */
// 如果改成 true则会在终端显示所有炸毛框架的 Log
const ZM_TEST_LOG_DEBUG = false;
use OneBot\Driver\Event\Process\WorkerStartEvent;
use PHPUnit\TextUI\Command;
use Swoole\Atomic;
use Tests\ZMResultPrinter;
use ZM\Command\Server\ServerStartCommand;
use ZM\Event\EventProvider;
use ZM\Framework;
use ZM\Logger\ConsoleLogger;
use ZM\Store\MockAtomic;
// 引入自动加载
require dirname(__DIR__) . '/vendor/autoload.php';
// 声明一个全局的原子计数,用于保存整个进程的退出状态码
global $_swoole_atomic;
// Windows 没有 Swoole所以就使用了一个假的原子计数器反正 Windows 只有单进程
$_swoole_atomic = class_exists('\\Swoole\\Atomic') ? new Atomic() : new MockAtomic();
// 注册 Logger 等级
ob_logger_register(new ConsoleLogger(ZM_TEST_LOG_DEBUG ? 'debug' : 'error'));
// 使用框架自身的 EventProvider
global $ob_event_provider;
$ob_event_provider = new EventProvider();
// 注册一个最低级别的 WorkerStart 事件,用于在框架的事件初始化之后开始运行 PHPUnit
ob_event_provider()->addEventListener(WorkerStartEvent::getName(), function () {
register_shutdown_function(function () {
$error = error_get_last();
// 下面这段代码的作用就是,不是错误引发的退出时照常退出即可
if (($error['type'] ?? 0) != 0) {
logger()->emergency(zm_internal_errcode('E00027') . 'Internal fatal error: ' . $error['message'] . ' at ' . $error['file'] . "({$error['line']})");
}
Framework::getInstance()->stop();
});
$_SERVER['argv'][] = '--printer';
$_SERVER['argv'][] = ZMResultPrinter::class;
try {
// 不退出,而是返回 code
$retcode = Command::main(false);
} finally {
global $_swoole_atomic;
$_swoole_atomic->set($retcode ?? 0);
Framework::getInstance()->stop($retcode ?? 0);
}
}, 1);
try {
$options = ServerStartCommand::exportOptionArray();
$options['driver'] = 'workerman';
$options['worker-num'] = 1;
$options['private-mode'] = true;
(new Framework($options))->init()->start();
exit($_swoole_atomic->get());
} catch (Throwable $e) {
echo $e->getMessage() . PHP_EOL;
exit(1);
}

3
bin/phpunit-zm.bat Normal file
View File

@@ -0,0 +1,3 @@
@echo off
php %~dp0phpunit-zm %*

View File

@@ -5,7 +5,10 @@
# author: crazywhalecc
# since: 2.5.0
if [ -f "$(pwd)/runtime/php" ]; then
if [ "$ZM_CUSTOM_PHP_PATH" != "" ]; then
echo "* Using PHP executable: ""$ZM_CUSTOM_PHP_PATH"
executable="$ZM_CUSTOM_PHP_PATH"
elif [ -f "$(pwd)/runtime/php" ]; then
executable="$(pwd)/runtime/php"
echo "* Framework started with built-in php."
else

View File

@@ -13,30 +13,29 @@
}
],
"require": {
"php": "^7.2 || ^7.3 || ^7.4 || ^8.0 || ^8.1",
"php": "^8.0 || ^8.1",
"ext-json": "*",
"ext-posix": "*",
"ext-tokenizer": "*",
"doctrine/dbal": "^2.13.1",
"dragonmantank/cron-expression": "^3.3",
"jelix/version": "^2.0",
"koriym/attributes": "^1.0",
"onebot/libonebot": "dev-develop",
"psr/container": "^2.0",
"psy/psysh": "^0.11.2",
"symfony/console": "~6.0 || ~5.0 || ~4.0 || ~3.0",
"psy/psysh": "^0.11.8",
"symfony/console": "^6.0",
"symfony/polyfill-ctype": "^1.19",
"symfony/polyfill-mbstring": "^1.19",
"symfony/polyfill-php80": "^1.16",
"symfony/routing": "~6.0 || ~5.0 || ~4.0 || ~3.0",
"zhamao/config": "^1.0",
"zhamao/connection-manager": "^1.0",
"zhamao/console": "^1.0",
"zhamao/request": "^1.1"
"symfony/routing": "~6.0 || ~5.0 || ~4.0"
},
"require-dev": {
"brainmaestro/composer-git-hooks": "^2.8",
"brainmaestro/composer-git-hooks": "^3.0",
"friendsofphp/php-cs-fixer": "^3.2 != 3.7.0",
"jetbrains/phpstorm-attributes": "^1.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.1",
"phpunit/phpunit": "^8.5 || ^9.0",
"roave/security-advisories": "dev-latest",
"swoole/ide-helper": "^4.5"
@@ -48,31 +47,34 @@
"ext-redis": "If you use Redis in framework, you will need this extension",
"league/climate": "Display columns and status in terminal"
},
"minimum-stability": "stable",
"prefer-stable": true,
"minimum-stability": "dev",
"autoload": {
"psr-4": {
"ZM\\": "src/ZM"
},
"files": [
"src/ZM/global_functions.php"
"src/Globals/global_functions.php",
"src/Globals/global_defines_app.php",
"src/Globals/global_class_alias.php"
]
},
"autoload-dev": {
"psr-4": {
"Module\\": "src/Module",
"Custom\\": "src/Custom",
"Tests\\": "tests"
}
},
"bin": [
"bin/gendoc",
"bin/phpunit-swoole",
"bin/start"
"bin/phpunit-zm",
"bin/zhamao"
],
"config": {
"optimize-autoloader": true,
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"extra": {
"hooks": {
@@ -99,6 +101,6 @@
],
"analyse": "phpstan analyse --memory-limit 300M",
"cs-fix": "php-cs-fixer fix",
"test": "bin/phpunit-swoole --no-coverage"
"test": "bin/phpunit-zm --no-coverage"
}
}

View File

@@ -1,152 +1,110 @@
<?php
/** @noinspection PhpComposerExtensionStubsInspection */
declare(strict_types=1);
/* bind host */
$config['host'] = '0.0.0.0';
/* 启动框架的底层驱动(原生支持 swoole、workerman 两种) */
$config['driver'] = 'workerman';
/* bind port */
$config['port'] = 20001;
/* 框架开到公网或外部的HTTP访问链接通过 DataProvider::getFrameworkLink() 获取 */
$config['http_reverse_link'] = 'http://127.0.0.1:' . $config['port'];
/* 框架是否启动debug模式当debug模式为true时启用热更新需要安装inotify扩展 */
$config['debug_mode'] = false;
/* 存放框架内文件数据的目录 */
$config['zm_data'] = realpath(WORKING_DIR) . '/zm_data/';
/* 存放各个模块配置文件的目录 */
$config['config_dir'] = $config['zm_data'] . 'config/';
/* 存放崩溃和运行日志的目录 */
$config['crash_dir'] = $config['zm_data'] . 'crash/';
/* 对应swoole的server->set参数 */
$config['swoole'] = [
'log_file' => $config['crash_dir'] . 'swoole_error.log',
// 'worker_num' => swoole_cpu_num(), //如果你只有一个 OneBot 实例连接到框架并且代码没有复杂的CPU密集计算则可把这里改为1使用全局变量
'dispatch_mode' => 2, // 包分配原则,见 https://wiki.swoole.com/#/server/setting?id=dispatch_mode
'max_coroutine' => 300000,
'max_wait_time' => 5,
// 'task_worker_num' => 4,
// 'task_enable_coroutine' => true
/* 要启动的服务器监听端口及协议 */
$config['servers'] = [
[
'host' => '0.0.0.0',
'port' => 20001,
'type' => 'websocket',
],
[
'host' => '0.0.0.0',
'port' => 20002,
'type' => 'http',
'flag' => 20002,
],
[
'host' => '0.0.0.0',
'port' => 20003,
'type' => 'http',
'flag' => 20003,
],
];
/* 一些框架与框架运行时设置的调整 */
/* Workerman 驱动相关配置 */
$config['workerman_options'] = [
'worker_num' => 1, // 如果你只有一个 OneBot 实例连接到框架并且代码没有复杂的CPU密集计算则可把这里改为1使用全局变量
];
/* Swoole 驱动相关配置 */
$config['swoole_options'] = [
'coroutine_hook_flags' => SWOOLE_HOOK_ALL & (~SWOOLE_HOOK_CURL), // 协程 Hook 内容
'swoole_set' => [
'worker_num' => 1, // 如果你只有一个 OneBot 实例连接到框架并且代码没有复杂的CPU密集计算则可把这里改为1使用全局变量
'dispatch_mode' => 2, // 包分配原则,见 https://wiki.swoole.com/#/server/setting?id=dispatch_mode
'max_coroutine' => 300000, // 允许最大的协程数
'max_wait_time' => 5, // 安全退出模式下允许等待 Worker 的最长秒数
// 'task_worker_num' => 4, // 启动 TaskWorker 进程的数量(默认不启动)
// 'task_enable_coroutine' => true // TaskWorker 是否开启协程
],
'swoole_server_mode' => SWOOLE_PROCESS, // Swoole Server 启动模式,默认为 SWOOLE_PROCESS
];
/* 默认存取炸毛数据的目录相对目录时代表WORKING_DIR下的目录绝对目录按照绝对目录来 */
$config['data_dir'] = 'zm_data';
/* 框架本体运行时的一些可调配置 */
$config['runtime'] = [
'swoole_coroutine_hook_flags' => SWOOLE_HOOK_ALL & (~SWOOLE_HOOK_CURL),
'swoole_server_mode' => SWOOLE_PROCESS,
'middleware_error_policy' => 1,
'reload_delay_time' => 800,
'global_middleware_binding' => [],
'save_console_log_file' => false, // 改为目标路径,则将 Console 输出的日志保存到文件
'annotation_reader_ignore' => [ // 设置注解解析器忽略的注解名或命名空间,防止解析到不该解析的
'name' => [
'mixin',
],
'namespace' => [],
],
'timezone' => 'Asia/Shanghai',
];
/* 轻量字符串缓存,默认开启 */
$config['light_cache'] = [
'size' => 512, // 最多允许储存的条数需要2的倍数
'max_strlen' => 32768, // 单行字符串最大长度需要2的倍数
'hash_conflict_proportion' => 0.6, // Hash冲突率越大越好但是需要的内存更多
'persistence_path' => $config['zm_data'] . '_cache.json',
'auto_save_interval' => 900,
];
/* 大容量跨进程变量存储2.2.0可用) */
$config['worker_cache'] = [
'worker' => 0,
'transaction_timeout' => 30000,
];
/* MySQL数据库连接信息host留空则启动时不创建sql连接池 */
$config['mysql_config'] = [
'host' => '',
'port' => 3306,
'unix_socket' => null,
'username' => 'root',
'password' => '123456',
'dbname' => '',
'charset' => 'utf8mb4',
'pool_size' => 64,
'options' => [
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
],
];
/* Redis连接信息host留空则启动时不创建Redis连接池 */
$config['redis_config'] = [
'host' => '',
'port' => 6379,
'timeout' => 1,
'db_index' => 0,
'auth' => '',
];
/* onebot连接约定的token */
$config['access_token'] = '';
/* HTTP服务器固定请求头的返回 */
$config['http_header'] = [
'Server' => 'zhamao-framework',
'Content-Type' => 'text/html; charset=utf-8',
];
/* HTTP服务器在指定状态码下回复的页面默认 */
$config['http_default_code_page'] = [
'404' => '404.html',
];
/* zhamao-framework在框架启动时初始化的atomic们 */
$config['init_atomics'] = [
// 'custom_atomic_name' => 0, //自定义添加的Atomic
];
/* 终端日志显示等级0-4 */
$config['info_level'] = 2;
/* 上下文接口类 implemented from ContextInterface */
$config['context_class'] = \ZM\Context\Context::class;
/* 静态文件访问 */
$config['static_file_server'] = [
'status' => false,
'document_root' => realpath(__DIR__ . '/../') . '/resources/html',
'document_index' => [
'index.html',
/* 允许加载插件形式 */
$config['plugin'] = [
'enable' => true,
'load_dir' => 'plugins',
];
/* 内部默认启用的插件 */
$config['native_plugin'] = [
'onebot12' => true, // OneBot v12 协议支持
'onebot12-ban-other-ws' => true, // OneBot v12 协议支持,禁止其他 WebSocket 连接
];
/* 静态文件读取器 */
$config['file_server'] = [
'enable' => true,
'document_root' => $config['data_dir'] . '/public/',
'document_index' => 'index.html',
'document_code_page' => [
'404' => '404.html',
'500' => '500.html',
],
];
/* 机器人解析模块关闭后无法使用如CQCommand等注解(上面的modules即将废弃) */
$config['onebot'] = [
'status' => true,
'single_bot_mode' => false,
'message_level' => 99,
'message_convert_string' => true,
'message_command_policy' => 'interrupt',
];
/* 一个远程简易终端使用nc直接连接即可但是不建议开放host为0.0.0.0(远程连接) */
$config['remote_terminal'] = [
'status' => false,
'host' => '127.0.0.1',
'port' => 20002,
'token' => '',
];
/* 模块(插件)加载器的相关设置 */
$config['module_loader'] = [
'enable_hotload' => false,
'load_path' => $config['zm_data'] . 'modules',
/* MySQL 和 SQLite3 数据库连接配置,框架将自动生成连接池,支持多个连接池 */
$config['database'] = [
'sqlite_db1' => [
'enable' => false,
'type' => 'sqlite',
'dbname' => 'a.db',
'pool_size' => 10,
],
'zm' => [
'enable' => false,
'type' => 'mysql',
'host' => '127.0.0.1', // 填写数据库服务器地址后才会创建数据库连接
'port' => 3306,
'username' => 'root',
'password' => 'ZhamaoTEST',
'dbname' => 'zm',
'charset' => 'utf8mb4',
'pool_size' => 64,
],
];
return $config;

152
config/global_old.php Normal file
View File

@@ -0,0 +1,152 @@
<?php
/** @noinspection PhpComposerExtensionStubsInspection */
declare(strict_types=1);
/* bind host */
$config['host'] = '0.0.0.0';
/* bind port */
$config['port'] = 20001;
/* 框架开到公网或外部的HTTP访问链接通过 DataProvider::getFrameworkLink() 获取 */
$config['http_reverse_link'] = 'http://127.0.0.1:' . $config['port'];
/* 框架是否启动debug模式当debug模式为true时启用热更新需要安装inotify扩展 */
$config['debug_mode'] = false;
/* 存放框架内文件数据的目录 */
$config['zm_data'] = realpath(WORKING_DIR) . '/zm_data/';
/* 存放各个模块配置文件的目录 */
$config['config_dir'] = $config['zm_data'] . 'config/';
/* 存放崩溃和运行日志的目录 */
$config['crash_dir'] = $config['zm_data'] . 'crash/';
/* 对应swoole的server->set参数 */
$config['swoole'] = [
'log_file' => $config['crash_dir'] . 'swoole_error.log',
// 'worker_num' => swoole_cpu_num(), //如果你只有一个 OneBot 实例连接到框架并且代码没有复杂的CPU密集计算则可把这里改为1使用全局变量
'dispatch_mode' => 2, // 包分配原则,见 https://wiki.swoole.com/#/server/setting?id=dispatch_mode
'max_coroutine' => 300000,
'max_wait_time' => 5,
// 'task_worker_num' => 4,
// 'task_enable_coroutine' => true
];
/* 一些框架与框架运行时设置的调整 */
$config['runtime'] = [
'swoole_coroutine_hook_flags' => SWOOLE_HOOK_ALL & (~SWOOLE_HOOK_CURL),
'swoole_server_mode' => SWOOLE_PROCESS,
'middleware_error_policy' => 1,
'reload_delay_time' => 800,
'global_middleware_binding' => [],
'save_console_log_file' => false, // 改为目标路径,则将 Console 输出的日志保存到文件
'annotation_reader_ignore' => [ // 设置注解解析器忽略的注解名或命名空间,防止解析到不该解析的
'name' => [
'mixin',
],
'namespace' => [],
],
];
/* 轻量字符串缓存,默认开启 */
$config['light_cache'] = [
'size' => 512, // 最多允许储存的条数需要2的倍数
'max_strlen' => 32768, // 单行字符串最大长度需要2的倍数
'hash_conflict_proportion' => 0.6, // Hash冲突率越大越好但是需要的内存更多
'persistence_path' => $config['zm_data'] . '_cache.json',
'auto_save_interval' => 900,
];
/* 大容量跨进程变量存储2.2.0可用) */
$config['worker_cache'] = [
'worker' => 0,
'transaction_timeout' => 30000,
];
/* MySQL数据库连接信息host留空则启动时不创建sql连接池 */
$config['mysql_config'] = [
'host' => '',
'port' => 3306,
'unix_socket' => null,
'username' => 'root',
'password' => '123456',
'dbname' => '',
'charset' => 'utf8mb4',
'pool_size' => 64,
'options' => [
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
],
];
/* Redis连接信息host留空则启动时不创建Redis连接池 */
$config['redis_config'] = [
'host' => '',
'port' => 6379,
'timeout' => 1,
'db_index' => 0,
'auth' => '',
];
/* onebot连接约定的token */
$config['access_token'] = '';
/* HTTP服务器固定请求头的返回 */
$config['http_header'] = [
'Server' => 'zhamao-framework',
'Content-Type' => 'text/html; charset=utf-8',
];
/* HTTP服务器在指定状态码下回复的页面默认 */
$config['http_default_code_page'] = [
'404' => '404.html',
];
/* zhamao-framework在框架启动时初始化的atomic们 */
$config['init_atomics'] = [
// 'custom_atomic_name' => 0, //自定义添加的Atomic
];
/* 终端日志显示等级0-4 */
$config['info_level'] = 2;
/* 上下文接口类 implemented from ContextInterface */
$config['context_class'] = \ZM\Context\Context::class;
/* 静态文件访问 */
$config['static_file_server'] = [
'status' => false,
'document_root' => realpath(__DIR__ . '/../') . '/resources/html',
'document_index' => [
'index.html',
],
];
/* 机器人解析模块关闭后无法使用如CQCommand等注解(上面的modules即将废弃) */
$config['onebot'] = [
'status' => true,
'single_bot_mode' => false,
'message_level' => 99,
'message_convert_string' => true,
'message_command_policy' => 'interrupt',
];
/* 一个远程简易终端使用nc直接连接即可但是不建议开放host为0.0.0.0(远程连接) */
$config['remote_terminal'] = [
'status' => false,
'host' => '127.0.0.1',
'port' => 20002,
'token' => '',
];
/* 模块(插件)加载器的相关设置 */
$config['module_loader'] = [
'enable_hotload' => false,
'load_path' => $config['zm_data'] . 'modules',
];
return $config;

96
docker-compose.yml Normal file
View File

@@ -0,0 +1,96 @@
version: "3.9"
services:
bot:
build:
context: docker/zhamao
dockerfile: ./Dockerfile
container_name: zhamao-bot
depends_on:
- database-postgres
- database-redis
networks:
- bot-net
ports:
- "20001-20005:20001-20005/tcp"
volumes:
- ".:/bot"
walle-q:
build:
context: docker/walle-q
dockerfile: ./Dockerfile
container_name: zhamao-bot-walle-q
depends_on:
- bot
networks:
- bot-net
volumes:
- "./docker/volumes/walle-q-data:/bot"
database-postgres:
container_name: zhamao-bot-db-postgres
env_file:
- docker/environment.env
image: postgres:14.4-alpine
networks:
- bot-net
ports:
- "5432:5432/tcp"
restart: always
volumes:
- "./docker/volumes/postgres-data:/var/lib/postgresql/data"
- "./docker/volumes/postgres-init:/docker-entrypoint-initdb.d"
database-redis:
command:
- redis-server
- --requirepass
- "$${REDIS_PASSWORD}"
container_name: zhamao-bot-db-redis
env_file:
- docker/environment.env
image: redis:7.0-alpine
networks:
- bot-net
ports:
- "6379:6379/tcp"
restart: always
volumes:
- "./docker/volumes/redis-data:/data"
db-admin-adminer:
container_name: zhamao-bot-dbadmin-adminer
depends_on:
database-postgres:
condition: service_started
database-redis:
condition: service_started
env_file:
- docker/environment.env
image: adminer:latest
networks:
- bot-net
ports:
- "15432:8080/tcp"
profiles:
- with-adminer
db-admin-redis-insight:
container_name: zhamao-bot-dbadmin-redis-insight
depends_on:
database-postgres:
condition: service_started
database-redis:
condition: service_started
image: redislabs/redisinsight:latest
networks:
- bot-net
ports:
- "16379:8001/tcp"
profiles:
- with-adminer
networks:
bot-net:
name: bot-net

2
docker/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/volumes
environment.env

View File

@@ -0,0 +1,7 @@
REDIS_PASSWORD={{$REDIS_PASSWORD}}
POSTGRES_USER={{$DB_ROOT_USER}}
POSTGRES_PASSWORD={{$DB_ROOT_PASSWORD}}
POSTGRES_APPLICATION_USER={{$DB_USER}}
POSTGRES_APPLICATION_USER_PASSWORD={{$DB_PASSWORD}}
POSTGRES_APPLICATION_DATABASE={{$DB_NAME}}

14
docker/walle-q/Dockerfile Normal file
View File

@@ -0,0 +1,14 @@
FROM alpine:latest
MAINTAINER sunxyw <me@sunxyw.xyz>
RUN apk add --no-cache curl
RUN mkdir -p /bot && \
curl -fsSL https://github.com/onebot-walle/walle-q/releases/latest/download/walle-q-i686-linux-musl.tar.gz -O && \
tar -zxvf walle-q-i686-linux-musl.tar.gz -C /bot && \
rm -rf walle-q-i686-linux-musl.tar.gz && \
chmod +x /bot/walle-q-i686-linux-musl
ENV TZ=Asia/Shanghai
ENTRYPOINT [ "/bot/walle-q-i686-linux-musl" ]

14
docker/zhamao/Dockerfile Normal file
View File

@@ -0,0 +1,14 @@
FROM phpswoole/swoole:5.0-php8.1
MAINTAINER sunxyw <me@sunxyw.xyz>
WORKDIR "/bot"
ENV TZ=Asia/Shanghai
EXPOSE 20001-20005
RUN docker-php-ext-install pcntl
ENTRYPOINT [ "./zhamao" ]
CMD [ "server" ]

View File

@@ -1 +1 @@
module.exports = [{"title":"ZM","collapsable":true,"children":["ZM/ZMServer"]},{"title":"ZM/API","collapsable":true,"children":["ZM/API/CQ","ZM/API/OneBotV11","ZM/API/ZMRobot","ZM/API/GoCqhttpAPIV11","ZM/API/TuringAPI"]},{"title":"ZM/API/Proxies/Bot","collapsable":true,"children":["ZM/API/Proxies/Bot/AllBotsProxy","ZM/API/Proxies/Bot/AllGroupsProxy","ZM/API/Proxies/Bot/AbstractBotProxy"]},{"title":"ZM/Annotation/Swoole","collapsable":true,"children":["ZM/Annotation/Swoole/OnSwooleEventBase"]},{"title":"ZM/Command","collapsable":true,"children":["ZM/Command/CheckConfigCommand"]},{"title":"ZM/Command/Module","collapsable":true,"children":["ZM/Command/Module/ModuleListCommand","ZM/Command/Module/ModulePackCommand"]},{"title":"ZM/Container","collapsable":true,"children":["ZM/Container/Container","ZM/Container/BoundMethod","ZM/Container/WorkerContainer"]},{"title":"ZM/DB","collapsable":true,"children":["ZM/DB/InsertBody","ZM/DB/Table","ZM/DB/DB","ZM/DB/DeleteBody","ZM/DB/SelectBody","ZM/DB/UpdateBody"]},{"title":"ZM/Event","collapsable":true,"children":["ZM/Event/EventTracer","ZM/Event/EventManager","ZM/Event/EventDispatcher"]},{"title":"ZM/Event/SwooleEvent","collapsable":true,"children":["ZM/Event/SwooleEvent/OnMessage","ZM/Event/SwooleEvent/OnTask"]},{"title":"ZM/Http","collapsable":true,"children":["ZM/Http/Response"]},{"title":"ZM/Module","collapsable":true,"children":["ZM/Module/ModuleUnpacker","ZM/Module/ModulePacker","ZM/Module/ModuleBase"]},{"title":"ZM/MySQL","collapsable":true,"children":["ZM/MySQL/MySQLQueryBuilder","ZM/MySQL/MySQLPool","ZM/MySQL/MySQLStatementWrapper","ZM/MySQL/MySQLStatement","ZM/MySQL/MySQLWrapper","ZM/MySQL/MySQLConnection"]},{"title":"ZM/Store","collapsable":true,"children":["ZM/Store/ZMAtomic","ZM/Store/LightCacheInside","ZM/Store/LightCache"]},{"title":"ZM/Store/Redis","collapsable":true,"children":["ZM/Store/Redis/ZMRedis"]},{"title":"ZM/Utils","collapsable":true,"children":["ZM/Utils/SignalListener","ZM/Utils/CoMessage","ZM/Utils/Terminal","ZM/Utils/MessageUtil","ZM/Utils/DataProvider","ZM/Utils/HttpUtil","ZM/Utils/ReflectionUtil","ZM/Utils/CommandInfoUtil"]},{"title":"ZM/Utils/Manager","collapsable":true,"children":["ZM/Utils/Manager/WorkerManager","ZM/Utils/Manager/ModuleManager","ZM/Utils/Manager/CronManager"]}]
module.exports = [{"title":"ZM","collapsable":true,"children":["ZM/ZMApplication","ZM/ConsoleApplication"]},{"title":"ZM/Annotation","collapsable":true,"children":["ZM/Annotation/AnnotationHandler","ZM/Annotation/AnnotationMap","ZM/Annotation/AnnotationParser","ZM/Annotation/AnnotationBase"]},{"title":"ZM/Command","collapsable":true,"children":["ZM/Command/InitCommand","ZM/Command/Command","ZM/Command/ProxyServerCommand","ZM/Command/BuildCommand"]},{"title":"ZM/Command/Server","collapsable":true,"children":["ZM/Command/Server/ServerStartCommand","ZM/Command/Server/ServerCommand"]},{"title":"ZM/Config","collapsable":true,"children":["ZM/Config/ZMConfig","ZM/Config/ConfigTracer"]},{"title":"ZM/Container","collapsable":true,"children":["ZM/Container/ContainerServicesProvider","ZM/Container/BoundMethod","ZM/Container/WorkerContainer","ZM/Container/Container"]},{"title":"ZM/Context","collapsable":true,"children":["ZM/Context/Context"]},{"title":"ZM/Event","collapsable":true,"children":["ZM/Event/EventProvider","ZM/Event/EventDispatcher"]},{"title":"ZM/Event/Listener","collapsable":true,"children":["ZM/Event/Listener/MasterEventListener","ZM/Event/Listener/ManagerEventListener","ZM/Event/Listener/HttpEventListener","ZM/Event/Listener/WorkerEventListener","ZM/Event/Listener/SignalListener","ZM/Event/Listener/WSEventListener"]},{"title":"ZM/Middleware","collapsable":true,"children":["ZM/Middleware/MiddlewareHandler","ZM/Middleware/Pipeline"]},{"title":"ZM/Plugin","collapsable":true,"children":["ZM/Plugin/PluginManager","ZM/Plugin/OneBot12Adapter"]},{"title":"ZM/Process","collapsable":true,"children":["ZM/Process/ProcessStateManager"]},{"title":"ZM/Store","collapsable":true,"children":["ZM/Store/FileSystem"]},{"title":"ZM/Store/Database","collapsable":true,"children":["ZM/Store/Database/DBWrapper","ZM/Store/Database/DBStatement","ZM/Store/Database/DBPool","ZM/Store/Database/DBStatementWrapper","ZM/Store/Database/DBConnection","ZM/Store/Database/DBQueryBuilder"]},{"title":"ZM/Store/Lock","collapsable":true,"children":["ZM/Store/Lock/FileLock"]},{"title":"ZM/Utils","collapsable":true,"children":["ZM/Utils/EasterEgg","ZM/Utils/ConnectionUtil","ZM/Utils/ReflectionUtil","ZM/Utils/ZMUtil","ZM/Utils/HttpUtil"]}]

View File

@@ -0,0 +1,293 @@
# ZM\Adapters\OneBot11Adapter
## getName
```php
public function getName(): string
```
### 描述
{@inheritDoc}
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | |
## getVersion
```php
public function getVersion(): string
```
### 描述
{@inheritDoc}
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | |
## handleIncomingRequest
```php
public function handleIncomingRequest(ZM\Context\ContextInterface $context): void
```
### 描述
{@inheritDoc}
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| context | ZM\Context\ContextInterface | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## handleAPIResponse
```php
public function handleAPIResponse(array $data, ContextInterface $context): void
```
### 描述
处理 API 响应
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| data | array | 数据 |
| context | ContextInterface | 上下文 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## handleMessageEvent
```php
public function handleMessageEvent(array $data, ContextInterface $context): void
```
### 描述
处理消息事件
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| data | array | 消息数据 |
| context | ContextInterface | 上下文 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## handleMetaEvent
```php
public function handleMetaEvent(array $data, ContextInterface $context): void
```
### 描述
处理元事件
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| data | array | 消息数据 |
| context | ContextInterface | 上下文 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## handleNoticeEvent
```php
public function handleNoticeEvent(array $data, ContextInterface $context): void
```
### 描述
处理通知事件
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| data | array | 消息数据 |
| context | ContextInterface | 上下文 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## handleRequestEvent
```php
public function handleRequestEvent(array $data, ContextInterface $context): void
```
### 描述
处理请求事件
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| data | array | 消息数据 |
| context | ContextInterface | 上下文 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## handleBeforeEvent
```php
public function handleBeforeEvent(array $data, string $time): ZM\Event\EventDispatcher
```
### 描述
处理前置事件
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| data | array | 消息数据 |
| time | string | 执行时机 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZM\Event\EventDispatcher | |
## handleAfterEvent
```php
public function handleAfterEvent(array $data): ZM\Event\EventDispatcher
```
### 描述
处理后置事件
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| data | array | 消息数据 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZM\Event\EventDispatcher | |
## isAPIResponse
```php
public function isAPIResponse(array $data): bool
```
### 描述
判断是否为 API 回调
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| data | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## isEvent
```php
public function isEvent(array $data): bool
```
### 描述
判断是否为事件
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| data | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## isMetaEvent
```php
public function isMetaEvent(array $data): bool
```
### 描述
判断是否为元事件
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| data | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |

View File

@@ -1 +1,23 @@
# ZM\Annotation\AnnotationBase
# ZM\Annotation\AnnotationBase
## on
```php
public function on(mixed $method): ZM\Annotation\AnnotationBase
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| method | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZM\Annotation\AnnotationBase | |

View File

@@ -0,0 +1,174 @@
# ZM\Annotation\AnnotationHandler
## __construct
```php
public function __construct(string $annotation_class): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| annotation_class | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## interrupt
```php
public function interrupt(mixed $return_var): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| return_var | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## setRuleCallback
```php
public function setRuleCallback(callable $rule): ZM\Annotation\AnnotationHandler
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| rule | callable | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZM\Annotation\AnnotationHandler | |
## setReturnCallback
```php
public function setReturnCallback(callable $return): ZM\Annotation\AnnotationHandler
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| return | callable | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZM\Annotation\AnnotationHandler | |
## handleAll
```php
public function handleAll(mixed $params): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| params | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## handle
```php
public function handle(ZM\Annotation\AnnotationBase $v, callable $rule_callback, mixed $args): bool
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| v | ZM\Annotation\AnnotationBase | |
| rule_callback | callable | |
| args | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## getStatus
```php
public function getStatus(): int
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |
## getReturnVal
```php
public function getReturnVal(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,40 @@
# ZM\Annotation\AnnotationMap
## loadAnnotationByParser
```php
public function loadAnnotationByParser(ZM\Annotation\AnnotationParser $parser): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| parser | ZM\Annotation\AnnotationParser | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## sortAnnotationList
```php
public function sortAnnotationList(): void
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |

View File

@@ -3,12 +3,18 @@
## __construct
```php
public function __construct(): mixed
public function __construct(bool $with_internal_parsers): mixed
```
### 描述
AnnotationParser constructor.
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| with_internal_parsers | bool | |
### 返回
@@ -17,21 +23,62 @@ AnnotationParser constructor.
| mixed | |
## registerMods
## addSpecialParser
```php
public function registerMods(): mixed
public function addSpecialParser(string $class_name, callable $callback): void
```
### 描述
注册各个模块类的注解和模块level的排序
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| class_name | string | |
| callback | callable | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
| void | |
## parseAll
```php
public function parseAll(): void
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## generateAnnotationList
```php
public function generateAnnotationList(): array
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## addRegisterPath
@@ -48,8 +95,8 @@ public function addRegisterPath(string $path, string $indoor_name): mixed
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| path | string | 注册解析注解的路径 |
| indoor_name | string | 起始命名空间的名称 |
| path | string | |
| indoor_name | string | |
### 返回
@@ -58,10 +105,44 @@ public function addRegisterPath(string $path, string $indoor_name): mixed
| mixed | |
## sortByLevel
## getUsedTime
```php
public function sortByLevel(array $events, string $class_name, string $prefix): mixed
public function getUsedTime(): float
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| float | |
## getAnnotationMap
```php
public function getAnnotationMap(): array
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## addRouteAnnotation
```php
public function addRouteAnnotation(ZM\Annotation\Http\Route $vss, array $same_method_annotations): mixed
```
### 描述
@@ -72,26 +153,8 @@ public function sortByLevel(array $events, string $class_name, string $prefix):
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| events | array | 需要排序的 |
| class_name | string | 排序的类名 |
| prefix | string | 前缀 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## verifyMiddlewares
```php
public function verifyMiddlewares(): mixed
```
### 描述
作者很懒,什么也没有说
| vss | ZM\Annotation\Http\Route | |
| same_method_annotations | array | |
### 返回

View File

@@ -1 +1,17 @@
# ZM\Command\BuildCommand
# ZM\Command\BuildCommand
## configure
```php
public function configure(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -3,7 +3,7 @@
## check
```php
public function check(mixed $remote, mixed $local, Symfony\Component\Console\Output\OutputInterface $out): mixed
public function check(mixed $remote, mixed $local): mixed
```
### 描述
@@ -16,7 +16,6 @@ public function check(mixed $remote, mixed $local, Symfony\Component\Console\Out
| -------- | ---- | ----------- |
| remote | mixed | |
| local | mixed | |
| out | Symfony\Component\Console\Output\OutputInterface | |
### 返回

View File

@@ -0,0 +1,226 @@
# ZM\Command\Command
## execute
```php
public function execute(Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output): int
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| input | Symfony\Component\Console\Input\InputInterface | |
| output | Symfony\Component\Console\Output\OutputInterface | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |
## shouldExecute
```php
public function shouldExecute(): bool
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## handle
```php
public function handle(): int
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |
## write
```php
public function write(string $message, bool $newline): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| message | string | |
| newline | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## info
```php
public function info(string $message, bool $newline): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| message | string | |
| newline | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## error
```php
public function error(string $message, bool $newline): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| message | string | |
| newline | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## comment
```php
public function comment(string $message, bool $newline): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| message | string | |
| newline | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## question
```php
public function question(string $message, bool $newline): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| message | string | |
| newline | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## detail
```php
public function detail(string $message, bool $newline): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| message | string | |
| newline | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## section
```php
public function section(string $message, callable $callback): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| message | string | |
| callback | callable | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |

View File

@@ -1 +1,40 @@
# ZM\Command\InitCommand
# ZM\Command\InitCommand
## setBasePath
```php
public function setBasePath(): void
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## extractFile
```php
public function extractFile(string $file): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| file | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |

View File

@@ -0,0 +1,41 @@
# ZM\Command\ProxyServerCommand
## configure
```php
public function configure(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## startSocksProxy
```php
public function startSocksProxy(string $address, mixed $port): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| address | string | |
| port | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,24 @@
# ZM\Command\Server\ServerCommand
## execute
```php
public function execute(Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output): int
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| input | Symfony\Component\Console\Input\InputInterface | |
| output | Symfony\Component\Console\Output\OutputInterface | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |

View File

@@ -0,0 +1,24 @@
# ZM\Command\Server\ServerStartCommand
## execute
```php
public function execute(Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output): int
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| input | Symfony\Component\Console\Input\InputInterface | |
| output | Symfony\Component\Console\Output\OutputInterface | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |

View File

@@ -0,0 +1,73 @@
# ZM\Config\ConfigTracer
## addTracesOf
```php
public function addTracesOf(string $group, array $traces, string $source): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| group | string | |
| traces | array | |
| source | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## getTraceOf
```php
public function getTraceOf(string $key): string
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| key | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | |
## flatten
```php
public function flatten(string $prefix, array $array, string $source): array
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| prefix | string | |
| array | array | |
| source | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |

View File

@@ -0,0 +1,348 @@
# ZM\Config\ZMConfig
## __construct
```php
public function __construct(array $config_paths, string $environment): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| config_paths | array | |
| environment | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## loadFiles
```php
public function loadFiles(): void
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## merge
```php
public function merge(string $key, array $config): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| key | string | |
| config | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## get
```php
public function get(string $key, mixed $default): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| key | string | |
| default | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## set
```php
public function set(mixed $key, mixed $value): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| key | mixed | |
| value | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## addConfigPath
```php
public function addConfigPath(string $path): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| path | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## getEnvironment
```php
public function getEnvironment(): string
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | |
## setEnvironment
```php
public function setEnvironment(string $environment): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| environment | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## reload
```php
public function reload(): void
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## getHolder
```php
public function getHolder(): OneBot\Config\Config
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| OneBot\Config\Config | |
## getTrace
```php
public function getTrace(string $key): string
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| key | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | |
## getFileMeta
```php
public function getFileMeta(string $name): array
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## getFileLoadType
```php
public function getFileLoadType(string $name): string
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | |
## shouldLoadFile
```php
public function shouldLoadFile(string $path): bool
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| path | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## loadConfigFromPath
```php
public function loadConfigFromPath(string $path): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| path | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## getInstance
```php
public function getInstance(mixed $args): object
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| args | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| object | |

View File

@@ -1,9 +1,9 @@
# ZM\ConsoleApplication
## __construct
## run
```php
public function __construct(string $name): mixed
public function run(Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output): int
```
### 描述
@@ -14,33 +14,11 @@ public function __construct(string $name): mixed
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | |
| input | Symfony\Component\Console\Input\InputInterface | |
| output | Symfony\Component\Console\Output\OutputInterface | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## initEnv
```php
public function initEnv(string $with_default_cmd): ZM\ConsoleApplication
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| with_default_cmd | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZM\ConsoleApplication | |
| int | |

View File

@@ -3,19 +3,19 @@
## call
```php
public function call(Container $container, callable|string $callback, array $parameters, string $default_method): mixed
public function call(ZM\Container\ContainerInterface $container, mixed $callback, array $parameters, string $default_method): mixed
```
### 描述
调用指定闭包、类方法并注入依赖
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| container | Container | |
| callback | callable|string | |
| container | ZM\Container\ContainerInterface | |
| callback | mixed | |
| parameters | array | |
| default_method | string | |
@@ -29,19 +29,19 @@ public function call(Container $container, callable|string $callback, array $par
## getMethodDependencies
```php
public function getMethodDependencies(callable|string $callback, ZM\Container\ContainerInterface $container, array $parameters): array
public function getMethodDependencies(ZM\Container\ContainerInterface $container, mixed $callback, array $parameters): array
```
### 描述
Get all dependencies for a given method.
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| callback | callable|string | |
| container | ZM\Container\ContainerInterface | |
| callback | mixed | |
| parameters | array | |
### 返回
@@ -59,7 +59,7 @@ public function addDependencyForCallParameter(ZM\Container\ContainerInterface $c
### 描述
Get the dependency for the given call parameter.
作者很懒,什么也没有说
### 参数

View File

@@ -8,7 +8,7 @@ public function getParent(): ZM\Container\ContainerInterface
### 描述
获取父容器
作者很懒,什么也没有说
### 返回
@@ -25,16 +25,13 @@ public function has(string $id): bool
### 描述
Returns true if the container can return an entry for the given identifier.
Returns false otherwise.
`has($id)` returning true does not mean that `get($id)` will not throw an exception.
It does however mean that `get($id)` will not throw a `NotFoundExceptionInterface`.
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| id | string | identifier of the entry to look for |
| id | string | |
### 返回
@@ -46,42 +43,48 @@ It does however mean that `get($id)` will not throw a `NotFoundExceptionInterfac
## make
```php
public function make(class-string<T> $abstract, array $parameters): Closure|mixed|T
public function make(string $abstract, array $parameters): mixed
```
### 描述
获取一个绑定的实例
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | class-string<T> | 类或接口名 |
| parameters | array | 参数 |
| abstract | string | |
| parameters | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Closure|mixed|T | 实例 |
| mixed | |
## getInstance
```php
public function getInstance(): static
public function getInstance(mixed $args): object
```
### 描述
获取类实例
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| args | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| static | |
| object | |
## bound
@@ -92,13 +95,13 @@ public function bound(string $abstract): bool
### 描述
判断对应的类或接口是否已经注册
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| abstract | string | |
### 返回
@@ -115,19 +118,19 @@ public function getAlias(string $abstract): string
### 描述
获取类别名(如存在)
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| abstract | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | 别名,不存在时返回传入的类或接口名 |
| string | |
## alias
@@ -138,14 +141,14 @@ public function alias(string $abstract, string $alias): void
### 描述
注册一个类别名
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| alias | string | 别名 |
| abstract | string | |
| alias | string | |
### 返回
@@ -157,20 +160,20 @@ public function alias(string $abstract, string $alias): void
## bind
```php
public function bind(string $abstract, null|Closure|string $concrete, bool $shared): void
public function bind(string $abstract, mixed $concrete, bool $shared): void
```
### 描述
注册绑定
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| concrete | null|Closure|string | 返回类实例的闭包,或是类名 |
| shared | bool | 是否共享 |
| abstract | string | |
| concrete | mixed | |
| shared | bool | |
### 返回
@@ -182,21 +185,20 @@ public function bind(string $abstract, null|Closure|string $concrete, bool $shar
## bindIf
```php
public function bindIf(string $abstract, null|Closure|string $concrete, bool $shared): void
public function bindIf(string $abstract, mixed $concrete, bool $shared): void
```
### 描述
注册绑定
在已经绑定时不会重复注册
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| concrete | null|Closure|string | 返回类实例的闭包,或是类名 |
| shared | bool | 是否共享 |
| abstract | string | |
| concrete | mixed | |
| shared | bool | |
### 返回
@@ -208,19 +210,19 @@ public function bindIf(string $abstract, null|Closure|string $concrete, bool $sh
## singleton
```php
public function singleton(string $abstract, null|Closure|string $concrete): void
public function singleton(string $abstract, mixed $concrete): void
```
### 描述
注册一个单例绑定
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| concrete | null|Closure|string | 返回类实例的闭包,或是类名 |
| abstract | string | |
| concrete | mixed | |
### 返回
@@ -232,20 +234,19 @@ public function singleton(string $abstract, null|Closure|string $concrete): void
## singletonIf
```php
public function singletonIf(string $abstract, null|Closure|string $concrete): void
public function singletonIf(string $abstract, mixed $concrete): void
```
### 描述
注册一个单例绑定
在已经绑定时不会重复注册
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| concrete | null|Closure|string | 返回类实例的闭包,或是类名 |
| abstract | string | |
| concrete | mixed | |
### 返回
@@ -262,14 +263,14 @@ public function instance(string $abstract, mixed $instance): mixed
### 描述
注册一个已有的实例,效果等同于单例绑定
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| instance | mixed | 实例 |
| abstract | string | |
| instance | mixed | |
### 返回
@@ -286,13 +287,13 @@ public function factory(string $abstract): Closure
### 描述
获取一个解析对应类实例的闭包
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| abstract | string | |
### 返回
@@ -309,7 +310,7 @@ public function flush(): void
### 描述
清除所有绑定和实例
作者很懒,什么也没有说
### 返回
@@ -321,42 +322,42 @@ public function flush(): void
## traitMake
```php
public function traitMake(class-string<T> $abstract, array $parameters): Closure|mixed|T
public function traitMake(string $abstract, array $parameters): mixed
```
### 描述
获取一个绑定的实例
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | class-string<T> | 类或接口名 |
| parameters | array | 参数 |
| abstract | string | |
| parameters | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Closure|mixed|T | 实例 |
| mixed | |
## build
```php
public function build(Closure|string $concrete): mixed
public function build(mixed $concrete): mixed
```
### 描述
实例化具体的类实例
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| concrete | Closure|string | 类名或对应的闭包 |
| concrete | mixed | |
### 返回
@@ -368,20 +369,20 @@ public function build(Closure|string $concrete): mixed
## call
```php
public function call(callable|string $callback, array $parameters, null|string $default_method): mixed
public function call(mixed $callback, array $parameters, string $default_method): mixed
```
### 描述
调用对应的方法,并自动注入依赖
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| callback | callable|string | 对应的方法 |
| parameters | array | 参数 |
| default_method | null|string | 默认方法 |
| callback | mixed | |
| parameters | array | |
| default_method | string | |
### 返回
@@ -398,19 +399,19 @@ public function get(string $id): mixed
### 描述
Finds an entry of the container by its identifier and returns it.
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| id | string | identifier of the entry to look for * |
| id | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | entry |
| mixed | |
## extend
@@ -421,14 +422,14 @@ public function extend(string $abstract, Closure $closure): void
### 描述
扩展一个类或接口
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| closure | Closure | 扩展闭包 |
| abstract | string | |
| closure | Closure | |
### 返回
@@ -445,7 +446,7 @@ public function getLogPrefix(): string
### 描述
获取日志前缀
作者很懒,什么也没有说
### 返回
@@ -462,7 +463,7 @@ public function setLogPrefix(string $prefix): void
### 描述
设置日志前缀
作者很懒,什么也没有说
### 参数
@@ -480,24 +481,24 @@ public function setLogPrefix(string $prefix): void
## getExtenders
```php
public function getExtenders(string $abstract): Closure[]
public function getExtenders(string $abstract): array
```
### 描述
获取对应类型的所有扩展器
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| abstract | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Closure[] | |
| array | |
## isAlias
@@ -508,7 +509,7 @@ public function isAlias(string $name): bool
### 描述
判断传入的是否为别名
作者很懒,什么也没有说
### 参数
@@ -531,13 +532,13 @@ public function dropStaleInstances(string $abstract): void
### 描述
抛弃所有过时的实例和别名
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| abstract | string | |
### 返回
@@ -554,14 +555,14 @@ public function getClosure(string $abstract, string $concrete): Closure
### 描述
获取一个解析对应类的闭包
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| concrete | string | 实际类名 |
| abstract | string | |
| concrete | string | |
### 返回
@@ -578,7 +579,7 @@ public function getLastParameterOverride(): array
### 描述
获取最后一次的覆盖参数
作者很懒,什么也没有说
### 返回
@@ -595,7 +596,7 @@ public function notInstantiable(string $concrete, string $reason): void
### 描述
抛出实例化异常
作者很懒,什么也没有说
### 参数
@@ -614,18 +615,18 @@ public function notInstantiable(string $concrete, string $reason): void
## resolveDependencies
```php
public function resolveDependencies(ReflectionParameter[] $dependencies): array
public function resolveDependencies(array $dependencies): array
```
### 描述
解析依赖
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| dependencies | ReflectionParameter[] | |
| dependencies | array | |
### 返回
@@ -642,7 +643,7 @@ public function hasParameterOverride(ReflectionParameter $parameter): bool
### 描述
判断传入的参数是否存在覆盖参数
作者很懒,什么也没有说
### 参数
@@ -665,7 +666,7 @@ public function getParameterOverride(ReflectionParameter $parameter): mixed
### 描述
获取覆盖参数
作者很懒,什么也没有说
### 参数
@@ -688,7 +689,7 @@ public function hasParameterTypeOverride(ReflectionParameter $parameter): bool
### 描述
判断传入的参数是否存在临时注入的参数
作者很懒,什么也没有说
### 参数
@@ -711,7 +712,7 @@ public function getParameterTypeOverride(ReflectionParameter $parameter): mixed
### 描述
获取临时注入的参数
作者很懒,什么也没有说
### 参数
@@ -734,7 +735,7 @@ public function resolvePrimitive(ReflectionParameter $parameter): mixed
### 描述
解析基本类型
作者很懒,什么也没有说
### 参数
@@ -746,7 +747,7 @@ public function resolvePrimitive(ReflectionParameter $parameter): mixed
| 类型 | 描述 |
| ---- | ----------- |
| mixed | 对应类型的默认值 |
| mixed | |
## resolveClass
@@ -757,7 +758,7 @@ public function resolveClass(ReflectionParameter $parameter): mixed
### 描述
解析类
作者很懒,什么也没有说
### 参数
@@ -775,24 +776,24 @@ public function resolveClass(ReflectionParameter $parameter): mixed
## getConcrete
```php
public function getConcrete(string $abstract): Closure|string
public function getConcrete(string $abstract): mixed
```
### 描述
获取类名的实际类型
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| abstract | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Closure|string | |
| mixed | |
## isBuildable
@@ -803,14 +804,14 @@ public function isBuildable(mixed $concrete, string $abstract): bool
### 描述
判断传入的实际类型是否可以构造
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| concrete | mixed | 实际类型 |
| abstract | string | 类或接口名 |
| concrete | mixed | |
| abstract | string | |
### 返回
@@ -827,13 +828,13 @@ public function isShared(string $abstract): bool
### 描述
判断传入的类型是否为共享实例
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| abstract | string | |
### 返回
@@ -850,7 +851,7 @@ public function shouldLog(): bool
### 描述
判断是否输出日志
作者很懒,什么也没有说
### 返回
@@ -867,7 +868,7 @@ public function log(string $message): void
### 描述
记录日志(自动附加容器日志前缀)
作者很懒,什么也没有说
### 参数

View File

@@ -0,0 +1,134 @@
# ZM\Container\ContainerServicesProvider
## registerServices
```php
public function registerServices(string $scope, mixed $params): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| scope | string | |
| params | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## cleanup
```php
public function cleanup(): void
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## registerGlobalServices
```php
public function registerGlobalServices(ZM\Container\ContainerInterface $container): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| container | ZM\Container\ContainerInterface | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## registerRequestServices
```php
public function registerRequestServices(ZM\Container\ContainerInterface $container, OneBot\Driver\Event\Http\HttpRequestEvent $event): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| container | ZM\Container\ContainerInterface | |
| event | OneBot\Driver\Event\Http\HttpRequestEvent | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## registerMessageServices
```php
public function registerMessageServices(ZM\Container\ContainerInterface $container): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| container | ZM\Container\ContainerInterface | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## registerConnectionServices
```php
public function registerConnectionServices(ZM\Container\ContainerInterface $container): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| container | ZM\Container\ContainerInterface | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |

View File

@@ -3,18 +3,24 @@
## getInstance
```php
public function getInstance(): static
public function getInstance(mixed $args): object
```
### 描述
获取类实例
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| args | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| static | |
| object | |
## bound
@@ -25,13 +31,13 @@ public function bound(string $abstract): bool
### 描述
判断对应的类或接口是否已经注册
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| abstract | string | |
### 返回
@@ -48,19 +54,19 @@ public function getAlias(string $abstract): string
### 描述
获取类别名(如存在)
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| abstract | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | 别名,不存在时返回传入的类或接口名 |
| string | |
## alias
@@ -71,14 +77,14 @@ public function alias(string $abstract, string $alias): void
### 描述
注册一个类别名
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| alias | string | 别名 |
| abstract | string | |
| alias | string | |
### 返回
@@ -90,20 +96,20 @@ public function alias(string $abstract, string $alias): void
## bind
```php
public function bind(string $abstract, null|Closure|string $concrete, bool $shared): void
public function bind(string $abstract, mixed $concrete, bool $shared): void
```
### 描述
注册绑定
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| concrete | null|Closure|string | 返回类实例的闭包,或是类名 |
| shared | bool | 是否共享 |
| abstract | string | |
| concrete | mixed | |
| shared | bool | |
### 返回
@@ -115,21 +121,20 @@ public function bind(string $abstract, null|Closure|string $concrete, bool $shar
## bindIf
```php
public function bindIf(string $abstract, null|Closure|string $concrete, bool $shared): void
public function bindIf(string $abstract, mixed $concrete, bool $shared): void
```
### 描述
注册绑定
在已经绑定时不会重复注册
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| concrete | null|Closure|string | 返回类实例的闭包,或是类名 |
| shared | bool | 是否共享 |
| abstract | string | |
| concrete | mixed | |
| shared | bool | |
### 返回
@@ -141,19 +146,19 @@ public function bindIf(string $abstract, null|Closure|string $concrete, bool $sh
## singleton
```php
public function singleton(string $abstract, null|Closure|string $concrete): void
public function singleton(string $abstract, mixed $concrete): void
```
### 描述
注册一个单例绑定
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| concrete | null|Closure|string | 返回类实例的闭包,或是类名 |
| abstract | string | |
| concrete | mixed | |
### 返回
@@ -165,20 +170,19 @@ public function singleton(string $abstract, null|Closure|string $concrete): void
## singletonIf
```php
public function singletonIf(string $abstract, null|Closure|string $concrete): void
public function singletonIf(string $abstract, mixed $concrete): void
```
### 描述
注册一个单例绑定
在已经绑定时不会重复注册
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| concrete | null|Closure|string | 返回类实例的闭包,或是类名 |
| abstract | string | |
| concrete | mixed | |
### 返回
@@ -195,14 +199,14 @@ public function instance(string $abstract, mixed $instance): mixed
### 描述
注册一个已有的实例,效果等同于单例绑定
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| instance | mixed | 实例 |
| abstract | string | |
| instance | mixed | |
### 返回
@@ -219,13 +223,13 @@ public function factory(string $abstract): Closure
### 描述
获取一个解析对应类实例的闭包
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| abstract | string | |
### 返回
@@ -242,7 +246,7 @@ public function flush(): void
### 描述
清除所有绑定和实例
作者很懒,什么也没有说
### 返回
@@ -254,42 +258,42 @@ public function flush(): void
## make
```php
public function make(class-string<T> $abstract, array $parameters): Closure|mixed|T
public function make(string $abstract, array $parameters): mixed
```
### 描述
获取一个绑定的实例
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | class-string<T> | 类或接口名 |
| parameters | array | 参数 |
| abstract | string | |
| parameters | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Closure|mixed|T | 实例 |
| mixed | |
## build
```php
public function build(Closure|string $concrete): mixed
public function build(mixed $concrete): mixed
```
### 描述
实例化具体的类实例
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| concrete | Closure|string | 类名或对应的闭包 |
| concrete | mixed | |
### 返回
@@ -301,20 +305,20 @@ public function build(Closure|string $concrete): mixed
## call
```php
public function call(callable|string $callback, array $parameters, null|string $default_method): mixed
public function call(mixed $callback, array $parameters, string $default_method): mixed
```
### 描述
调用对应的方法,并自动注入依赖
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| callback | callable|string | 对应的方法 |
| parameters | array | 参数 |
| default_method | null|string | 默认方法 |
| callback | mixed | |
| parameters | array | |
| default_method | string | |
### 返回
@@ -331,19 +335,19 @@ public function get(string $id): mixed
### 描述
Finds an entry of the container by its identifier and returns it.
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| id | string | identifier of the entry to look for * |
| id | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | entry |
| mixed | |
## has
@@ -354,16 +358,13 @@ public function has(string $id): bool
### 描述
Returns true if the container can return an entry for the given identifier.
Returns false otherwise.
`has($id)` returning true does not mean that `get($id)` will not throw an exception.
It does however mean that `get($id)` will not throw a `NotFoundExceptionInterface`.
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| id | string | identifier of the entry to look for |
| id | string | |
### 返回
@@ -380,14 +381,14 @@ public function extend(string $abstract, Closure $closure): void
### 描述
扩展一个类或接口
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| closure | Closure | 扩展闭包 |
| abstract | string | |
| closure | Closure | |
### 返回
@@ -404,7 +405,7 @@ public function getLogPrefix(): string
### 描述
获取日志前缀
作者很懒,什么也没有说
### 返回
@@ -421,7 +422,7 @@ public function setLogPrefix(string $prefix): void
### 描述
设置日志前缀
作者很懒,什么也没有说
### 参数
@@ -439,24 +440,24 @@ public function setLogPrefix(string $prefix): void
## getExtenders
```php
public function getExtenders(string $abstract): Closure[]
public function getExtenders(string $abstract): array
```
### 描述
获取对应类型的所有扩展器
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| abstract | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Closure[] | |
| array | |
## isAlias
@@ -467,7 +468,7 @@ public function isAlias(string $name): bool
### 描述
判断传入的是否为别名
作者很懒,什么也没有说
### 参数
@@ -490,13 +491,13 @@ public function dropStaleInstances(string $abstract): void
### 描述
抛弃所有过时的实例和别名
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| abstract | string | |
### 返回
@@ -513,14 +514,14 @@ public function getClosure(string $abstract, string $concrete): Closure
### 描述
获取一个解析对应类的闭包
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| concrete | string | 实际类名 |
| abstract | string | |
| concrete | string | |
### 返回
@@ -537,7 +538,7 @@ public function getLastParameterOverride(): array
### 描述
获取最后一次的覆盖参数
作者很懒,什么也没有说
### 返回
@@ -554,7 +555,7 @@ public function notInstantiable(string $concrete, string $reason): void
### 描述
抛出实例化异常
作者很懒,什么也没有说
### 参数
@@ -573,18 +574,18 @@ public function notInstantiable(string $concrete, string $reason): void
## resolveDependencies
```php
public function resolveDependencies(ReflectionParameter[] $dependencies): array
public function resolveDependencies(array $dependencies): array
```
### 描述
解析依赖
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| dependencies | ReflectionParameter[] | |
| dependencies | array | |
### 返回
@@ -601,7 +602,7 @@ public function hasParameterOverride(ReflectionParameter $parameter): bool
### 描述
判断传入的参数是否存在覆盖参数
作者很懒,什么也没有说
### 参数
@@ -624,7 +625,7 @@ public function getParameterOverride(ReflectionParameter $parameter): mixed
### 描述
获取覆盖参数
作者很懒,什么也没有说
### 参数
@@ -647,7 +648,7 @@ public function hasParameterTypeOverride(ReflectionParameter $parameter): bool
### 描述
判断传入的参数是否存在临时注入的参数
作者很懒,什么也没有说
### 参数
@@ -670,7 +671,7 @@ public function getParameterTypeOverride(ReflectionParameter $parameter): mixed
### 描述
获取临时注入的参数
作者很懒,什么也没有说
### 参数
@@ -693,7 +694,7 @@ public function resolvePrimitive(ReflectionParameter $parameter): mixed
### 描述
解析基本类型
作者很懒,什么也没有说
### 参数
@@ -705,7 +706,7 @@ public function resolvePrimitive(ReflectionParameter $parameter): mixed
| 类型 | 描述 |
| ---- | ----------- |
| mixed | 对应类型的默认值 |
| mixed | |
## resolveClass
@@ -716,7 +717,7 @@ public function resolveClass(ReflectionParameter $parameter): mixed
### 描述
解析类
作者很懒,什么也没有说
### 参数
@@ -734,24 +735,24 @@ public function resolveClass(ReflectionParameter $parameter): mixed
## getConcrete
```php
public function getConcrete(string $abstract): Closure|string
public function getConcrete(string $abstract): mixed
```
### 描述
获取类名的实际类型
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| abstract | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Closure|string | |
| mixed | |
## isBuildable
@@ -762,14 +763,14 @@ public function isBuildable(mixed $concrete, string $abstract): bool
### 描述
判断传入的实际类型是否可以构造
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| concrete | mixed | 实际类型 |
| abstract | string | 类或接口名 |
| concrete | mixed | |
| abstract | string | |
### 返回
@@ -786,13 +787,13 @@ public function isShared(string $abstract): bool
### 描述
判断传入的类型是否为共享实例
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| abstract | string | 类或接口名 |
| abstract | string | |
### 返回
@@ -809,7 +810,7 @@ public function shouldLog(): bool
### 描述
判断是否输出日志
作者很懒,什么也没有说
### 返回
@@ -826,7 +827,7 @@ public function log(string $message): void
### 描述
记录日志(自动附加容器日志前缀)
作者很懒,什么也没有说
### 参数

View File

@@ -1,9 +1,9 @@
# ZM\Context\Context
## getServer
## getRequest
```php
public function getServer(): Server
public function getRequest(): Psr\Http\Message\ServerRequestInterface
```
### 描述
@@ -14,13 +14,13 @@ public function getServer(): Server
| 类型 | 描述 |
| ---- | ----------- |
| Server | |
| Psr\Http\Message\ServerRequestInterface | |
## getData
## getHttpRequestEvent
```php
public function getData(): mixed
public function getHttpRequestEvent(): OneBot\Driver\Event\Http\HttpRequestEvent
```
### 描述
@@ -29,189 +29,29 @@ public function getData(): mixed
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| OneBot\Driver\Event\Http\HttpRequestEvent | |
## withResponse
```php
public function withResponse(Psr\Http\Message\ResponseInterface $response): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| response | Psr\Http\Message\ResponseInterface | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## reply
```php
public function reply(array|string $msg, bool|callable|Closure $yield): array|bool
```
### 描述
only can used by cq->message event function
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| msg | array|string | 要回复的消息 |
| yield | bool|callable|Closure | 是否协程挂起true是否绑定异步事件Closure |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array|bool | 返回API调用结果 |
## finalReply
```php
public function finalReply(array|string $msg, bool $yield): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| msg | array|string | 要回复的消息 |
| yield | bool | 是否协程挂起true是否绑定异步事件Closure |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## waitMessage
```php
public function waitMessage(string $prompt, int $timeout, string $timeout_prompt): string
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| prompt | string | |
| timeout | int | |
| timeout_prompt | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | 返回用户输入的内容 |
## getArgs
```php
public function getArgs(int|string $mode, string|Stringable $prompt_msg): float|int|string
```
### 描述
根据选定的模式获取消息参数
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| mode | int|string | 获取的模式 |
| prompt_msg | string|Stringable | 提示语回复 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| float|int|string | |
## getNextArg
```php
public function getNextArg(string $prompt_msg): int|mixed|string
```
### 描述
获取下一个参数
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| prompt_msg | string | 提示语回复 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int|mixed|string | 返回获取的参数 |
## getFullArg
```php
public function getFullArg(string $prompt_msg): int|mixed|string
```
### 描述
获取接下来所有的消息当成一个完整的参数(包含空格)
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| prompt_msg | string | 提示语回复 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int|mixed|string | 返回获取的参数 |
## getNumArg
```php
public function getNumArg(string $prompt_msg): int|mixed|string
```
### 描述
获取下一个数字类型的参数
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| prompt_msg | string | 提示语回复 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int|mixed|string | 返回获取的参数 |
## cloneFromParent
```php
public function cloneFromParent(): ContextInterface
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ContextInterface | 返回上下文 |

View File

@@ -1,9 +1,9 @@
# ZM\Event\EventDispatcher
## interrupt
## getInstance
```php
public function interrupt(mixed $return_var): mixed
public function getInstance(mixed $args): object
```
### 描述
@@ -14,10 +14,10 @@ public function interrupt(mixed $return_var): mixed
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| return_var | mixed | |
| args | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
| object | |

View File

@@ -0,0 +1,117 @@
# ZM\Event\EventProvider
## addEventListener
```php
public function addEventListener(mixed $event, callable $callback, int $level): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| event | mixed | |
| callback | callable | |
| level | int | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getEventListeners
```php
public function getEventListeners(string $event_name): array
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| event_name | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## getListenersForEvent
```php
public function getListenersForEvent(object $event): iterable
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| event | object | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| iterable | |
## sortEvents
```php
public function sortEvents(mixed $name): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getInstance
```php
public function getInstance(mixed $args): object
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| args | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| object | |

View File

@@ -0,0 +1,69 @@
# ZM\Event\Listener\HttpEventListener
## onRequest999
```php
public function onRequest999(OneBot\Driver\Event\Http\HttpRequestEvent $event): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| event | OneBot\Driver\Event\Http\HttpRequestEvent | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## onRequest1
```php
public function onRequest1(OneBot\Driver\Event\Http\HttpRequestEvent $event): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| event | OneBot\Driver\Event\Http\HttpRequestEvent | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## getInstance
```php
public function getInstance(mixed $args): object
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| args | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| object | |

View File

@@ -0,0 +1,57 @@
# ZM\Event\Listener\ManagerEventListener
## onManagerStart
```php
public function onManagerStart(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## onManagerStop
```php
public function onManagerStop(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getInstance
```php
public function getInstance(mixed $args): object
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| args | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| object | |

View File

@@ -0,0 +1,40 @@
# ZM\Event\Listener\MasterEventListener
## onMasterStop
```php
public function onMasterStop(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getInstance
```php
public function getInstance(mixed $args): object
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| args | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| object | |

View File

@@ -0,0 +1,57 @@
# ZM\Event\Listener\SignalListener
## signalWorker
```php
public function signalWorker(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## processKillerPrompt
```php
public function processKillerPrompt(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getInstance
```php
public function getInstance(mixed $args): object
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| args | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| object | |

View File

@@ -0,0 +1,69 @@
# ZM\Event\Listener\WSEventListener
## onWebSocketOpen
```php
public function onWebSocketOpen(OneBot\Driver\Event\WebSocket\WebSocketOpenEvent $event): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| event | OneBot\Driver\Event\WebSocket\WebSocketOpenEvent | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## onWebSocketClose
```php
public function onWebSocketClose(OneBot\Driver\Event\WebSocket\WebSocketCloseEvent $event): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| event | OneBot\Driver\Event\WebSocket\WebSocketCloseEvent | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## getInstance
```php
public function getInstance(mixed $args): object
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| args | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| object | |

View File

@@ -0,0 +1,108 @@
# ZM\Event\Listener\WorkerEventListener
## onWorkerStart999
```php
public function onWorkerStart999(): void
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## onWorkerStop999
```php
public function onWorkerStop999(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## initUserPlugins
```php
public function initUserPlugins(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## dispatchInit
```php
public function dispatchInit(): void
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## initConnectionPool
```php
public function initConnectionPool(): void
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## getInstance
```php
public function getInstance(mixed $args): object
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| args | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| object | |

View File

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

View File

@@ -0,0 +1,112 @@
# ZM\Middleware\MiddlewareHandler
## bindMiddleware
```php
public function bindMiddleware(callable $callback, string $name, array $params): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| callback | callable | |
| name | string | |
| params | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## process
```php
public function process(callable $callback, mixed $args): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| callback | callable | |
| args | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getCurrentCallable
```php
public function getCurrentCallable(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getStackId
```php
public function getStackId(callable $callback): string
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| callback | callable | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | |
## getInstance
```php
public function getInstance(mixed $args): object
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| args | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| object | |

View File

@@ -0,0 +1,69 @@
# ZM\Middleware\Pipeline
## send
```php
public function send(mixed $value): ZM\Middleware\Pipeline
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| value | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZM\Middleware\Pipeline | |
## through
```php
public function through(array $middlewares): ZM\Middleware\Pipeline
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| middlewares | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZM\Middleware\Pipeline | |
## then
```php
public function then(callable $callback): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| callback | callable | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,87 @@
# ZM\Plugin\OneBot12Adapter
## parseBotCommand
```php
public function parseBotCommand(ZM\Annotation\OneBot\BotCommand $command, array $same_method_annotations): bool
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| command | ZM\Annotation\OneBot\BotCommand | |
| same_method_annotations | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## parseCommandArgument
```php
public function parseCommandArgument(): bool
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## handleUnknownWSReverseInput
```php
public function handleUnknownWSReverseInput(OneBot\Driver\Event\WebSocket\WebSocketOpenEvent $event): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| event | OneBot\Driver\Event\WebSocket\WebSocketOpenEvent | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## handleWSReverseInput
```php
public function handleWSReverseInput(OneBot\Driver\Event\WebSocket\WebSocketOpenEvent $event): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| event | OneBot\Driver\Event\WebSocket\WebSocketOpenEvent | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |

View File

@@ -0,0 +1,46 @@
# ZM\Plugin\PluginManager
## addPluginsFromDir
```php
public function addPluginsFromDir(string $dir): int
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| dir | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |
## addPlugin
```php
public function addPlugin(array $meta): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| meta | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |

View File

@@ -0,0 +1,73 @@
# ZM\Process\ProcessStateManager
## removeProcessState
```php
public function removeProcessState(int $type, mixed $id_or_name): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| type | int | |
| id_or_name | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getProcessState
```php
public function getProcessState(int $type, mixed $id_or_name): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| type | int | |
| id_or_name | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## saveProcessState
```php
public function saveProcessState(int $type, mixed $pid, array $data): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| type | int | |
| pid | mixed | |
| data | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,110 @@
# ZM\Store\Database\DBConnection
## prepare
```php
public function prepare(mixed $sql, mixed $options): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| sql | mixed | |
| options | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## query
```php
public function query(mixed $args): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| args | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## exec
```php
public function exec(mixed $sql): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| sql | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## lastInsertId
```php
public function lastInsertId(mixed $name): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getPoolName
```php
public function getPoolName(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,104 @@
# ZM\Store\Database\DBPool
## create
```php
public function create(string $name, array $config): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | |
| config | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## pool
```php
public function pool(string $name): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getAllPools
```php
public function getAllPools(): array
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## destroyPool
```php
public function destroyPool(string $name): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## checkMysqlExtension
```php
public function checkMysqlExtension(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,17 @@
# ZM\Store\Database\DBQueryBuilder
## execute
```php
public function execute(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,17 @@
# ZM\Store\Database\DBStatement
## current
```php
public function current(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,289 @@
# ZM\Store\Database\DBStatementWrapper
## getIterator
```php
public function getIterator(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## columnCount
```php
public function columnCount(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## fetchNumeric
```php
public function fetchNumeric(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## fetchAssociative
```php
public function fetchAssociative(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## fetchOne
```php
public function fetchOne(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## fetchAllNumeric
```php
public function fetchAllNumeric(): array
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## fetchAllAssociative
```php
public function fetchAllAssociative(): array
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## fetchAllKeyValue
```php
public function fetchAllKeyValue(): array
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## fetchAllAssociativeIndexed
```php
public function fetchAllAssociativeIndexed(): array
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## fetchFirstColumn
```php
public function fetchFirstColumn(): array
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## iterateNumeric
```php
public function iterateNumeric(): Traversable
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## iterateAssociative
```php
public function iterateAssociative(): Traversable
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## iterateKeyValue
```php
public function iterateKeyValue(): Traversable
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## iterateAssociativeIndexed
```php
public function iterateAssociativeIndexed(): Traversable
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## iterateColumn
```php
public function iterateColumn(): Traversable
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## rowCount
```php
public function rowCount(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## free
```php
public function free(): void
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |

View File

@@ -0,0 +1,959 @@
# ZM\Store\Database\DBWrapper
## __construct
```php
public function __construct(string $name): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getDatabase
```php
public function getDatabase(): string
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | |
## isAutoCommit
```php
public function isAutoCommit(): bool
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## setAutoCommit
```php
public function setAutoCommit(bool $auto_commit): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| auto_commit | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## fetchAssociative
```php
public function fetchAssociative(string $query, array $params, array $types): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## fetchNumeric
```php
public function fetchNumeric(string $query, array $params, array $types): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## fetchOne
```php
public function fetchOne(string $query, array $params, array $types): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## isTransactionActive
```php
public function isTransactionActive(): bool
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## delete
```php
public function delete(string $table, array $criteria, array $types): int
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| table | string | |
| criteria | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |
## setTransactionIsolation
```php
public function setTransactionIsolation(int $level): int
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| level | int | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |
## getTransactionIsolation
```php
public function getTransactionIsolation(): int
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |
## update
```php
public function update(string $table, array $data, array $criteria, array $types): int
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| table | string | |
| data | array | |
| criteria | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |
## insert
```php
public function insert(string $table, array $data, array $types): int
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| table | string | |
| data | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |
## quoteIdentifier
```php
public function quoteIdentifier(string $str): string
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| str | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | |
## quote
```php
public function quote(mixed $value, mixed $type): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| value | mixed | |
| type | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## fetchAllNumeric
```php
public function fetchAllNumeric(string $query, array $params, array $types): array
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## fetchAllAssociative
```php
public function fetchAllAssociative(string $query, array $params, array $types): array
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## fetchAllKeyValue
```php
public function fetchAllKeyValue(string $query, array $params, array $types): array
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## fetchAllAssociativeIndexed
```php
public function fetchAllAssociativeIndexed(string $query, array $params, array $types): array
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## fetchFirstColumn
```php
public function fetchFirstColumn(string $query, array $params, array $types): array
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## iterateNumeric
```php
public function iterateNumeric(string $query, array $params, array $types): Traversable
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## iterateAssociative
```php
public function iterateAssociative(string $query, array $params, array $types): Traversable
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## iterateKeyValue
```php
public function iterateKeyValue(string $query, array $params, array $types): Traversable
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## iterateAssociativeIndexed
```php
public function iterateAssociativeIndexed(string $query, array $params, array $types): Traversable
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## iterateColumn
```php
public function iterateColumn(string $query, array $params, array $types): Traversable
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## executeQuery
```php
public function executeQuery(string $sql, array $params, array $types, Doctrine\DBAL\Cache\QueryCacheProfile $qcp): ZM\Store\Database\DBStatementWrapper
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| sql | string | |
| params | array | |
| types | array | |
| qcp | Doctrine\DBAL\Cache\QueryCacheProfile | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZM\Store\Database\DBStatementWrapper | |
## executeCacheQuery
```php
public function executeCacheQuery(string $sql, array $params, array $types, Doctrine\DBAL\Cache\QueryCacheProfile $qcp): ZM\Store\Database\DBStatementWrapper
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| sql | string | |
| params | array | |
| types | array | |
| qcp | Doctrine\DBAL\Cache\QueryCacheProfile | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZM\Store\Database\DBStatementWrapper | |
## executeStatement
```php
public function executeStatement(string $sql, array $params, array $types): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| sql | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getTransactionNestingLevel
```php
public function getTransactionNestingLevel(): int
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |
## lastInsertId
```php
public function lastInsertId(string $name): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## transactional
```php
public function transactional(Closure $func): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| func | Closure | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## setNestTransactionsWithSavepoints
```php
public function setNestTransactionsWithSavepoints(bool $nest_transactions_with_savepoints): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| nest_transactions_with_savepoints | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getNestTransactionsWithSavepoints
```php
public function getNestTransactionsWithSavepoints(): bool
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## beginTransaction
```php
public function beginTransaction(): bool
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## commit
```php
public function commit(): bool
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## rollBack
```php
public function rollBack(): bool
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## createSavepoint
```php
public function createSavepoint(string $savepoint): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| savepoint | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## releaseSavepoint
```php
public function releaseSavepoint(string $savepoint): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| savepoint | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## rollbackSavepoint
```php
public function rollbackSavepoint(string $savepoint): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| savepoint | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## setRollbackOnly
```php
public function setRollbackOnly(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## isRollbackOnly
```php
public function isRollbackOnly(): bool
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## createQueryBuilder
```php
public function createQueryBuilder(): ZM\Store\Database\DBQueryBuilder
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZM\Store\Database\DBQueryBuilder | |
## getConnectionClass
```php
public function getConnectionClass(string $type): string
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| type | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | |

View File

@@ -0,0 +1,115 @@
# ZM\Store\FileSystem
## scanDirFiles
```php
public function scanDirFiles(string $dir, bool $recursive, mixed $relative, bool $include_dir): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| dir | string | |
| recursive | bool | |
| relative | mixed | |
| include_dir | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## isRelativePath
```php
public function isRelativePath(string $path): bool
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| path | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## createDir
```php
public function createDir(string $path): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| path | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## getReloadableFiles
```php
public function getReloadableFiles(): array
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## getClassesPsr4
```php
public function getClassesPsr4(string $dir, string $base_namespace, mixed $rule, mixed $return_path_value): array
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| dir | string | |
| base_namespace | string | |
| rule | mixed | |
| return_path_value | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |

View File

@@ -0,0 +1,46 @@
# ZM\Store\Lock\FileLock
## lock
```php
public function lock(string $name): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## unlock
```php
public function unlock(string $name): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,110 @@
# ZM\Store\MySQL\MySQLConnection
## prepare
```php
public function prepare(mixed $sql, mixed $options): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| sql | mixed | |
| options | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## query
```php
public function query(mixed $args): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| args | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## exec
```php
public function exec(mixed $sql): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| sql | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## lastInsertId
```php
public function lastInsertId(mixed $name): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getPoolName
```php
public function getPoolName(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,104 @@
# ZM\Store\MySQL\MySQLPool
## create
```php
public function create(string $name, array $config): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | |
| config | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## pool
```php
public function pool(string $name): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getAllPools
```php
public function getAllPools(): array
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## destroyPool
```php
public function destroyPool(string $name): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## checkExtension
```php
public function checkExtension(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,17 @@
# ZM\Store\MySQL\MySQLQueryBuilder
## execute
```php
public function execute(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,17 @@
# ZM\Store\MySQL\MySQLStatement
## current
```php
public function current(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -0,0 +1,289 @@
# ZM\Store\MySQL\MySQLStatementWrapper
## getIterator
```php
public function getIterator(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## columnCount
```php
public function columnCount(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## fetchNumeric
```php
public function fetchNumeric(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## fetchAssociative
```php
public function fetchAssociative(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## fetchOne
```php
public function fetchOne(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## fetchAllNumeric
```php
public function fetchAllNumeric(): array
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## fetchAllAssociative
```php
public function fetchAllAssociative(): array
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## fetchAllKeyValue
```php
public function fetchAllKeyValue(): array
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## fetchAllAssociativeIndexed
```php
public function fetchAllAssociativeIndexed(): array
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## fetchFirstColumn
```php
public function fetchFirstColumn(): array
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## iterateNumeric
```php
public function iterateNumeric(): Traversable
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## iterateAssociative
```php
public function iterateAssociative(): Traversable
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## iterateKeyValue
```php
public function iterateKeyValue(): Traversable
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## iterateAssociativeIndexed
```php
public function iterateAssociativeIndexed(): Traversable
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## iterateColumn
```php
public function iterateColumn(): Traversable
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## rowCount
```php
public function rowCount(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## free
```php
public function free(): void
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |

View File

@@ -0,0 +1,936 @@
# ZM\Store\MySQL\MySQLWrapper
## __construct
```php
public function __construct(string $name): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getDatabase
```php
public function getDatabase(): string
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | |
## isAutoCommit
```php
public function isAutoCommit(): bool
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## setAutoCommit
```php
public function setAutoCommit(bool $auto_commit): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| auto_commit | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## fetchAssociative
```php
public function fetchAssociative(string $query, array $params, array $types): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## fetchNumeric
```php
public function fetchNumeric(string $query, array $params, array $types): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## fetchOne
```php
public function fetchOne(string $query, array $params, array $types): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## isTransactionActive
```php
public function isTransactionActive(): bool
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## delete
```php
public function delete(string $table, array $criteria, array $types): int
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| table | string | |
| criteria | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |
## setTransactionIsolation
```php
public function setTransactionIsolation(int $level): int
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| level | int | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |
## getTransactionIsolation
```php
public function getTransactionIsolation(): int
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |
## update
```php
public function update(string $table, array $data, array $criteria, array $types): int
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| table | string | |
| data | array | |
| criteria | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |
## insert
```php
public function insert(string $table, array $data, array $types): int
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| table | string | |
| data | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |
## quoteIdentifier
```php
public function quoteIdentifier(string $str): string
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| str | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string | |
## quote
```php
public function quote(mixed $value, mixed $type): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| value | mixed | |
| type | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## fetchAllNumeric
```php
public function fetchAllNumeric(string $query, array $params, array $types): array
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## fetchAllAssociative
```php
public function fetchAllAssociative(string $query, array $params, array $types): array
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## fetchAllKeyValue
```php
public function fetchAllKeyValue(string $query, array $params, array $types): array
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## fetchAllAssociativeIndexed
```php
public function fetchAllAssociativeIndexed(string $query, array $params, array $types): array
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## fetchFirstColumn
```php
public function fetchFirstColumn(string $query, array $params, array $types): array
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| array | |
## iterateNumeric
```php
public function iterateNumeric(string $query, array $params, array $types): Traversable
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## iterateAssociative
```php
public function iterateAssociative(string $query, array $params, array $types): Traversable
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## iterateKeyValue
```php
public function iterateKeyValue(string $query, array $params, array $types): Traversable
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## iterateAssociativeIndexed
```php
public function iterateAssociativeIndexed(string $query, array $params, array $types): Traversable
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## iterateColumn
```php
public function iterateColumn(string $query, array $params, array $types): Traversable
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| query | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Traversable | |
## executeQuery
```php
public function executeQuery(string $sql, array $params, array $types, Doctrine\DBAL\Cache\QueryCacheProfile $qcp): ZM\Store\MySQL\MySQLStatementWrapper
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| sql | string | |
| params | array | |
| types | array | |
| qcp | Doctrine\DBAL\Cache\QueryCacheProfile | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZM\Store\MySQL\MySQLStatementWrapper | |
## executeCacheQuery
```php
public function executeCacheQuery(string $sql, array $params, array $types, Doctrine\DBAL\Cache\QueryCacheProfile $qcp): ZM\Store\MySQL\MySQLStatementWrapper
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| sql | string | |
| params | array | |
| types | array | |
| qcp | Doctrine\DBAL\Cache\QueryCacheProfile | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZM\Store\MySQL\MySQLStatementWrapper | |
## executeStatement
```php
public function executeStatement(string $sql, array $params, array $types): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| sql | string | |
| params | array | |
| types | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getTransactionNestingLevel
```php
public function getTransactionNestingLevel(): int
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| int | |
## lastInsertId
```php
public function lastInsertId(string $name): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| name | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## transactional
```php
public function transactional(Closure $func): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| func | Closure | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## setNestTransactionsWithSavepoints
```php
public function setNestTransactionsWithSavepoints(bool $nest_transactions_with_savepoints): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| nest_transactions_with_savepoints | bool | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getNestTransactionsWithSavepoints
```php
public function getNestTransactionsWithSavepoints(): bool
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## beginTransaction
```php
public function beginTransaction(): bool
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## commit
```php
public function commit(): bool
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## rollBack
```php
public function rollBack(): bool
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## createSavepoint
```php
public function createSavepoint(string $savepoint): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| savepoint | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## releaseSavepoint
```php
public function releaseSavepoint(string $savepoint): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| savepoint | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## rollbackSavepoint
```php
public function rollbackSavepoint(string $savepoint): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| savepoint | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## setRollbackOnly
```php
public function setRollbackOnly(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## isRollbackOnly
```php
public function isRollbackOnly(): bool
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## createQueryBuilder
```php
public function createQueryBuilder(): ZM\Store\MySQL\MySQLQueryBuilder
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ZM\Store\MySQL\MySQLQueryBuilder | |

View File

@@ -0,0 +1,71 @@
# ZM\Utils\ConnectionUtil
## addConnection
```php
public function addConnection(int $fd, array $handle): bool
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| fd | int | |
| handle | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
## setConnection
```php
public function setConnection(int $fd, array $handle): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| fd | int | |
| handle | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |
## removeConnection
```php
public function removeConnection(int $fd): void
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| fd | int | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| void | |

View File

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

View File

@@ -3,7 +3,7 @@
## parseUri
```php
public function parseUri(mixed $request, mixed $response, mixed $uri, mixed $node, mixed $params): mixed
public function parseUri(Psr\Http\Message\RequestInterface $request, mixed $node, mixed $params): int
```
### 描述
@@ -14,9 +14,7 @@ public function parseUri(mixed $request, mixed $response, mixed $uri, mixed $nod
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| request | mixed | |
| response | mixed | |
| uri | mixed | |
| request | Psr\Http\Message\RequestInterface | |
| node | mixed | |
| params | mixed | |
@@ -24,13 +22,13 @@ public function parseUri(mixed $request, mixed $response, mixed $uri, mixed $nod
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
| int | |
## handleStaticPage
```php
public function handleStaticPage(Response|\Swoole\Http\Response $response, string $uri, array $settings): bool
public function handleStaticPage(string $uri, array $settings): Psr\Http\Message\ResponseInterface
```
### 描述
@@ -41,7 +39,6 @@ public function handleStaticPage(Response|\Swoole\Http\Response $response, strin
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| response | Response|\Swoole\Http\Response | |
| uri | string | |
| settings | array | |
@@ -49,4 +46,52 @@ public function handleStaticPage(Response|\Swoole\Http\Response $response, strin
| 类型 | 描述 |
| ---- | ----------- |
| bool | |
| Psr\Http\Message\ResponseInterface | |
## handleHttpCodePage
```php
public function handleHttpCodePage(int $code): Psr\Http\Message\ResponseInterface
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| code | int | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Psr\Http\Message\ResponseInterface | |
## createJsonResponse
```php
public function createJsonResponse(array $data, int $http_code, int $json_flag): Psr\Http\Message\ResponseInterface
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| data | array | |
| http_code | int | |
| json_flag | int | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| Psr\Http\Message\ResponseInterface | |

View File

@@ -1 +1,73 @@
# ZM\Utils\Manager\ProcessManager
# ZM\Utils\Manager\ProcessManager
## removeProcessState
```php
public function removeProcessState(null|int|string $id_or_name, int $type): mixed
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| id_or_name | null|int|string | |
| type | int | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getProcessState
```php
public function getProcessState(mixed $id_or_name, int $type): false|int|mixed
```
### 描述
用于框架内部获取多进程运行状态的函数
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| id_or_name | mixed | |
| type | int | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| false|int|mixed | |
## saveProcessState
```php
public function saveProcessState(int|string $pid, int $type, array $data): mixed
```
### 描述
将各进程的pid写入文件以备后续崩溃及僵尸进程处理使用
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| pid | int|string | |
| type | int | |
| data | array | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |

View File

@@ -3,24 +3,24 @@
## getParameterClassName
```php
public function getParameterClassName(ReflectionParameter $parameter): null|string
public function getParameterClassName(ReflectionParameter $parameter): string
```
### 描述
获取参数的类名(如有)
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| parameter | ReflectionParameter | 参数 |
| parameter | ReflectionParameter | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| null|string | 类名,如果参数不是类,返回 null |
| string | |
## variableToString
@@ -31,7 +31,7 @@ public function variableToString(mixed $var): string
### 描述
将传入变量转换为字符串
作者很懒,什么也没有说
### 参数
@@ -49,18 +49,18 @@ public function variableToString(mixed $var): string
## isNonStaticMethod
```php
public function isNonStaticMethod(callable|string $callback): bool
public function isNonStaticMethod(mixed $callback): bool
```
### 描述
判断传入的回调是否为任意类的非静态方法
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| callback | callable|string | 回调 |
| callback | mixed | |
### 返回
@@ -72,24 +72,45 @@ public function isNonStaticMethod(callable|string $callback): bool
## getCallReflector
```php
public function getCallReflector(callable|string $callback): ReflectionFunctionAbstract
public function getCallReflector(mixed $callback): ReflectionFunctionAbstract
```
### 描述
获取传入的回调的反射实例
如果传入的是类方法,则会返回 {@link ReflectionMethod} 实例
否则将返回 {@link ReflectionFunction} 实例
可传入实现了 __invoke 的类
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| callback | callable|string | 回调 |
| callback | mixed | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ReflectionFunctionAbstract | |
## getMethod
```php
public function getMethod(string $class, string $method): ReflectionMethod
```
### 描述
作者很懒,什么也没有说
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| class | string | |
| method | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| ReflectionMethod | |

View File

@@ -1,9 +1,9 @@
# ZM\Utils\ZMUtil
## stop
## getComposerMetadata
```php
public function stop(mixed $error_exit): mixed
public function getComposerMetadata(string $path): array
```
### 描述
@@ -14,70 +14,10 @@ public function stop(mixed $error_exit): mixed
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| error_exit | mixed | |
| path | string | |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## reload
```php
public function reload(): mixed
```
### 描述
作者很懒,什么也没有说
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| mixed | |
## getReloadableFiles
```php
public function getReloadableFiles(): string[]|string[][]
```
### 描述
在工作进程中返回可以通过reload重新加载的php文件列表
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string[]|string[][] | |
## getClassesPsr4
```php
public function getClassesPsr4(string $dir, string $base_namespace, null|mixed $rule, bool|string $return_path_value): string[]
```
### 描述
使用Psr-4标准获取目录下的所有类
### 参数
| 名称 | 类型 | 描述 |
| -------- | ---- | ----------- |
| dir | string | 目录 |
| base_namespace | string | 基础命名空间 |
| rule | null|mixed | 规则 |
| return_path_value | bool|string | 是否返回文件路径,返回文件路径的话传入字符串 |
### 返回
| 类型 | 描述 |
| ---- | ----------- |
| string[] | |
| array | |

View File

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

View File

@@ -1,82 +1,86 @@
# 错误码对照表
| 异常码 | 含义 | 解决方案 |
| ------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| E00001 | 炸毛框架未检测到 PHP 安装了 Swoole 扩展 | 根据文档安装扩展去! |
| E00002 | Swoole 扩展安装的版本过低 | 升级 Swoole 版本,最好为最新版。 |
| E00003 | PHP 版本过低 | 升级 PHP 版本,至少为 7.2。 |
| E00004 | Swoole 版本低于 4.6.7 且未安装 pcntl 扩展 | 安装 pcntl 扩展或升级 Swoole 至少为4.6.7。 |
| E00005 | 在框架命令行解析过程中出现了致命错误 | 请根据提示的错误位置进行调试和修复,如果未解决请将问题反馈给作者。 |
| E00006 | 炸毛框架在源码模式启动时未能修改 composer.json 文件 | 检查源码模式下 composer.json 文件是否正常可写可读。 |
| E00007 | 框架在启动时未找到 global.php 全局配置文件 | 如果是使用 `composer create-project` 或用 git 来克隆 starter 仓库的,需要先使用 `vendor/bin/start init` 指令,再启动服务器。 |
| E00008 | 框架在启动时给用于存储连接数据的共享内存表初始化失败 | 请检查系统内存是否过小,如果一切正常,此问题一般是框架内部导致的问题,请将错误日志反馈给开发者。 |
| E00009 | 使用 `--remote-terminal` 时远程终端处理命令出现异常或致命错误 | 检查自身的远程终端是否正确配置和使用,自定义的 `@TerminalCommand` 注解是否抛出了致命错误。 |
| E00010 | 框架在第一步的启动阶段抛出异常或致命错误,导致框架不能继续运行 | 此错误涵盖的错误内容较多,请根据实际抛出的异常内容进行处理或反馈给开发者。<br />如果你使用了 `@SwooleHandler``@OnSetup` 注解,那么可以自行检查一下注解绑定的函数有没有出错。 |
| E00011 | 框架在调用 Swoole 服务器启动 `$server->start()` 过程中出现了异常 | 此问题未经测试,暂无解决方案,也没有遇到过,如果有发生,请将错误反馈开发者。 |
| E00012 | 框架在启动时调用脚本解析 `@SwooleHandler``@OnSetup` 时出现了异常 | 留个坑下次写TODO。 |
| E00013 | 使用命令行参数动态设置启动的 Worker/TaskWorker 进程数时输入了非法的数字 | 填写合法的数字或不使用此功能。 |
| E00014 | 炸毛框架的启动命令报错,提示没有找到 PHP 环境 | 使用 `./install-runtime.sh` 命令安装便携的静态 PHP 环境或根据教程和 Linux 发行版安装环境。 |
| E00015 | 启动命令启动框架找不到框架本体的入口文件 | 请检查 Composer 拉取的框架代码是否完整。 |
| E00016 | 连接中断后 `@OnCloseEvent` 事件抛出异常 | 检查 `@OnCloseEvent``@OnSwooleEvent("close")` 注解事件。 |
| E00017 | 框架作为 WebSocket 服务器收到客户端数据后 `@OnMessageEvent``@OnSwooleEvent("message")` 或 OneBot 相关事件抛出了未被捕获的异常或错误 | 检查 `@OnSwooleEvent("message")``@OnMessageEvent` 或 OneBot 相关注解事件。 |
| E00018 | 框架设置 `access_token` 参数为自定义闭包函数,有新 WebSocket 连接接入但是闭包函数返回失败 | 说白了就是自定义的 `access_token` 验证失败。如果是自己的 OneBot 客户端连接,那么请检查你的函数或 OneBot 客户端那边和框架约定的 token 是否一致,如果将框架开到了公网并有人尝试连接但失败了说明是正常现象。 |
| E00019 | 框架设置了 `access_token` 为固定字符串,但是 WebSocket 新连接验证 Token 失败 | 如果是自身行为,比如 OneBot 客户端接入,请检查 Token 是否一致。如果不需要设置 Token请检查全局配置文件的 `access_token` 项是否为空字符串。 |
| E00020 | 框架在收到 WebSocket 连接后触发 `@OnOpenEvent` 注解事件过程中抛出了异常 | 检查用户代码中 `@OnOpenEvent``@OnSwooleEvent("open")` 注解事件下的代码是否有问题。 |
| E00021 | 框架在处理 pipeMessage 事件时出现了异常 | 如果写了 `@OnPipeMessageEvent` 注解事件,请检查对应注解事件。如果未设置,可能是框架内部错误,请将报错信息反馈开发者。 |
| E00022 | 调用 `ProcessManager::sendActionToWorker()` 方法时,调用此方法的进程不是 Worker 或 Manager 进程 | 如果你在 Master 进程调用此方法会直接报此错误,框架不支持从 Master 进程调用此方法。 |
| E00023 | 框架在收到 HTTP 请求后处理过程中出现了未捕获的异常 | 检查 HTTP 请求相关的注解解析代码,如果调用栈显示非用户代码所致,请将错误信息反馈开发者。 |
| E00024 | 框架使用 `--watch` 时无法使用热更新并报错 | PHP 未安装 inotify 扩展,请使用 pecl 安装 inotify 扩展并启用后再试。 |
| E00025 | 框架使用终端输入时产生了未捕获的异常或致命错误 | 检查 `@TerminalCommand` 注解事件或检查使用动态命令的内容(例如 bc 或 call 运行的代码或函数有没有错误)。 |
| E00026 | 框架使用 `@OnTask` 注解在 TaskWorker 进程中执行函数抛出了异常 | 检查 TaskWorker 运行的任务代码是否会抛出未捕获的异常。 |
| E00027 | 框架在运行过程中 Worker 进程发生未捕获的异常导致崩溃退出 | 见 [Issue #38](https://github.com/zhamao-robot/zhamao-framework/issues/38)。 |
| E00028 | PHP 未安装 pdo_mysqlmysqlnd+PDO扩展 | 安装 php-mysql以 ubuntu 为例apt install php-pdo php-mysql。 |
| E00029 | PHP 未安装 redis 扩展 | 安装 redis 扩展。 |
| E00030 | 框架在 Worker 进程启动时出现错误 | 检查 `@OnStart` 相关事件的问题,或根据报错信息定位问题所在。此问题可能较常见,一般在启动时导致的。 |
| E00031 | 框架在启动前解析代码出现错误 | 检查模块代码中是否有 PHP 语法错误。 |
| E00032 | 上下文的 class 没有 implements ContextInterface 接口 | 如果从 global.php 设置了自定义上下文类,那么请检查上下文类有没有根据文档标准来编写接口。 |
| E00033 | Worker 进程运行过程使用 `zm_*` 方法过程中抛出了未被捕获的异常 | 一般是由 `zm_go()``zm_timer_tik()` 造成的,协程或计时器内抛出了异常未被捕获。建议根据 trace 检查是什么地方抛出的异常。 |
| E00034 | 由带中间件的 `@OnTick` 计时器产生了未被捕获的异常 | 建议检查计时器内的代码抛出异常位置,如果错误处理也是一部分功能,建议使用 `try catch` 自行捕获。 |
| E00035 | CQ 码相关错误 | 根据提示检查调用 CQ 码的代码即可。 |
| E00036 | OneBot WebSocket API 推送失败,可能是 WebSocket 客户端出现了问题 | 建议检查 OneBot 客户端和框架的连接是否正常。 |
| E00037 | OneBot 机器人端连接未找到,或单例模式连接了多个机器人 | 根据提示信息进行修复,比如机器人 xxx 未连接到框架,就看一下 OneBot 客户端是否启用和配置正常。 |
| E00038 | 图灵机器人 API 调用出错 | 根据提示和图灵错误码进行检查。 |
| E00039 | 使用 build 命令时检测到目标目录不存在 | 重新指定一个存在的目录即可。 |
| E00040 | 使用 build 命令时检测到 PHP 未设置 `phar.readonly=Off` | 修改 php.ini 将此项设置为 Off。 |
| E00041 | 使用 init 命令时未检测到 composer.json 文件 | 检查引用框架的 composer.json 文件位置。 |
| E00042 | 框架使用 init 命令时启动模式不是 Composer 模式 | 如果你是使用 git 且下载的仓库是 `zhamao-robot/zhamao-framework.git`,那么代表其以源码模式启动,详见[框架启动模式 - 炸毛框架 v2 (zhamao.xin)](https://framework.zhamao.xin/advanced/custom-start/)。 |
| E00043 | MySQL 数据库出错,抛出异常 | 根据提示信息检查 MySQL 语句是否正确,数据库是否连接正常等,其他不能解决的问题建议反馈开发者。 |
| E00044 | 打包模块过程中抛出了异常 | 根据提示文本进行修复错误的指令和代码即可。 |
| E00045 | 打包模块过程中无法储存 `light-cache-store` 项指定的缓存数据 | 根据提示进行修复即可。 |
| E00046 | Redis 连接池在使用过程中未提前初始化,可能是未设置全局配置文件启用 Redis 连接池 | 检查 global.php 是否设置 Redis 服务器。 |
| E00047 | Redis 连接池初始化失败 | 根据提示报错信息进行修复,先检查 global.php 是否设置 Redis 服务器。 |
| E00048 | LightCache 未初始化 | LightCache 会根据 global.php 初始化申请内存,如果申请出错请根据启动时的报错信息调整配置。 |
| E00049 | LightCache 不能接收字符串、数组、int 之外的变量数据 | 检查传入的数据类型。 |
| E00050 | 系统内存不足LightCache 申请内存失败 | 让 PHP 可使用的内存或系统内存变大,也可以调小全局配置中设置的 LightCache 配置项。 |
| E00051 | LightCache 的 Hash 冲突过多,导致无法动态空间分配内存 | 设置 `hash_conflict_proportion` 大一些(范围 0-1默认是 0.6)。 |
| E00052 | 在 /src/ 目录下不可以直接标记为模块(zm.json),因为命名空间不能为根空间 | 将模块标记文件 zm.json 放到子目录下,不能直接放在 src 目录下。 |
| E00053 | 框架检测到了重名模块 | 更改模块名称。 |
| E00054 | 打包好的模块文件phar内检测不到 zm.json 原始模块标记文件存在 | 检查 phar 模块是否完整。 |
| E00055 | 打包好的模块文件phar不能正常读取模块标记文件zm.json | 检查 phar 模块是否完整。 |
| E00056 | 未开启 TaskWorker 进程 | 请先修改 global 配置文件启用。 |
| E00057 | 调用 `DataProvider::saveToJson()` 失败,因为传入了多级目录 | `saveToJson()` 方法的 `$filename` 参数只能最多到第二级子目录,不能有三级,例如 `foo/bar`。 |
| E00058 | 调用 `DataProvider::scanDirFiles()` 失败,因为传入的 `$relative` 错误 | `$relative` 参数只能传入 `string/false` 两种类型。 |
| E00059 | 使用 `MessageUtil::downloadCQImage()` 失败,因为指定下载的目录不存在 | 新建目录,检查目录地址是否是绝对路径,如果手动指定了目录,最好为绝对路径。 |
| E00060 | 使用 `MessageUtil::downloadCQImage()` 失败,因为图片下载失败 | 检查下载图片的链接地址是否能正常的访问。 |
| E00061 | 使用 `set_coroutine_params()` 失败,因为不能在非协程环境使用此函数 | 检查调用此函数的位置,注意不能在非协程环境(比如 Master 进程)下调用。 |
| E00062 | 注解事件非法或不可回溯 | 不能在非注解调用的类中的方法调用 `EventTracer` 方法。 |
| E00063 | 模块检测到依赖版本问题 | 检查是否部署或正确配置依赖的模块/插件版本。 |
| E00064 | 模块系统检测到依赖的模块不存在或未安装部署 | 检查依赖的模块是否正确存在于源码目录。 |
| E00065 | 模块系统检测到打包的模块文件中未含有 `light_cache_store.json` 文件 | 可能是打包此模块后打包的文件损坏,请询问原开发者打包一个新的没有损坏的 phar 文件。 |
| E00066 | 模块打包时 `zmdata-store` 指定的文件或目录不存在 | 检查是否存在,检查写的相对路径是否有误(相对路径的初始路径为框架当前的 `zm_data` 配置的目录。 |
| E00067 | 模块解包合并 `composer.json` 时没有找到项目原文件 | 检查项目的工作目录下是否有 `composer.json` 文件存在。 |
| E00068 | 模块解包时无法正常拷贝文件 | 检查文件夹是否正常可以创建和写入。 |
| E00069 | 框架不能启动两个 ConsoleApplication 实例 | 不要重复使用 `new ConsoleApplication()` |
| E00070 | 框架找不到 `zm_data` 目录 | 检查配置中指定的 `zm_data` 目录是否存在。 |
| E00071 | 框架找不到对应类型的 API 调用类 | 检查 `getExtendedAPI($name)` 传入的 `$name` 是否正确 |
| E00072 | 上下文无法找到 | 检查上下文环境,如是否处于协程环境中 |
| E00073 | 在类中找不到方法 | 检查调用对象是否存在对应的方法method或检查是否插入了对应的macro宏方法 |
| E00074 | 参数非法 | 检查调用的参数是否正常(此处可能有多处问题,请看具体调用栈炸掉的地方) |
| E00075 | Cron表达式非法 | 检查 @Cron 中的表达式是否书写格式正确 |
| E00076 | Cron检查间隔非法 | 检查 @Cron 中的检查间隔毫秒是否在1000-60000之间 |
| E00077 | 输入了非法的消息匹配参数类型 | 检查传入 `@CommandArgument``checkArguments()` 方法有没有传入非法的 `type` 参数 |
| E99999 | 未知错误 | |
| 异常码 | 含义 | 解决方案 |
|--------|-----------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|
| E00001 | 炸毛框架未检测到 PHP 安装了 Swoole 扩展 | 根据文档安装扩展去! |
| E00002 | Swoole 扩展安装的版本过低 | 升级 Swoole 版本,最好为最新版。 |
| E00003 | PHP 版本过低 | 升级 PHP 版本,至少为 7.2。 |
| E00004 | Swoole 版本低于 4.6.7 且未安装 pcntl 扩展 | 安装 pcntl 扩展或升级 Swoole 至少为4.6.7。 |
| E00005 | 在框架命令行解析过程中出现了致命错误 | 请根据提示的错误位置进行调试和修复,如果未解决请将问题反馈给作者。 |
| E00006 | 炸毛框架在源码模式启动时未能修改 composer.json 文件 | 检查源码模式下 composer.json 文件是否正常可写可读。 |
| E00007 | 框架在启动时未找到 global.php 全局配置文件 | 如果是使用 `composer create-project` 或用 git 来克隆 starter 仓库的,需要先使用 `vendor/bin/start init` 指令,再启动服务器。 |
| E00008 | 框架在启动时给用于存储连接数据的共享内存表初始化失败 | 请检查系统内存是否过小,如果一切正常,此问题一般是框架内部导致的问题,请将错误日志反馈给开发者。 |
| E00009 | 使用 `--remote-terminal` 时远程终端处理命令出现异常或致命错误 | 检查自身的远程终端是否正确配置和使用,自定义的 `@TerminalCommand` 注解是否抛出了致命错误。 |
| E00010 | 框架在第一步的启动阶段抛出异常或致命错误,导致框架不能继续运行 | 此错误涵盖的错误内容较多,请根据实际抛出的异常内容进行处理或反馈给开发者。<br />如果你使用了 `@SwooleHandler``@OnSetup` 注解,那么可以自行检查一下注解绑定的函数有没有出错。 |
| E00011 | 框架在调用 Swoole 服务器启动 `$server->start()` 过程中出现了异常 | 此问题未经测试,暂无解决方案,也没有遇到过,如果有发生,请将错误反馈开发者。 |
| E00012 | 框架在启动时调用脚本解析 `@SwooleHandler``@OnSetup` 时出现了异常 | 留个坑下次写TODO。 |
| E00013 | 使用命令行参数动态设置启动的 Worker/TaskWorker 进程数时输入了非法的数字 | 填写合法的数字或不使用此功能。 |
| E00014 | 炸毛框架的启动命令报错,提示没有找到 PHP 环境 | 使用 `./install-runtime.sh` 命令安装便携的静态 PHP 环境或根据教程和 Linux 发行版安装环境。 |
| E00015 | 启动命令启动框架找不到框架本体的入口文件 | 请检查 Composer 拉取的框架代码是否完整。 |
| E00016 | 连接中断后 `@OnCloseEvent` 事件抛出异常 | 检查 `@OnCloseEvent``@OnSwooleEvent("close")` 注解事件。 |
| E00017 | 框架作为 WebSocket 服务器收到客户端数据后 `@OnMessageEvent``@OnSwooleEvent("message")` 或 OneBot 相关事件抛出了未被捕获的异常或错误 | 检查 `@OnSwooleEvent("message")``@OnMessageEvent` 或 OneBot 相关注解事件。 |
| E00018 | 框架设置 `access_token` 参数为自定义闭包函数,有新 WebSocket 连接接入但是闭包函数返回失败 | 说白了就是自定义的 `access_token` 验证失败。如果是自己的 OneBot 客户端连接,那么请检查你的函数或 OneBot 客户端那边和框架约定的 token 是否一致,如果将框架开到了公网并有人尝试连接但失败了说明是正常现象。 |
| E00019 | 框架设置了 `access_token` 为固定字符串,但是 WebSocket 新连接验证 Token 失败 | 如果是自身行为,比如 OneBot 客户端接入,请检查 Token 是否一致。如果不需要设置 Token请检查全局配置文件的 `access_token` 项是否为空字符串。 |
| E00020 | 框架在收到 WebSocket 连接后触发 `@OnOpenEvent` 注解事件过程中抛出了异常 | 检查用户代码中 `@OnOpenEvent``@OnSwooleEvent("open")` 注解事件下的代码是否有问题。 |
| E00021 | 框架在处理 pipeMessage 事件时出现了异常 | 如果写了 `@OnPipeMessageEvent` 注解事件,请检查对应注解事件。如果未设置,可能是框架内部错误,请将报错信息反馈开发者。 |
| E00022 | 调用 `ProcessManager::sendActionToWorker()` 方法时,调用此方法的进程不是 Worker 或 Manager 进程 | 如果你在 Master 进程调用此方法会直接报此错误,框架不支持从 Master 进程调用此方法。 |
| E00023 | 框架在收到 HTTP 请求后处理过程中出现了未捕获的异常 | 检查 HTTP 请求相关的注解解析代码,如果调用栈显示非用户代码所致,请将错误信息反馈开发者。 |
| E00024 | 框架使用 `--watch` 时无法使用热更新并报错 | PHP 未安装 inotify 扩展,请使用 pecl 安装 inotify 扩展并启用后再试。 |
| E00025 | 框架使用终端输入时产生了未捕获的异常或致命错误 | 检查 `@TerminalCommand` 注解事件或检查使用动态命令的内容(例如 bc 或 call 运行的代码或函数有没有错误)。 |
| E00026 | 框架使用 `@OnTask` 注解在 TaskWorker 进程中执行函数抛出了异常 | 检查 TaskWorker 运行的任务代码是否会抛出未捕获的异常。 |
| E00027 | 框架在运行过程中 Worker 进程发生未捕获的异常导致崩溃退出 | 见 [Issue #38](https://github.com/zhamao-robot/zhamao-framework/issues/38)。 |
| E00028 | PHP 未安装 pdo_mysqlmysqlnd+PDO扩展 | 安装 php-mysql以 ubuntu 为例apt install php-pdo php-mysql |
| E00029 | PHP 未安装 redis 扩展 | 安装 redis 扩展。 |
| E00030 | 框架在 Worker 进程启动时出现错误 | 检查 `@OnStart` 相关事件的问题,或根据报错信息定位问题所在。此问题可能较常见,一般在启动时导致的。 |
| E00031 | 框架在启动前解析代码出现错误 | 检查模块代码中是否有 PHP 语法错误。 |
| E00032 | 上下文的 class 没有 implements ContextInterface 接口 | 如果从 global.php 设置了自定义上下文类,那么请检查上下文类有没有根据文档标准来编写接口。 |
| E00033 | Worker 进程运行过程使用 `zm_*` 方法过程中抛出了未被捕获的异常 | 一般是由 `zm_go()``zm_timer_tik()` 造成的,协程或计时器内抛出了异常未被捕获。建议根据 trace 检查是什么地方抛出的异常。 |
| E00034 | 由带中间件的 `@OnTick` 计时器产生了未被捕获的异常 | 建议检查计时器内的代码抛出异常位置,如果错误处理也是一部分功能,建议使用 `try catch` 自行捕获。 |
| E00035 | CQ 码相关错误 | 根据提示检查调用 CQ 码的代码即可。 |
| E00036 | OneBot WebSocket API 推送失败,可能是 WebSocket 客户端出现了问题 | 建议检查 OneBot 客户端和框架的连接是否正常。 |
| E00037 | OneBot 机器人端连接未找到,或单例模式连接了多个机器人 | 根据提示信息进行修复,比如机器人 xxx 未连接到框架,就看一下 OneBot 客户端是否启用和配置正常。 |
| E00038 | 图灵机器人 API 调用出错 | 根据提示和图灵错误码进行检查。 |
| E00039 | 使用 build 命令时检测到目标目录不存在 | 重新指定一个存在的目录即可。 |
| E00040 | 使用 build 命令时检测到 PHP 未设置 `phar.readonly=Off` | 修改 php.ini 将此项设置为 Off。 |
| E00041 | 使用 init 命令时未检测到 composer.json 文件 | 检查引用框架的 composer.json 文件位置。 |
| E00042 | 框架使用 init 命令时启动模式不是 Composer 模式 | 如果你是使用 git 且下载的仓库是 `zhamao-robot/zhamao-framework.git`,那么代表其以源码模式启动,详见[框架启动模式 - 炸毛框架 v2 (zhamao.xin)](https://framework.zhamao.xin/advanced/custom-start/)。 |
| E00043 | MySQL 数据库出错,抛出异常 | 根据提示信息检查 MySQL 语句是否正确,数据库是否连接正常等,其他不能解决的问题建议反馈开发者。 |
| E00044 | 打包模块过程中抛出了异常 | 根据提示文本进行修复错误的指令和代码即可。 |
| E00045 | 打包模块过程中无法储存 `light-cache-store` 项指定的缓存数据 | 根据提示进行修复即可。 |
| E00046 | Redis 连接池在使用过程中未提前初始化,可能是未设置全局配置文件启用 Redis 连接池 | 检查 global.php 是否设置 Redis 服务器。 |
| E00047 | Redis 连接池初始化失败 | 根据提示报错信息进行修复,先检查 global.php 是否设置 Redis 服务器。 |
| E00048 | LightCache 未初始化 | LightCache 会根据 global.php 初始化申请内存,如果申请出错请根据启动时的报错信息调整配置。 |
| E00049 | LightCache 不能接收字符串、数组、int 之外的变量数据 | 检查传入的数据类型。 |
| E00050 | 系统内存不足LightCache 申请内存失败 | 让 PHP 可使用的内存或系统内存变大,也可以调小全局配置中设置的 LightCache 配置项。 |
| E00051 | LightCache 的 Hash 冲突过多,导致无法动态空间分配内存 | 设置 `hash_conflict_proportion` 大一些(范围 0-1默认是 0.6)。 |
| E00052 | 在 /src/ 目录下不可以直接标记为模块(zm.json),因为命名空间不能为根空间 | 将模块标记文件 zm.json 放到子目录下,不能直接放在 src 目录下。 |
| E00053 | 框架检测到了重名模块 | 更改模块名称。 |
| E00054 | 打包好的模块文件phar内检测不到 zm.json 原始模块标记文件存在 | 检查 phar 模块是否完整。 |
| E00055 | 打包好的模块文件phar不能正常读取模块标记文件zm.json | 检查 phar 模块是否完整。 |
| E00056 | 未开启 TaskWorker 进程 | 请先修改 global 配置文件启用。 |
| E00057 | 调用 `DataProvider::saveToJson()` 失败,因为传入了多级目录 | `saveToJson()` 方法的 `$filename` 参数只能最多到第二级子目录,不能有三级,例如 `foo/bar` |
| E00058 | 调用 `DataProvider::scanDirFiles()` 失败,因为传入的 `$relative` 错误 | `$relative` 参数只能传入 `string/false` 两种类型。 |
| E00059 | 使用 `MessageUtil::downloadCQImage()` 失败,因为指定下载的目录不存在 | 新建目录,检查目录地址是否是绝对路径,如果手动指定了目录,最好为绝对路径。 |
| E00060 | 使用 `MessageUtil::downloadCQImage()` 失败,因为图片下载失败 | 检查下载图片的链接地址是否能正常的访问。 |
| E00061 | 使用 `set_coroutine_params()` 失败,因为不能在非协程环境使用此函数 | 检查调用此函数的位置,注意不能在非协程环境(比如 Master 进程)下调用。 |
| E00062 | 注解事件非法或不可回溯 | 不能在非注解调用的类中的方法调用 `EventTracer` 方法。 |
| E00063 | 模块检测到依赖版本问题 | 检查是否部署或正确配置依赖的模块/插件版本。 |
| E00064 | 模块系统检测到依赖的模块不存在或未安装部署 | 检查依赖的模块是否正确存在于源码目录。 |
| E00065 | 模块系统检测到打包的模块文件中未含有 `light_cache_store.json` 文件 | 可能是打包此模块后打包的文件损坏,请询问原开发者打包一个新的没有损坏的 phar 文件。 |
| E00066 | 模块打包时 `zmdata-store` 指定的文件或目录不存在 | 检查是否存在,检查写的相对路径是否有误(相对路径的初始路径为框架当前的 `zm_data` 配置的目录。 |
| E00067 | 模块解包合并 `composer.json` 时没有找到项目原文件 | 检查项目的工作目录下是否有 `composer.json` 文件存在。 |
| E00068 | 模块解包时无法正常拷贝文件 | 检查文件夹是否正常可以创建和写入。 |
| E00069 | 框架不能启动两个 ConsoleApplication 实例 | 不要重复使用 `new ConsoleApplication()` |
| E00070 | 框架找不到 `zm_data` 目录 | 检查配置中指定的 `zm_data` 目录是否存在。 |
| E00071 | 框架找不到对应类型的 API 调用类 | 检查 `getExtendedAPI($name)` 传入的 `$name` 是否正确 |
| E00072 | 上下文无法找到 | 检查上下文环境,如是否处于协程环境中 |
| E00073 | 在类中找不到方法 | 检查调用对象是否存在对应的方法method或检查是否插入了对应的macro宏方法 |
| E00074 | 参数非法 | 检查调用的参数是否正常(此处可能有多处问题,请看具体调用栈炸掉的地方) |
| E00075 | Cron表达式非法 | 检查 @Cron 中的表达式是否书写格式正确 |
| E00076 | Cron检查间隔非法 | 检查 @Cron 中的检查间隔毫秒是否在1000-60000之间 |
| E00077 | 输入了非法的消息匹配参数类型 | 检查传入 `@CommandArgument``checkArguments()` 方法有没有传入非法的 `type` 参数 |
| E00078 | 配置文件读取失败,未找到 base 配置文件 | 检查配置文件是否存在(一般是由于没找到基类配置文件产生的此错误) |
| E00079 | 配置文件读取失败 | 根据报错信息修复配置文件(或将 debug 日志发给框架开发者或反馈 Issue |
| E00080 | 调用 `FileSystem::scanDirFiles()` 失败,因为传入的不是目录或无法读取 | 使用 scanDirFiles() 传入一个可读取的目录 |
| E00081 | 传入了未知类型的 Driver | 使用受支持的 Driver 名称,例如 `swoole``workerman`(如需支持其他驱动,请反馈) |
| E99999 | 未知错误 | |

View File

@@ -49,7 +49,7 @@ function download_file() {
# 安装下载内建PHP
function install_native_php() {
ZM_PHP_VERSION="8.0"
ZM_PHP_VERSION="8.1"
if [ "$ZM_DOWN_PHP_VERSION" != "" ]; then
ZM_PHP_VERSION="$ZM_DOWN_PHP_VERSION"
fi

View File

@@ -1,26 +0,0 @@
<?php
declare(strict_types=1);
require_once 'vendor/autoload.php';
use ZM\Annotation\CQ\CQCommand;
use ZM\Annotation\Swoole\OnOpenEvent;
use ZM\ConnectionManager\ConnectionObject;
use ZM\Console\Console;
use ZM\Module\InstantModule;
use ZM\ZMServer;
$weather = new InstantModule('weather');
$weather->onEvent(OnOpenEvent::class, ['connect_type' => 'qq'], function (ConnectionObject $conn) {
Console::info('机器人 ' . $conn->getOption('connect_id') . ' 已连接!');
});
$weather->onEvent(CQCommand::class, ['match' => '你好'], function () {
ctx()->reply('hello呀');
});
$app = new ZMServer('app-name');
$app->addModule($weather);
$app->run();

20
instant-plugin-demo.php Normal file
View File

@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
$plugin = new \ZM\ZMApplication(__DIR__);
/*
* 发送 "测试 123",回复 "你好123"
*/
$cmd1 = BotCommand::make('test', '测试')->withArgument('arg1')->on(fn () => '你好,{{arg1}}');
/*
* 浏览器访问 http://ip:port/index233返回内容
*/
$route1 = Route::make('/index233')->on(fn () => '<h1>Hello world</h1>');
$plugin->addBotCommand($cmd1);
$plugin->addHttpRoute($route1);
$plugin->run();

View File

@@ -1,143 +0,0 @@
site_name: 炸毛框架文档
repo_name: '炸毛框架'
repo_url: 'https://github.com/zhamao-robot/zhamao-framework'
edit_uri: 'blob/master/docs/'
theme:
name: material
logo: assets/logos.png
favicon: assets/favicon.png
language: zh
palette:
primary: indigo
accent: indigo
features:
- navigation.tabs
- navigation.sections
extra_javascript:
- javascripts/library/highlight.min.js
- javascripts/config.js
extra_css:
- assets/css/extra.css
- assets/css/library/default.min.css
plugins:
- search:
lang: ja
markdown_extensions:
- admonition
- pymdownx.tabbed
- pymdownx.superfences
- pymdownx.inlinehilite
- pymdownx.snippets
- pymdownx.details
- abbr
- pymdownx.highlight:
linenums: true
linenums_style: pymdownx.inline
extra:
version:
provider: mike
copyright: 'Copyright &copy; 2019 - 2022 CrazyBot Team&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="tx-switch">
<button data-md-color-scheme="default"><code>默认模式</code></button>
<button data-md-color-scheme="slate"><code>暗黑模式</code></button>
</span>
<script>
var buttons = document.querySelectorAll("button[data-md-color-scheme]");
buttons.forEach(function(button) {
button.addEventListener("click", function() {
var attr = this.getAttribute("data-md-color-scheme");
setCookie("_theme", attr);
document.body.setAttribute("data-md-color-scheme", attr);
var name = document.querySelector("#__code_0 code span:nth-child(7)");
name.textContent = attr;
})
})
</script><br><a href="http://beian.miit.gov.cn">沪ICP备2021010446号-1</a>'
nav:
- 指南:
- 介绍: index.md
- 安装框架: guide/installation.md
- 快速上手(机器人篇): guide/quickstart-robot.md
- 快速上手HTTP篇: guide/quickstart-http.md
- 选择聊天机器人实例: guide/onebot-choose.md
- 基本配置: guide/basic-config.md
- 编写模块: guide/write-module.md
- 注册事件响应: guide/register-event.md
- 升级指南: guide/upgrade.md
- 错误码对照表: guide/errcode.md
- 事件和注解:
- 事件和注解: event/index.md
- 机器人注解事件: event/robot-annotations.md
- HTTP 路由注解事件: event/route-annotations.md
- 框架核心注解事件: event/framework-annotations.md
- 中间件注解: event/middleware.md
- 自定义注解: event/custom-annotations.md
- 事件分发器: event/event-dispatcher.md
- 框架组件:
- 框架组件: component/index.md
- 聊天机器人组件:
- 机器人动作V12: component/bot/robot-api-12.md
- 机器人动作V11: component/bot/robot-api.md
- CQ 码(多媒体消息): component/bot/cqcode.md
- 机器人消息处理: component/bot/message-util.md
- Token 验证: component/bot/access-token.md
- 图灵机器人 API: component/bot/turing-api.md
- 存储:
- LightCache 轻量缓存: component/store/light-cache.md
- MySQL 查询器:
- 简介: component/store/mysql/mysql.md
- 配置: component/store/mysql/config.md
- 执行 SQL 语句: component/store/mysql/common-query.md
- MySQL 查询器(废弃): component/store/mysql-db.md
- Redis 数据库: component/store/redis.md
- ZMAtomic 原子计数器: component/store/atomics.md
- SpinLock 自旋锁: component/store/spin-lock.md
- 文件管理: component/store/data-provider.md
- 通用组件:
- 上下文: component/common/context.md
- 协程池: component/common/coroutine-pool.md
- 单例类: component/common/singleton-trait.md
- ZMUtil 杂项: component/common/zmutil.md
- 全局方法: component/common/global-functions.md
- Console 终端: component/common/console.md
- TaskWorker 管理: component/common/task-worker.md
- Terminal 终端: component/common/remote-terminal.md
- EventTracer 事件追踪器: component/common/event-tracer.md
- HTTP 服务器工具类:
- HTTP 和 WebSocket 客户端: component/http/zmrequest.md
- HTTP 路由管理: component/http/route-manager.md
- 模块/插件管理:
- 模块打包: component/module/module-pack.md
- 模块解包: component/module/module-unpack.md
- 进阶开发:
- 进阶开发: advanced/index.md
- 框架高级开发:
- 框架剖析: advanced/framework-structure.md
- 框架启动模式: advanced/custom-start.md
- 手动安装环境: advanced/manually-install.md
- 内部类文件手册: advanced/inside-class.md
- 框架多进程: advanced/multi-process.md
- TaskWorker 提高并发: advanced/task-worker.md
- 开发实战教程:
- 接入 WebSocket 客户端: advanced/connect-ws-client.md
- 编写管理员才能触发的功能: advanced/example/admin.md
- 接入青云客聊天API: advanced/example/integrate-qingyunke-chatbot.md
- 开发天气机器人: advanced/example/weather-bot.md
- FAQ:
- FAQ: faq/FAQ.md
- 从 v1 升级: faq/to-v2.md
- 框架常见问题(持续更新): faq/usual-question.md
- 启动时报错 Address already in use: faq/address-already-in-use.md
- 出现 deadlock 字样: faq/display-deadlock.md
- 使用 LightCache 关闭时无法正常保存持久化: faq/light-cache-wrong.md
- CQBefore 过滤不了 waitMessage: faq/wait-message-cqbefore.md
- 更新日志:
- 更新日志v2: update/v2.md
- 更新日志v1: update/v1.md
- 更新日志build update: update/build-update.md
- 配置文件更新日志: update/config.md
- <u>炸毛框架 v1</u>: https://docs-v1.zhamao.xin/

39
mybot.php Normal file
View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
use OneBot\Driver\Event\Http\HttpRequestEvent;
require 'vendor/autoload.php';
// 创建框架 App
$app = new ZM\ZMApplication();
// 传入自定义配置文件
$app->patchConfig([
'driver' => 'workerman',
]);
// 改变启动所需的参数
$app->patchArgs([
'--private-mode',
]);
// 如果有 Composer 依赖的插件,使用 enablePlugins 进行开启
$app->enablePlugins([
'a',
'b',
'c',
'd',
]);
// BotCommand 事件构造
$cmd = BotCommand::make('test')->on(function () {
ctx()->reply('test ok');
});
$event = BotEvent::make(type: 'message')->on(function () {
});
$app->addBotEvent($event);
$app->addBotCommand($cmd);
$app->addEvent(HttpRequestEvent::getName(), function (HttpRequestEvent $event) {
$event->withResponse(\OneBot\Http\HttpFactory::getInstance()->createResponse(503));
});
$app->run();

View File

@@ -4,11 +4,13 @@ parameters:
paths:
- ./src/
ignoreErrors:
- '#Used constant OS_TYPE_(LINUX|WINDOWS) not found#'
- '#Constant .* not found#'
- '#PHPDoc tag @throws with type Psr\\Container\\ContainerExceptionInterface is not subtype of Throwable#'
- '#Unsafe usage of new static#'
- '#Call to method initTableList\(\) of deprecated class ZM\\DB\\DB#'
- '#class Fiber#'
dynamicConstantNames:
- SWOOLE_VERSION
- ZM_TEST_LOG_DEBUG
- _PHAR_STUB_ID
- LOAD_MODE

View File

@@ -1,29 +0,0 @@
<?php
declare(strict_types=1);
namespace Custom\Annotation;
use Attribute;
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
use Doctrine\Common\Annotations\Annotation\Target;
use ZM\Annotation\AnnotationBase;
use ZM\Annotation\Interfaces\CustomAnnotation;
/**
* Class CustomAnnotation
* @Annotation
* @NamedArgumentConstructor()
* @Target("ALL")
*/
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_ALL)]
class Example extends AnnotationBase implements CustomAnnotation
{
/** @var string */
public $str = '';
public function __construct($str = '')
{
$this->str = $str;
}
}

View File

@@ -1,10 +0,0 @@
<?php
declare(strict_types=1);
use ZM\Utils\CoroutinePool;
function pgo(callable $func, string $name = 'default')
{
CoroutinePool::go($func, $name);
}

View File

@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
use ZM\Container\ClassAliasHelper;
ClassAliasHelper::addAlias(\ZM\Annotation\Framework\BindEvent::class, 'BindEvent');
ClassAliasHelper::addAlias(\ZM\Annotation\Framework\Init::class, 'Init');
ClassAliasHelper::addAlias(\ZM\Annotation\Framework\Setup::class, 'Setup');
ClassAliasHelper::addAlias(\ZM\Annotation\Http\Controller::class, 'Controller');
ClassAliasHelper::addAlias(\ZM\Annotation\Http\Route::class, 'Route');
ClassAliasHelper::addAlias(\ZM\Annotation\Middleware\Middleware::class, 'Middleware');
ClassAliasHelper::addAlias(\ZM\Annotation\OneBot\BotCommand::class, 'BotCommand');
ClassAliasHelper::addAlias(\ZM\Annotation\OneBot\BotEvent::class, 'BotEvent');
ClassAliasHelper::addAlias(\ZM\Annotation\OneBot\CommandArgument::class, 'CommandArgument');
ClassAliasHelper::addAlias(\ZM\Annotation\Closed::class, 'Closed');
ClassAliasHelper::addAlias(\ZM\Plugin\ZMPlugin::class, 'ZMPlugin');
ClassAliasHelper::addAlias(\OneBot\V12\Object\OneBotEvent::class, 'OneBotEvent');
ClassAliasHelper::addAlias(\ZM\Context\BotContext::class, 'BotContext');
// 下面是 OneBot 相关类的全局别称
ClassAliasHelper::addAlias(\OneBot\Driver\Event\WebSocket\WebSocketOpenEvent::class, 'WebSocketOpenEvent');
ClassAliasHelper::addAlias(\OneBot\Driver\Event\WebSocket\WebSocketCloseEvent::class, 'WebSocketCloseEvent');
ClassAliasHelper::addAlias(\OneBot\Driver\Event\WebSocket\WebSocketMessageEvent::class, 'WebSocketMessageEvent');
ClassAliasHelper::addAlias(\OneBot\Driver\Event\Http\HttpRequestEvent::class, 'HttpRequestEvent');

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
class_alias(ZM\Annotation\Framework\BindEvent::class, 'BindEvent');
class_alias(ZM\Annotation\Framework\Init::class, 'Init');
class_alias(ZM\Annotation\Framework\Setup::class, 'Setup');
class_alias(ZM\Annotation\Http\Controller::class, 'Controller');
class_alias(ZM\Annotation\Http\Route::class, 'Route');
class_alias(ZM\Annotation\Middleware\Middleware::class, 'Middleware');
class_alias(ZM\Annotation\OneBot\BotCommand::class, 'BotCommand');
class_alias(ZM\Annotation\OneBot\BotEvent::class, 'BotEvent');
class_alias(ZM\Annotation\OneBot\CommandArgument::class, 'CommandArgument');
class_alias(ZM\Annotation\Closed::class, 'Closed');
class_alias(ZM\Plugin\ZMPlugin::class, 'ZMPlugin');
class_alias(OneBot\V12\Object\OneBotEvent::class, 'OneBotEvent');
class_alias(ZM\Context\BotContext::class, 'BotContext');
class_alias(OneBot\Driver\Event\WebSocket\WebSocketOpenEvent::class, 'WebSocketOpenEvent');
class_alias(OneBot\Driver\Event\WebSocket\WebSocketCloseEvent::class, 'WebSocketCloseEvent');
class_alias(OneBot\Driver\Event\WebSocket\WebSocketMessageEvent::class, 'WebSocketMessageEvent');
class_alias(OneBot\Driver\Event\Http\HttpRequestEvent::class, 'HttpRequestEvent');

View File

@@ -0,0 +1,88 @@
<?php
declare(strict_types=1);
/*
此文件用于定义一些常量,是框架运行的前提常量,例如定义全局版本、全局方法等。
*/
use ZM\Framework;
/** 全局版本ID */
const ZM_VERSION_ID = Framework::VERSION_ID;
/** 全局版本名称 */
const ZM_VERSION = Framework::VERSION;
/** 机器人用的,用于判断二元语意 */
const TRUE_LIST = ['yes', 'y', 'true', 'on', '是', '对', true];
const FALSE_LIST = ['no', 'n', 'false', 'off', '否', '错', false];
/** 定义多进程的全局变量 */
const ZM_PROCESS_MASTER = ONEBOT_PROCESS_MASTER;
const ZM_PROCESS_MANAGER = ONEBOT_PROCESS_MANAGER;
const ZM_PROCESS_WORKER = ONEBOT_PROCESS_WORKER;
const ZM_PROCESS_USER = ONEBOT_PROCESS_USER;
const ZM_PROCESS_TASKWORKER = ONEBOT_PROCESS_TASKWORKER;
/** 定义一些内部引用的错误ID */
const ZM_ERR_NONE = 0; // 正常
const ZM_ERR_METHOD_NOT_FOUND = 1; // 找不到方法
const ZM_ERR_ROUTE_NOT_FOUND = 2; // 找不到路由
const ZM_ERR_ROUTE_METHOD_NOT_ALLOWED = 3; // 路由方法不允许
const LOAD_MODE_VENDOR = 0; // 从 vendor 加载
const LOAD_MODE_SRC = 1; // 从 src 加载
/* 定义工作目录 */
define('WORKING_DIR', getcwd());
/* 定义源码根目录,如果是 Phar 打包框架运行的话,就是 Phar 文件本身 */
define('SOURCE_ROOT_DIR', Phar::running() !== '' ? Phar::running() : WORKING_DIR);
if (DIRECTORY_SEPARATOR === '\\') {
define('TMP_DIR', 'C:\\Windows\\Temp');
} elseif (!empty(getenv('TMPDIR'))) {
define('TMP_DIR', getenv('TMPDIR'));
} elseif (is_writable('/tmp')) {
define('TMP_DIR', '/tmp');
} else {
define('TMP_DIR', getcwd() . '/.zm-tmp');
}
/* 定义启动模式,这里指的是框架本身的源码目录是通过 composer 加入 vendor 加载的还是直接放到 src 目录加载的,前者为 1后者为 0 */
define('LOAD_MODE', is_dir(zm_dir(SOURCE_ROOT_DIR . '/src/ZM')) ? LOAD_MODE_VENDOR : LOAD_MODE_SRC);
/* 定义框架本身所处的根目录,此处如果 LOAD_MODE 为 1 的话,框架自身的根目录在 vendor/zhamao/framework 子目录下 */
if (Phar::running() !== '') {
define('FRAMEWORK_ROOT_DIR', zm_dir(LOAD_MODE == 1 ? (SOURCE_ROOT_DIR . '/vendor/zhamao/framework') : SOURCE_ROOT_DIR));
} else {
define('FRAMEWORK_ROOT_DIR', realpath(zm_dir(__DIR__ . '/../../')));
}
define('ZM_INIT_TIME', microtime(true));
/* 定义用于存放框架运行状态的目录Windows 可用) */
define('ZM_STATE_DIR', TMP_DIR . '/.zm_' . sha1(ZM_INIT_TIME . FRAMEWORK_ROOT_DIR));
/* 对 global.php 在 Windows 下的兼容性考虑,因为 Windows 或者无 Swoole 环境时候无法运行 */
!defined('SWOOLE_BASE') && define('SWOOLE_BASE', 1) && define('SWOOLE_PROCESS', 2);
!defined('SWOOLE_HOOK_ALL') && (
define('SWOOLE_HOOK_TCP', 2)
&& define('SWOOLE_HOOK_UDP', 4)
&& define('SWOOLE_HOOK_UNIX', 8)
&& define('SWOOLE_HOOK_UDG', 16)
&& define('SWOOLE_HOOK_SSL', 32)
&& define('SWOOLE_HOOK_TLS', 64)
&& define('SWOOLE_HOOK_STREAM_FUNCTION', 128)
&& define('SWOOLE_HOOK_STREAM_SELECT', 128)
&& define('SWOOLE_HOOK_FILE', 256)
&& define('SWOOLE_HOOK_STDIO', 32768)
&& define('SWOOLE_HOOK_SLEEP', 512)
&& define('SWOOLE_HOOK_PROC', 1024)
&& define('SWOOLE_HOOK_CURL', 2048)
&& define('SWOOLE_HOOK_NATIVE_CURL', 4096)
&& define('SWOOLE_HOOK_BLOCKING_FUNCTION', 8192)
&& define('SWOOLE_HOOK_SOCKETS', 16384)
&& define('SWOOLE_HOOK_ALL', 2_147_481_599)
);

View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
use ZM\Utils\ZMUtil;
/* 定义炸毛框架初始启动时间 */
if (!defined('ZM_START_TIME')) {
define('ZM_START_TIME', microtime(true));
}
/* 定义使用炸毛框架应用的版本 */
if (!defined('APP_VERSION')) {
define('APP_VERSION', LOAD_MODE == 1 ? (ZMUtil::getComposerMetadata()['version'] ?? ZM_VERSION) : ZM_VERSION);
}

View File

@@ -0,0 +1,218 @@
<?php
declare(strict_types=1);
use OneBot\Driver\Coroutine\Adaptive;
use OneBot\Driver\Coroutine\CoroutineInterface;
use OneBot\Driver\Process\ExecutionResult;
use OneBot\V12\Object\MessageSegment;
use OneBot\V12\Object\OneBotEvent;
use Psr\Log\LoggerInterface;
use ZM\Config\ZMConfig;
use ZM\Container\Container;
use ZM\Container\ContainerInterface;
use ZM\Logger\ConsoleLogger;
use ZM\Middleware\MiddlewareHandler;
use ZM\Store\Database\DBException;
use ZM\Store\Database\DBWrapper;
// 防止重复引用引发报错
if (function_exists('zm_internal_errcode')) {
return;
}
/**
* 根据具体操作系统替换目录分隔符
*
* @param string $dir 目录
*/
function zm_dir(string $dir): string
{
if (str_starts_with($dir, 'phar://')) {
return $dir;
}
return str_replace('/', DIRECTORY_SEPARATOR, $dir);
}
/**
* 执行shell指令
*
* @param string $cmd 命令行
*/
function zm_exec(string $cmd): ExecutionResult
{
return Adaptive::exec($cmd);
}
/**
* sleep 指定时间单位为秒最小单位为1毫秒即0.001
*/
function zm_sleep(float|int $time)
{
Adaptive::sleep($time);
}
/**
* 获取协程接口
*/
function coroutine(): ?CoroutineInterface
{
return Adaptive::getCoroutine();
}
/**
* 获取内部错误码
*/
function zm_internal_errcode(int|string $code): string
{
return "[ErrCode:{$code}] ";
}
/**
* 返回当前炸毛实例的 ID
*/
function zm_instance_id(): string
{
if (defined('ZM_INSTANCE_ID')) {
return ZM_INSTANCE_ID;
}
if (!defined('ZM_START_TIME')) {
define('ZM_START_TIME', microtime(true));
}
$instance_id = dechex(crc32(strval(ZM_START_TIME)));
define('ZM_INSTANCE_ID', $instance_id);
return ZM_INSTANCE_ID;
}
/**
* 助手方法,返回一个 Logger 实例
*/
function logger(): LoggerInterface
{
global $ob_logger;
if ($ob_logger === null) {
return new ConsoleLogger();
}
return $ob_logger;
}
/**
* 判断传入的数组是否为关联数组
*/
function is_assoc_array(array $array): bool
{
return !empty($array) && array_keys($array) !== range(0, count($array) - 1);
}
/**
* 构建消息段的助手函数
*
* @param string $type 类型
* @param array $data 字段
*/
function segment(string $type, array $data = []): MessageSegment
{
return new MessageSegment($type, $data);
}
/**
* 中间件操作类的助手函数
*/
function middleware(): MiddlewareHandler
{
return MiddlewareHandler::getInstance();
}
// ////////////////// 容器部分 //////////////////////
/**
* 获取容器(请求级)实例
*/
function container(): ContainerInterface
{
return Container::getInstance();
}
/**
* 解析类实例(使用容器)
*
* @template T
* @param class-string<T> $abstract
* @return Closure|mixed|T
* @noinspection PhpDocMissingThrowsInspection
*/
function resolve(string $abstract, array $parameters = [])
{
/* @noinspection PhpUnhandledExceptionInspection */
return Container::getInstance()->make($abstract, $parameters);
}
/**
* 获取容器实例
*
* @template T
* @param null|class-string<T> $abstract
* @return Closure|ContainerInterface|mixed|T
*/
function app(string $abstract = null, array $parameters = [])
{
if (is_null($abstract)) {
return container();
}
return resolve($abstract, $parameters);
}
/**
* 获取 MySQL 调用的类
*
* @throws DBException
*/
function db(string $name = '')
{
return new DBWrapper($name);
}
/**
* 获取构建 MySQL 的类
*
* @throws DBException
*/
function sql_builder(string $name = '')
{
return (new DBWrapper($name))->createQueryBuilder();
}
/**
* 获取 / 设置配置项
*
* 传入键名和(或)默认值,获取配置项
* 传入数组,设置配置项
* 不传参数,返回配置容器
*
* @param null|array|string $key 键名
* @param null|mixed $default 默认值
* @return mixed|void|ZMConfig
*/
function config(array|string $key = null, mixed $default = null)
{
$config = ZMConfig::getInstance();
if (is_null($key)) {
return $config;
}
if (is_array($key)) {
$config->set($key);
return;
}
return $config->get($key, $default);
}
function bot(): ZM\Context\BotContext
{
if (\container()->has('bot.event')) {
/** @var OneBotEvent $bot_event */
$bot_event = \container()->get('bot.event');
return new \ZM\Context\BotContext($bot_event->self['user_id'] ?? '', $bot_event->self['platform']);
}
return new \ZM\Context\BotContext('', '');
}

View File

@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
use ZM\Annotation\AnnotationParser;
use ZM\Annotation\Framework\Setup;
use ZM\Utils\ZMUtil;
function _zm_setup_loader()
{
try {
global $_tmp_setup_list;
$_tmp_setup_list = [];
$parser = new AnnotationParser(false);
$composer = ZMUtil::getComposerMetadata();
// 合并 dev 和 非 dev 的 psr-4 加载目录
$merge_psr4 = array_merge($composer['autoload']['psr-4'] ?? [], $composer['autoload-dev']['psr-4'] ?? []);
// 排除 composer.json 中指定需要排除的目录
$excludes = $composer['extra']['zm']['exclude-annotation-path'] ?? [];
foreach ($merge_psr4 as $k => $v) {
// 如果在排除表就排除,否则就解析注解
if (is_dir(SOURCE_ROOT_DIR . '/' . $v) && !in_array($v, $excludes)) {
// 添加解析路径对应Base命名空间也贴出来
$parser->addRegisterPath(SOURCE_ROOT_DIR . '/' . $v . '/', trim($k, '\\'));
}
}
$parser->addSpecialParser(Setup::class, function (Setup $setup) {
global $_tmp_setup_list;
$_tmp_setup_list[] = [
'class' => $setup->class,
'method' => $setup->method,
];
return true;
});
// TODO: 然后加载插件目录下的插件
// 解析所有注册路径的文件,获取注解
$parser->parseAll();
return json_encode(['setup' => $_tmp_setup_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);
fclose($stderr);
exit(1);
}
}
// 在*nix等支持多进程环境的情况可直接运行此文件那么就执行
if (debug_backtrace() === []) {
require((!is_dir(__DIR__ . '/../../vendor')) ? getcwd() : (__DIR__ . '/../..')) . '/vendor/autoload.php';
echo _zm_setup_loader();
}

View File

@@ -1,266 +0,0 @@
<?php
declare(strict_types=1);
namespace Module\Example;
use ZM\Annotation\CQ\CommandArgument;
use ZM\Annotation\CQ\CQBefore;
use ZM\Annotation\CQ\CQCommand;
use ZM\Annotation\CQ\CQMessage;
use ZM\Annotation\Http\Middleware;
use ZM\Annotation\Http\RequestMapping;
use ZM\Annotation\Swoole\OnCloseEvent;
use ZM\Annotation\Swoole\OnOpenEvent;
use ZM\Annotation\Swoole\OnRequestEvent;
use ZM\Annotation\Swoole\OnStart;
use ZM\API\CQ;
use ZM\API\OneBotV11;
use ZM\API\TuringAPI;
use ZM\Config\ZMConfig;
use ZM\ConnectionManager\ConnectionObject;
use ZM\Console\Console;
use ZM\Context\Context;
use ZM\Event\EventDispatcher;
use ZM\Exception\InterruptException;
use ZM\Module\QQBot;
use ZM\Requests\ZMRequest;
use ZM\Utils\CommandInfoUtil;
use ZM\Utils\MessageUtil;
use ZM\Utils\ZMUtil;
/**
* Class Hello
*
* @since 2.0
*/
class Hello
{
/*
* 默认的图片监听路由对应目录,如需要使用可取消下面的注释,把上面的 /* 换成 /**
* @OnStart(-1)
*/
// public function onStart() {
// \ZM\Http\RouteManager::addStaticFileRoute("/images/", \ZM\Utils\DataProvider::getWorkingDir()."/zm_data/images/");
// }
/**
* 使用命令 .reload 发给机器人远程重载,注意将 user_id 换成你自己的 QQ
* @CQCommand(".reload",user_id=627577391)
*/
public function reload()
{
ctx()->reply('重启中...');
ZMUtil::reload();
}
/**
* @CQCommand("我是谁")
*/
public function whoami()
{
$bot = ctx()->getRobot()->getLoginInfo();
$bot_id = $bot['data']['user_id'];
$r = OneBotV11::get($bot_id);
$QQid = ctx()->getUserId();
$nick = $r->getStrangerInfo($QQid)['data']['nickname'];
return '你是' . $nick . 'QQ号是' . $QQid;
}
/**
* 向机器人发送"你好啊",也可回复这句话
* @CQCommand(match="你好",alias={"你好啊","你是谁"})
*/
public function hello()
{
return '你好啊,我是由炸毛框架构建的机器人!';
}
/**
* 一个最基本的第三方 API 接口使用示例
* @CQCommand("一言")
*/
public function hitokoto()
{
$api_result = ZMRequest::get('https://v1.hitokoto.cn/');
if ($api_result === false) {
return '接口请求出错,请稍后再试!';
}
$obj = json_decode($api_result, true);
if ($obj === null) {
return '接口解析出错!可能返回了非法数据!';
}
return $obj['hitokoto'] . "\n----「" . $obj['from'] . '」';
}
/**
* 图灵机器人的内置实现在tuling123.com申请一个apikey填入下方变量即可。
* @CQCommand(start_with="机器人",end_with="机器人",message_type="group")
* @CQMessage(message_type="private",level=1)
*/
public function turingAPI()
{
$user_id = ctx()->getUserId();
$api = ZMConfig::get('global', 'custom.turing_apikey') ?? ''; // 请在这里填入你的图灵机器人的apikey
if ($api === '') {
return false;
} // 如果没有填入apikey则此功能关闭
if (property_exists($this, '_running_annotation') && ($this->_running_annotation instanceof CQCommand)) {
$msg = ctx()->getFullArg('我在!有什么事吗?');
} else {
$msg = ctx()->getMessage();
}
ctx()->setMessage($msg);
if (MessageUtil::matchCommand($msg, ctx()->getData())->status === false) {
return TuringAPI::getTuringMsg($msg, $user_id, $api);
}
QQBot::getInstance()->handle(ctx()->getData(), ctx()->getCache('level') + 1);
// 执行嵌套消息,递归层级+1
return true;
}
/**
* 响应at机器人的消息
* @CQBefore("message")
*/
public function changeAt()
{
if (MessageUtil::isAtMe(ctx()->getMessage(), ctx()->getRobotId())) {
$msg = str_replace(CQ::at(ctx()->getRobotId()), '', ctx()->getMessage());
ctx()->setMessage('机器人' . $msg);
Console::info(ctx()->getMessage());
}
return true;
}
/**
* 一个简单随机数的功能demo
* 问法1随机数 1 20
* 问法2从1到20的随机数
* @CQCommand("随机数")
* @CQCommand(pattern="*从*到*的随机数")
* @CommandArgument(name="num1",type="int",required=true)
* @CommandArgument(name="num2",type="int",required=true)
* @param mixed $num1
* @param mixed $num2
* @return string
*/
public function randNum($num1, $num2)
{
$a = min($num1, $num2);
$b = max($num1, $num2);
// 回复用户结果
return '从' . $a . '到' . $b . '的随机数是:' . mt_rand($a, $b);
}
/**
* 中间件测试的一个示例函数
* @RequestMapping("/httpTimer")
* @Middleware("timer")
*/
public function timer()
{
return 'This page is used as testing TimerMiddleware! Do not use it in production.';
}
/**
* 默认示例页面
* @RequestMapping("/index")
* @RequestMapping("/")
*/
public function index()
{
return 'Hello Zhamao!';
}
/**
* 使用自定义参数的路由参数
* @RequestMapping("/whoami/{name}")
*
* @param array $param 参数
* @return string 返回的 HTML Body
*/
public function paramGet(array $param = []): string
{
return 'Hello, ' . $param['name'];
}
/**
* 在机器人连接后向终端输出信息
* @OnOpenEvent("qq")
*
* @param ConnectionObject $conn WebSocket 连接对象
*/
public function onConnect(ConnectionObject $conn)
{
Console::info('机器人 ' . $conn->getOption('connect_id') . ' 已连接!');
}
/**
* 在机器人断开连接后向终端输出信息
* @OnCloseEvent("qq")
*/
public function onDisconnect(ConnectionObject $conn)
{
Console::info('机器人 ' . $conn->getOption('connect_id') . ' 已断开连接!');
}
/**
* 阻止 Chrome 自动请求 /favicon.ico 导致的多条请求并发和干扰
* @OnRequestEvent(rule="ctx()->getRequest()->server['request_uri'] == '/favicon.ico'",level=200)
*
* @throws InterruptException
*/
public function onRequest()
{
EventDispatcher::interrupt();
}
/**
* 框架会默认关闭未知的WebSocket链接因为这个绑定的事件你可以根据你自己的需求进行修改
* @OnOpenEvent("default")
*/
public function closeUnknownConn()
{
Console::info('Unknown connection , I will close it.');
server()->disconnect(ctx()->getConnection()->getFd());
}
/**
* 输出帮助信息
*
* @CQCommand("帮助")
*/
#[CQCommand('帮助')]
public function help(): string
{
$util = resolve(CommandInfoUtil::class);
$commands = $util->get();
$helps = array_map(static function ($command) use ($util) {
return $util->getHelp($command['id']);
}, $commands);
array_unshift($helps, '帮助:');
return implode("\n", $helps);
}
/**
* @CQCommand("proxy")
*/
#[CQCommand('proxy')]
public function proxy()
{
bot()->all()->allGroups()->sendGroupMsg(0, ctx()->getMessage());
}
/*
* 欢迎来到容器时代
*
* @param Context $context 通过依赖注入实现的
*
* @CQCommand("容器你好")
*/
public function welcomeToContainerAge(Context $context)
{
$context->reply('欢迎来到容器时代');
}
}

Some files were not shown because too many files have changed in this diff Show More