From 86174c2e9f14e3250cb074fa2bf8ac1be93257ee Mon Sep 17 00:00:00 2001 From: sunxyw Date: Mon, 28 Mar 2022 16:08:28 +0800 Subject: [PATCH 1/8] normalize composer --- composer.json | 183 +++++++++++++++++++++++++------------------------- 1 file changed, 92 insertions(+), 91 deletions(-) diff --git a/composer.json b/composer.json index ff6d69ef..5d86c85c 100644 --- a/composer.json +++ b/composer.json @@ -1,94 +1,95 @@ { - "name": "zhamao/framework", - "description": "High performance chat robot and web server development framework", - "minimum-stability": "stable", - "license": "Apache-2.0", - "extra": { - "zm": { - "exclude-annotation-path": [ - "src/ZM" - ] - }, - "hooks": { - "post-merge": "composer install", - "pre-commit": [ - "echo committing as $(git config user.name)", - "./vendor/bin/php-cs-fixer fix --dry-run --diff ./src" - ], - "pre-push": [ - "./vendor/bin/php-cs-fixer fix --dry-run --diff ./src", - "composer analyse" - ] - } - }, - "authors": [ - { - "name": "jerry", - "email": "admin@zhamao.me" - } - ], - "prefer-stable": true, - "bin": [ - "bin/start", - "bin/phpunit-swoole", - "bin/gendoc" - ], - "require": { - "php": "^7.2 || ^7.3 || ^7.4 || ^8.0 || ^8.1", - "ext-json": "*", - "ext-posix": "*", - "doctrine/dbal": "^2.13.1", - "dragonmantank/cron-expression": "^3.3", - "jelix/version": "^2.0", - "koriym/attributes": "^1.0", - "psy/psysh": "^0.11.2", - "symfony/console": "~5.0 || ~4.0 || ~3.0", - "symfony/polyfill-ctype": "^1.19", - "symfony/polyfill-mbstring": "^1.19", - "symfony/polyfill-php80": "^1.16", - "symfony/routing": "~5.0 || ~4.0 || ~3.0", - "zhamao/config": "^1.0", - "zhamao/connection-manager": "^1.0", - "zhamao/console": "^1.0", - "zhamao/request": "^1.1" - }, - "suggest": { - "ext-ctype": "Use C/C++ extension instead of polyfill will be more efficient", - "ext-mbstring": "Use C/C++ extension instead of polyfill will be more efficient", - "ext-pdo_mysql": "If you use mysql in framework, you will need this extension", - "ext-redis": "If you use Redis in framework, you will need this extension", - "league/climate": "Display columns and status in terminal" - }, - "autoload": { - "psr-4": { - "ZM\\": "src/ZM" - }, - "files": [ - "src/ZM/global_functions.php" - ] - }, - "autoload-dev": { - "psr-4": { - "Module\\": "src/Module", - "Custom\\": "src/Custom" - } - }, - "config": { - "optimize-autoloader": true, - "sort-packages": true - }, - "require-dev": { - "brainmaestro/composer-git-hooks": "^2.8", - "friendsofphp/php-cs-fixer": "^3.2 != 3.7.0", - "phpstan/phpstan": "^1.1", - "phpunit/phpunit": "^8.5 || ^9.0", - "swoole/ide-helper": "^4.5" - }, - "scripts": { - "post-install-cmd": [ - "[ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/cghooks add" - ], - "analyse": "phpstan analyse --memory-limit 300M -l 0 ./src", - "cs-fix": "php-cs-fixer fix $1" + "name": "zhamao/framework", + "description": "High performance chat robot and web server development framework", + "license": "Apache-2.0", + "authors": [ + { + "name": "jerry", + "email": "admin@zhamao.me" } + ], + "require": { + "php": "^7.2 || ^7.3 || ^7.4 || ^8.0 || ^8.1", + "ext-json": "*", + "ext-posix": "*", + "doctrine/dbal": "^2.13.1", + "dragonmantank/cron-expression": "^3.3", + "jelix/version": "^2.0", + "koriym/attributes": "^1.0", + "psy/psysh": "^0.11.2", + "symfony/console": "~5.0 || ~4.0 || ~3.0", + "symfony/polyfill-ctype": "^1.19", + "symfony/polyfill-mbstring": "^1.19", + "symfony/polyfill-php80": "^1.16", + "symfony/routing": "~5.0 || ~4.0 || ~3.0", + "zhamao/config": "^1.0", + "zhamao/connection-manager": "^1.0", + "zhamao/console": "^1.0", + "zhamao/request": "^1.1" + }, + "require-dev": { + "brainmaestro/composer-git-hooks": "^2.8", + "friendsofphp/php-cs-fixer": "^3.2 != 3.7.0", + "phpstan/phpstan": "^1.1", + "phpunit/phpunit": "^8.5 || ^9.0", + "roave/security-advisories": "dev-latest", + "swoole/ide-helper": "^4.5" + }, + "suggest": { + "ext-ctype": "Use C/C++ extension instead of polyfill will be more efficient", + "ext-mbstring": "Use C/C++ extension instead of polyfill will be more efficient", + "ext-pdo_mysql": "If you use mysql in framework, you will need this extension", + "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, + "autoload": { + "psr-4": { + "ZM\\": "src/ZM" + }, + "files": [ + "src/ZM/global_functions.php" + ] + }, + "autoload-dev": { + "psr-4": { + "Module\\": "src/Module", + "Custom\\": "src/Custom" + } + }, + "bin": [ + "bin/gendoc", + "bin/phpunit-swoole", + "bin/start" + ], + "config": { + "optimize-autoloader": true, + "sort-packages": true + }, + "extra": { + "hooks": { + "post-merge": "composer install", + "pre-commit": [ + "echo committing as $(git config user.name)", + "./vendor/bin/php-cs-fixer fix --dry-run --diff ./src" + ], + "pre-push": [ + "./vendor/bin/php-cs-fixer fix --dry-run --diff ./src", + "composer analyse" + ] + }, + "zm": { + "exclude-annotation-path": [ + "src/ZM" + ] + } + }, + "scripts": { + "post-install-cmd": [ + "[ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/cghooks add" + ], + "analyse": "phpstan analyse --memory-limit 300M -l 0 ./src", + "cs-fix": "php-cs-fixer fix $1" + } } From ac50e965681ff49367e12d6020eb753641fae8a6 Mon Sep 17 00:00:00 2001 From: sunxyw Date: Mon, 28 Mar 2022 16:26:04 +0800 Subject: [PATCH 2/8] update .gitignore --- .gitignore | 67 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index d9029397..140b6813 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,23 @@ -.idea/ -/src/test/ -/src/webconsole/config/ -/vendor/ +### Zhamao Framework ### /zm_data/ -composer.lock /resources/server.phar /distribute/ -/bin/.phpunit.result.cache /resources/zhamao.service -.phpunit.result.cache -.daemon_pid /runtime/ /tmp/ /temp/ /site/ -# go-cqhttp快速安装启动相关(可能被废弃) +# 进程锁文件 +.daemon_pid +.zm_worker_*.pid + +### Composer ### +composer.phar +/vendor/ +composer.lock + +### Go CQHTTP ### /ext/go-cqhttp/data/ /ext/go-cqhttp/logs/ /ext/go-cqhttp/config.hjson @@ -23,12 +25,53 @@ composer.lock /ext/go-cqhttp/go-cqhttp /ext/go-cqhttp/session.token -.zm_worker_*.pid +### Git ### +# 备份文件 +*.orig -# Git Hook 的相关锁文件 +# 解决 Merge 冲突时可能会自动生成的文件 +*.BACKUP.* +*.BASE.* +*.LOCAL.* +*.REMOTE.* +*_BACKUP_*.txt +*_BASE_*.txt +*_LOCAL_*.txt +*_REMOTE_*.txt + +# Git Hooks cghooks.lock -# Vuepress 相关文件 +### VuePress ### /node_modules/ /docs/.vuepress/dist/ package-lock.json + +### PHPUnit ### + +# 生成的文件 +/bin/.phpunit.result.cache +.phpunit.result.cache +.phpunit.cache + +# 本地配置 +/phpunit.xml + +# 构建目录 +/build/ + +### PhpStorm ### +# 兼容 PHPStorm 及其他 Jetbrains IDE + +# 除了代码格式配置和运行配置之外的所有文件 +.idea/* + +!.idea/codeStyles +!.idea/runConfigurations + +### Phive ### +/.phive/ +/tools/ + +### ASDF ### +/.tool-version From 37b5d954e94797e030b18f42b02a2ce16f1ca929 Mon Sep 17 00:00:00 2001 From: sunxyw Date: Mon, 28 Mar 2022 16:34:26 +0800 Subject: [PATCH 3/8] add phpunit config --- phpunit.xml.dist | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 phpunit.xml.dist diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 00000000..d6bdc65a --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,21 @@ + + + + + ./tests + + + + + + \ No newline at end of file From 700b854434398b91b5add8a8ffac0c3c0df52ce9 Mon Sep 17 00:00:00 2001 From: sunxyw Date: Mon, 28 Mar 2022 16:41:13 +0800 Subject: [PATCH 4/8] rename test folder --- bin/phpunit-swoole | 2 +- {test => tests}/ZM/Utils/DataProviderTest.php | 0 {test => tests}/ZM/Utils/Manager/ModuleManagerTest.php | 0 {test => tests}/ZM/Utils/MessageUtilTest.php | 0 {test => tests}/ZM/Utils/TerminalTest.php | 0 {test => tests}/ZM/Utils/ZMUtilTest.php | 0 {test => tests}/ZMTest/Mock/mock.php | 0 .../ZMTest/PassedTest/AnnotationParserRegisterTest.php | 0 {test => tests}/ZMTest/Testing/EventDispatcherTest.php | 0 {test => tests}/ZMTest/Testing/ModuleTest.php | 0 {test => tests}/bootstrap.php | 0 {test => tests}/route_test.php | 0 12 files changed, 1 insertion(+), 1 deletion(-) rename {test => tests}/ZM/Utils/DataProviderTest.php (100%) rename {test => tests}/ZM/Utils/Manager/ModuleManagerTest.php (100%) rename {test => tests}/ZM/Utils/MessageUtilTest.php (100%) rename {test => tests}/ZM/Utils/TerminalTest.php (100%) rename {test => tests}/ZM/Utils/ZMUtilTest.php (100%) rename {test => tests}/ZMTest/Mock/mock.php (100%) rename {test => tests}/ZMTest/PassedTest/AnnotationParserRegisterTest.php (100%) rename {test => tests}/ZMTest/Testing/EventDispatcherTest.php (100%) rename {test => tests}/ZMTest/Testing/ModuleTest.php (100%) rename {test => tests}/bootstrap.php (100%) rename {test => tests}/route_test.php (100%) diff --git a/bin/phpunit-swoole b/bin/phpunit-swoole index 0e2d1003..b480220e 100644 --- a/bin/phpunit-swoole +++ b/bin/phpunit-swoole @@ -59,7 +59,7 @@ require PHPUNIT_COMPOSER_INSTALL; $starttime = microtime(true); go(function () { try { - require_once __DIR__.'/../test/bootstrap.php'; + require_once __DIR__ . '/../tests/bootstrap.php'; PHPUnit\TextUI\Command::main(false); } catch (Exception $e) { echo $e->getMessage() . PHP_EOL; diff --git a/test/ZM/Utils/DataProviderTest.php b/tests/ZM/Utils/DataProviderTest.php similarity index 100% rename from test/ZM/Utils/DataProviderTest.php rename to tests/ZM/Utils/DataProviderTest.php diff --git a/test/ZM/Utils/Manager/ModuleManagerTest.php b/tests/ZM/Utils/Manager/ModuleManagerTest.php similarity index 100% rename from test/ZM/Utils/Manager/ModuleManagerTest.php rename to tests/ZM/Utils/Manager/ModuleManagerTest.php diff --git a/test/ZM/Utils/MessageUtilTest.php b/tests/ZM/Utils/MessageUtilTest.php similarity index 100% rename from test/ZM/Utils/MessageUtilTest.php rename to tests/ZM/Utils/MessageUtilTest.php diff --git a/test/ZM/Utils/TerminalTest.php b/tests/ZM/Utils/TerminalTest.php similarity index 100% rename from test/ZM/Utils/TerminalTest.php rename to tests/ZM/Utils/TerminalTest.php diff --git a/test/ZM/Utils/ZMUtilTest.php b/tests/ZM/Utils/ZMUtilTest.php similarity index 100% rename from test/ZM/Utils/ZMUtilTest.php rename to tests/ZM/Utils/ZMUtilTest.php diff --git a/test/ZMTest/Mock/mock.php b/tests/ZMTest/Mock/mock.php similarity index 100% rename from test/ZMTest/Mock/mock.php rename to tests/ZMTest/Mock/mock.php diff --git a/test/ZMTest/PassedTest/AnnotationParserRegisterTest.php b/tests/ZMTest/PassedTest/AnnotationParserRegisterTest.php similarity index 100% rename from test/ZMTest/PassedTest/AnnotationParserRegisterTest.php rename to tests/ZMTest/PassedTest/AnnotationParserRegisterTest.php diff --git a/test/ZMTest/Testing/EventDispatcherTest.php b/tests/ZMTest/Testing/EventDispatcherTest.php similarity index 100% rename from test/ZMTest/Testing/EventDispatcherTest.php rename to tests/ZMTest/Testing/EventDispatcherTest.php diff --git a/test/ZMTest/Testing/ModuleTest.php b/tests/ZMTest/Testing/ModuleTest.php similarity index 100% rename from test/ZMTest/Testing/ModuleTest.php rename to tests/ZMTest/Testing/ModuleTest.php diff --git a/test/bootstrap.php b/tests/bootstrap.php similarity index 100% rename from test/bootstrap.php rename to tests/bootstrap.php diff --git a/test/route_test.php b/tests/route_test.php similarity index 100% rename from test/route_test.php rename to tests/route_test.php From 6f5575b1551803d3aa9171f78562525daf479ce2 Mon Sep 17 00:00:00 2001 From: sunxyw Date: Mon, 28 Mar 2022 16:45:32 +0800 Subject: [PATCH 5/8] adjust phpunit config --- phpunit.xml.dist | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d6bdc65a..04a60377 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -15,6 +15,11 @@ ./tests + + + ./src/ZM + + From 4e9199c68e563bc5c07a7245b82e96379f84435d Mon Sep 17 00:00:00 2001 From: sunxyw Date: Mon, 28 Mar 2022 17:27:36 +0800 Subject: [PATCH 6/8] refactor phpunit-swoole --- bin/phpunit-swoole | 85 +++++++++++++++++---------------------------- composer.json | 3 +- phpunit.xml.dist | 5 ++- tests/bootstrap.php | 23 ++++++------ 4 files changed, 48 insertions(+), 68 deletions(-) mode change 100644 => 100755 bin/phpunit-swoole diff --git a/bin/phpunit-swoole b/bin/phpunit-swoole old mode 100644 new mode 100755 index b480220e..acce0232 --- a/bin/phpunit-swoole +++ b/bin/phpunit-swoole @@ -1,69 +1,48 @@ #!/usr/bin/env php - * Date: 2018/4/14 下午10:58 - */ +/** For Swoole coroutine tests */ -use Swoole\Coroutine; +$root = dirname(__DIR__); -Coroutine::set([ +co::set([ 'log_level' => SWOOLE_LOG_INFO, 'trace_flags' => 0 ]); -if (!ini_get('date.timezone')) { - ini_set('date.timezone', 'Asia/Shanghai'); -} +/* + * This file is part of PHPUnit. + * + * (c) Sebastian Bergmann + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ -foreach ([ - __DIR__ . '/../../../autoload.php', - __DIR__ . '/../../autoload.php', - __DIR__ . '/../vendor/autoload.php', - __DIR__ . '/vendor/autoload.php' - ] as $file -) { - if (file_exists($file)) { - define('PHPUNIT_COMPOSER_INSTALL', $file); - break; - } -} - -if (!defined('PHPUNIT_COMPOSER_INSTALL')) { +if (PHP_VERSION_ID <= 70100) { fwrite( STDERR, - 'You need to set up the project dependencies using Composer:' . PHP_EOL . PHP_EOL . - ' composer install' . PHP_EOL . PHP_EOL . - 'You can learn all about Composer on https://getcomposer.org/.' . PHP_EOL + 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 + ) ); die(1); -} else { - if (array_reverse(explode('/', __DIR__))[0] ?? '' === 'test') { - $vendor_dir = dirname(PHPUNIT_COMPOSER_INSTALL); - $bin_unit = "{$vendor_dir}/bin/phpunit"; - $unit_uint = "{$vendor_dir}/phpunit/phpunit/phpunit"; - if (file_exists($bin_unit)) { - @unlink($bin_unit); - @symlink(__FILE__, $bin_unit); - } - if (file_exists($unit_uint)) { - @unlink($unit_uint); - @symlink(__FILE__, $unit_uint); - } - } } -/** @noinspection PhpIncludeInspection */ -require PHPUNIT_COMPOSER_INSTALL; -$starttime = microtime(true); -go(function () { - try { - require_once __DIR__ . '/../tests/bootstrap.php'; - PHPUnit\TextUI\Command::main(false); - } catch (Exception $e) { - echo $e->getMessage() . PHP_EOL; - } + +if (!ini_get('date.timezone')) { + ini_set('date.timezone', 'UTC'); +} + +require $root . '/vendor/autoload.php'; + +sleep(1); + +go(static function () { + PHPUnit\TextUI\Command::main(false); + Swoole\Process::wait(); }); -Swoole\Event::wait(); -echo "Took " . round(microtime(true) - $starttime, 4) . "s\n"; + +Swoole\Event::wait(); \ No newline at end of file diff --git a/composer.json b/composer.json index 5d86c85c..78f95c36 100644 --- a/composer.json +++ b/composer.json @@ -90,6 +90,7 @@ "[ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/cghooks add" ], "analyse": "phpstan analyse --memory-limit 300M -l 0 ./src", - "cs-fix": "php-cs-fixer fix $1" + "cs-fix": "php-cs-fixer fix $1", + "test": "bin/phpunit-swoole" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 04a60377..49ebec24 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,6 @@ - diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 7b0bb7a0..4368c0da 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,7 +1,4 @@ Date: Mon, 28 Mar 2022 18:18:59 +0800 Subject: [PATCH 7/8] add .editorconfig to unify coding style --- .editorconfig | 15 ++++ composer.json | 186 +++++++++++++++++++++++++------------------------- 2 files changed, 108 insertions(+), 93 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..d9f90ab1 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_size = 2 \ No newline at end of file diff --git a/composer.json b/composer.json index 78f95c36..e13ef98d 100644 --- a/composer.json +++ b/composer.json @@ -1,96 +1,96 @@ { - "name": "zhamao/framework", - "description": "High performance chat robot and web server development framework", - "license": "Apache-2.0", - "authors": [ - { - "name": "jerry", - "email": "admin@zhamao.me" - } - ], - "require": { - "php": "^7.2 || ^7.3 || ^7.4 || ^8.0 || ^8.1", - "ext-json": "*", - "ext-posix": "*", - "doctrine/dbal": "^2.13.1", - "dragonmantank/cron-expression": "^3.3", - "jelix/version": "^2.0", - "koriym/attributes": "^1.0", - "psy/psysh": "^0.11.2", - "symfony/console": "~5.0 || ~4.0 || ~3.0", - "symfony/polyfill-ctype": "^1.19", - "symfony/polyfill-mbstring": "^1.19", - "symfony/polyfill-php80": "^1.16", - "symfony/routing": "~5.0 || ~4.0 || ~3.0", - "zhamao/config": "^1.0", - "zhamao/connection-manager": "^1.0", - "zhamao/console": "^1.0", - "zhamao/request": "^1.1" - }, - "require-dev": { - "brainmaestro/composer-git-hooks": "^2.8", - "friendsofphp/php-cs-fixer": "^3.2 != 3.7.0", - "phpstan/phpstan": "^1.1", - "phpunit/phpunit": "^8.5 || ^9.0", - "roave/security-advisories": "dev-latest", - "swoole/ide-helper": "^4.5" - }, - "suggest": { - "ext-ctype": "Use C/C++ extension instead of polyfill will be more efficient", - "ext-mbstring": "Use C/C++ extension instead of polyfill will be more efficient", - "ext-pdo_mysql": "If you use mysql in framework, you will need this extension", - "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, - "autoload": { - "psr-4": { - "ZM\\": "src/ZM" - }, - "files": [ - "src/ZM/global_functions.php" - ] - }, - "autoload-dev": { - "psr-4": { - "Module\\": "src/Module", - "Custom\\": "src/Custom" - } - }, - "bin": [ - "bin/gendoc", - "bin/phpunit-swoole", - "bin/start" - ], - "config": { - "optimize-autoloader": true, - "sort-packages": true - }, - "extra": { - "hooks": { - "post-merge": "composer install", - "pre-commit": [ - "echo committing as $(git config user.name)", - "./vendor/bin/php-cs-fixer fix --dry-run --diff ./src" - ], - "pre-push": [ - "./vendor/bin/php-cs-fixer fix --dry-run --diff ./src", - "composer analyse" - ] - }, - "zm": { - "exclude-annotation-path": [ - "src/ZM" - ] - } - }, - "scripts": { - "post-install-cmd": [ - "[ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/cghooks add" + "name": "zhamao/framework", + "description": "High performance chat robot and web server development framework", + "license": "Apache-2.0", + "authors": [ + { + "name": "jerry", + "email": "admin@zhamao.me" + } ], - "analyse": "phpstan analyse --memory-limit 300M -l 0 ./src", - "cs-fix": "php-cs-fixer fix $1", - "test": "bin/phpunit-swoole" - } + "require": { + "php": "^7.2 || ^7.3 || ^7.4 || ^8.0 || ^8.1", + "ext-json": "*", + "ext-posix": "*", + "doctrine/dbal": "^2.13.1", + "dragonmantank/cron-expression": "^3.3", + "jelix/version": "^2.0", + "koriym/attributes": "^1.0", + "psy/psysh": "^0.11.2", + "symfony/console": "~5.0 || ~4.0 || ~3.0", + "symfony/polyfill-ctype": "^1.19", + "symfony/polyfill-mbstring": "^1.19", + "symfony/polyfill-php80": "^1.16", + "symfony/routing": "~5.0 || ~4.0 || ~3.0", + "zhamao/config": "^1.0", + "zhamao/connection-manager": "^1.0", + "zhamao/console": "^1.0", + "zhamao/request": "^1.1" + }, + "require-dev": { + "brainmaestro/composer-git-hooks": "^2.8", + "friendsofphp/php-cs-fixer": "^3.2 != 3.7.0", + "phpstan/phpstan": "^1.1", + "phpunit/phpunit": "^8.5 || ^9.0", + "roave/security-advisories": "dev-latest", + "swoole/ide-helper": "^4.5" + }, + "suggest": { + "ext-ctype": "Use C/C++ extension instead of polyfill will be more efficient", + "ext-mbstring": "Use C/C++ extension instead of polyfill will be more efficient", + "ext-pdo_mysql": "If you use mysql in framework, you will need this extension", + "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, + "autoload": { + "psr-4": { + "ZM\\": "src/ZM" + }, + "files": [ + "src/ZM/global_functions.php" + ] + }, + "autoload-dev": { + "psr-4": { + "Module\\": "src/Module", + "Custom\\": "src/Custom" + } + }, + "bin": [ + "bin/gendoc", + "bin/phpunit-swoole", + "bin/start" + ], + "config": { + "optimize-autoloader": true, + "sort-packages": true + }, + "extra": { + "hooks": { + "post-merge": "composer install", + "pre-commit": [ + "echo committing as $(git config user.name)", + "./vendor/bin/php-cs-fixer fix --dry-run --diff ./src" + ], + "pre-push": [ + "./vendor/bin/php-cs-fixer fix --dry-run --diff ./src", + "composer analyse" + ] + }, + "zm": { + "exclude-annotation-path": [ + "src/ZM" + ] + } + }, + "scripts": { + "post-install-cmd": [ + "[ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/cghooks add" + ], + "analyse": "phpstan analyse --memory-limit 300M -l 0 ./src", + "cs-fix": "php-cs-fixer fix $1", + "test": "bin/phpunit-swoole" + } } From f450b8d863866291785a37b65fb02fcd57699f9c Mon Sep 17 00:00:00 2001 From: sunxyw Date: Mon, 28 Mar 2022 18:19:48 +0800 Subject: [PATCH 8/8] change phpunit default timezone to Asia/Shanghai --- bin/phpunit-swoole | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/phpunit-swoole b/bin/phpunit-swoole index acce0232..5c16093f 100755 --- a/bin/phpunit-swoole +++ b/bin/phpunit-swoole @@ -33,7 +33,7 @@ if (PHP_VERSION_ID <= 70100) { } if (!ini_get('date.timezone')) { - ini_set('date.timezone', 'UTC'); + ini_set('date.timezone', 'Asia/Shanghai'); } require $root . '/vendor/autoload.php'; @@ -45,4 +45,4 @@ go(static function () { Swoole\Process::wait(); }); -Swoole\Event::wait(); \ No newline at end of file +Swoole\Event::wait();