diff --git a/Makefile b/Makefile
index cc28bec99..bf8fab970 100644
--- a/Makefile
+++ b/Makefile
@@ -16,17 +16,31 @@ help:
update:
git checkout . && git pull
+ installcli: ## Install the swoft releasecli tool from github
+installcli:
+ cd ~
+ git clone https://github.com/swoftlabs/swoft-releasecli
+ cd swoft-releasecli; \
+ ln -s $PWD/bin/releasecli /usr/local/bin/releasecli; \
+ chmod a+x bin/releasecli
+
+ updatecli: ## Update the swoft releasecli tool from github
+updatecli:
+ cd ~/swoft-releasecli; \
+ git pull; \
+ chmod a+x bin/releasecli
+
addrmt: ## Add the remote repository address of each component to the local remote
-addrmt:
- php dtool.php git:addrmt --all
+addrmt: update
+ releasecli git:addrmt --all
fpush: ## Push all update to remote sub-repo by git push with '--force'
-fpush:
- php dtool.php git:fpush --all
+fpush: update
+ releasecli git:fpush --all
release: ## Release all sub-repo to new tag version and push to remote repo. eg: tag=v2.0.3
release:
- php dtool.php tag:release --all -y -t $(TAG)
+ releasecli tag:release --all -y -t $(TAG)
sami: ## Gen classes docs by sami.phar
classdoc:
diff --git a/README.md b/README.md
index 349b868b7..57df1a07e 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
# Swoft Component
[![Actions Status](https://github.com/swoft-cloud/swoft-component/workflows/Unit-tests/badge.svg)](https://github.com/swoft-cloud/swoft-component/actions)
+[![Build Status](https://travis-ci.org/swoft-cloud/swoft-component.svg?branch=master)](https://travis-ci.org/swoft-cloud/swoft-component)
This repository is used to manage all swoft core components.
@@ -23,7 +24,7 @@ Add require to `composer.json`
Install:
-```json
+```bash
composer update
```
@@ -60,6 +61,10 @@ phpdbg -dauto_globals_jit=Off -qrr /usr/local/bin/phpunit --coverage-text
phpdbg -dauto_globals_jit=Off -qrr run.php --coverage-text -c src/event/phpunit.xml
```
+## Releases
+
+Please see https://github.com/swoftlabs/swoft-releasecli
+
## Document
- [中文文档](https://www.swoft.org/docs)
diff --git a/README.zh-CN.md b/README.zh-CN.md
index c34d287c5..68e9c977a 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -1,12 +1,15 @@
# Swoft Component
+[![Actions Status](https://github.com/swoft-cloud/swoft-component/workflows/Unit-tests/badge.svg)](https://github.com/swoft-cloud/swoft-component/actions)
+[![Build Status](https://travis-ci.org/swoft-cloud/swoft-component.svg?branch=master)](https://travis-ci.org/swoft-cloud/swoft-component)
+
这里是swoft基础和核心组件的开发仓库,所有的核心组件都是由这里分发出去的。
## [English](README.md)
## 如何使用
-Add require to `composer.json`
+添加组件到`composer.json`
```json
"require": {
@@ -14,15 +17,15 @@ Add require to `composer.json`
}
```
-Install:
+安装:
-```json
+```bash
composer update
```
### 单元测试
-Quick run tests for component:
+快速运行测试:
```bash
// For all components
@@ -33,7 +36,7 @@ Quick run tests for component:
./phpunit.sh event
```
-Only tests an special component:
+测试指定的组件:
```bash
./phpunit.sh event
@@ -43,7 +46,7 @@ php run.php -c src/event/phpunit.xml
php run.php -c src/event/phpunit.xml --filter testAddModule
```
-Output coverage data:
+输出测试覆盖率:
```bash
// output coverage. require xdebug ext
@@ -53,6 +56,10 @@ phpdbg -dauto_globals_jit=Off -qrr /usr/local/bin/phpunit --coverage-text
phpdbg -dauto_globals_jit=Off -qrr run.php --coverage-text -c src/event/phpunit.xml
```
+## 版本发布
+
+需要使用工具 https://github.com/swoftlabs/swoft-releasecli
+
## 使用文档
- [中文文档](https://www.swoft.org/docs)
diff --git a/dtool.php b/dtool.php
deleted file mode 100644
index 04ce068dd..000000000
--- a/dtool.php
+++ /dev/null
@@ -1,37 +0,0 @@
-addByConfig($gi = new GitFindTag(), $gi->getHelpConfig());
-$cli->addByConfig($drt = new DeleteRemoteTag(), $drt->getHelpConfig());
-$cli->addByConfig($grt = new GitReleaseTag(), $grt->getHelpConfig());
-$cli->addByConfig($gar = new GitAddRemote(), $gar->getHelpConfig());
-$cli->addByConfig($gfp = new GitForcePush(), $gfp->getHelpConfig());
-$cli->addByConfig($gsp1 = new GitSubtreePush(), $gsp1->getHelpConfig());
-$cli->addByConfig($gsp2 = new GitSubtreePull(), $gsp2->getHelpConfig());
-
-$cli->addByConfig($cmd = new GenReadme(), $cmd->getHelpConfig());
-$cli->addByConfig($cmd = new GenVersion(), $cmd->getHelpConfig());
-$cli->addByConfig($cmd = new UpdateSwooleVer(), $cmd->getHelpConfig());
-$cli->addByConfig($cmd = new ListComponents(), $cmd->getHelpConfig());
-
-$cli->run();
diff --git a/phpunit.xml b/phpunit.xml
index 8d38abcd8..920915b40 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -13,12 +13,12 @@
stopOnFailure="false">
- ./test/unit
+ test/unit
- ./src/*
+ src/*
-
\ No newline at end of file
+
diff --git a/run.php b/run.php
index 55974b80f..99431cd0c 100755
--- a/run.php
+++ b/run.php
@@ -19,15 +19,9 @@
* file that was distributed with this source code.
*/
if (version_compare('7.1.0', PHP_VERSION, '>')) {
- fwrite(
- STDERR,
- sprintf(
- 'This version of PHPUnit is supported on PHP 7.1 and PHP 7.2.' . PHP_EOL .
- 'You are using PHP %s (%s).' . PHP_EOL,
- PHP_VERSION,
- PHP_BINARY
- )
- );
+ fwrite(STDERR,
+ sprintf('This version of PHPUnit is supported on PHP 7.1 and PHP 7.2.' . PHP_EOL . 'You are using PHP %s (%s).' . PHP_EOL,
+ PHP_VERSION, PHP_BINARY));
die(1);
}
@@ -37,11 +31,10 @@
// add loader file
foreach ([
- __DIR__ . '/../../autoload.php',
- __DIR__ . '/../vendor/autoload.php',
- __DIR__ . '/vendor/autoload.php'
- ] as $__loader_file
-) {
+ __DIR__ . '/../../autoload.php',
+ __DIR__ . '/../vendor/autoload.php',
+ __DIR__ . '/vendor/autoload.php'
+] as $__loader_file) {
if (file_exists($__loader_file)) {
define('PHPUNIT_COMPOSER_INSTALL', $__loader_file);
break;
@@ -49,12 +42,8 @@
}
if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
- 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
- );
+ 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);
die(1);
}
@@ -79,6 +68,28 @@
require PHPUNIT_COMPOSER_INSTALL;
+// php run.php -c src/websocket-server/phpunit.xml
+// SWOFT_TEST_SERVER: http, ws, rpc, tcp
+if ($srvType = (string)getenv('SWOFT_TEST_SERVER')) {
+ // Output: "php is /usr/local/bin/php"
+ [$ok, $ret,] = \Swoft\Stdlib\Helper\Sys::run('type php');
+ if (0 !== $ok) {
+ exit('php not found');
+ }
+
+ $php = substr(trim($ret), 7);
+ $proc = new \Swoole\Process(function (\Swoole\Process $proc) use ($php) {
+ // $proc->exec($php, [ $dir . '/test/bin/swoft', 'ws:start');
+ $proc->exec($php, ['test/bin/swoft', 'ws:start']);
+ });
+ $pid = $proc->start();
+ echo "Swoft server started, PID $pid\n";
+
+ // wait server starting...
+ sleep(2);
+ echo file_get_contents('http://127.0.0.1:18308/hi');
+}
+
$status = 0;
\Swoft\Co::run(function () {
// Status
@@ -88,8 +99,14 @@
$status = Command::main(false);
} catch (ExitException $e) {
$status = $e->getCode();
- echo 'ExitException: ' .$e->getMessage(), "\n";
+ echo 'ExitException: ' . $e->getMessage(), "\n";
}
});
+if (isset($pid) && $pid > 0) {
+ echo "Stop server on tests end. PID $pid";
+ $ok = \Swoole\Process::kill($pid, 15);
+ echo $ok ? " OK\n" : " FAIL\n";
+}
+
exit($status);
diff --git a/script/Command/BaseCommand.php b/script/Command/BaseCommand.php
deleted file mode 100644
index f139adfb0..000000000
--- a/script/Command/BaseCommand.php
+++ /dev/null
@@ -1,128 +0,0 @@
-baseDir = BASE_PATH;
- $this->libsDir = BASE_PATH . '/src/';
- $this->cpuNum = swoole_cpu_num();
- }
-
- /**
- * @param App $app
- * @param string $allOpt Default is --all
- *
- * @return Generator|void
- */
- protected function findComponents(App $app, string $allOpt = 'all')
- {
- // For all components
- if ($app->getOpt($allOpt, false)) {
- $flags = GLOB_ONLYDIR | GLOB_MARK;
- $pattern = $this->libsDir . '*';
-
- yield from glob($pattern, $flags);
- return;
- }
-
- // For some components
- if (!$names = $app->getArgs()) {
- throw new InvalidArgumentException('Please input component names arguments');
- }
-
- foreach ($names as $name) {
- $dir = $this->libsDir . $name;
- if (!is_dir($dir)) {
- echo Color::render("Invalid component name: $name\n", 'error');
- continue;
- }
-
- yield $dir . '/';
- }
- }
-
- /**
- * @param string $cmd
- * @param string $workDir
- * @param bool $coRun
- *
- * @return array
- */
- public static function exec(string $cmd, string $workDir = '', bool $coRun = false): array
- {
- Color::println("> $cmd", 'yellow');
-
- if ($coRun) {
- $ret = Coroutine::exec($cmd);
- if ((int)$ret['code'] !== 0) {
- $msg = "Exec command error. Output: {$ret['output']}";
- Color::println($msg, 'error');
- }
-
- return $ret;
- }
-
- // normal run
- [$code, $output,] = Sys::run($cmd, $workDir);
- if ($code !== 0) {
- $msg = "Exec command error. Output: {$output}";
- Color::println($msg, 'error');
- }
-
- return [
- 'code' => $code,
- 'output' => $output,
- ];
- }
-
- /**
- * @param string $message
- */
- public static function gitCommit(string $message): void
- {
- $ret = self::exec(sprintf('git add . && git commit -m "%s"', $message));
- if ((int)$ret['code'] === 0) {
- echo $ret['output'] . PHP_EOL;
- }
- }
-}
diff --git a/script/Command/DeleteRemoteTag.php b/script/Command/DeleteRemoteTag.php
deleted file mode 100644
index b1ab4f133..000000000
--- a/script/Command/DeleteRemoteTag.php
+++ /dev/null
@@ -1,116 +0,0 @@
- The tag version. eg: v2.0.2
-
-Example:
- {{fullCmd}} -t v2.0.3 --all
- {{fullCmd}} -t v2.0.3 event
- {{fullCmd}} -t v2.0.3 event config
-
-STR;
-
- return [
- 'name' => 'tag:delete',
- 'desc' => 'delete git remote tag for components',
- 'usage' => 'tag:delete [options] [arguments]',
- 'help' => $help,
- ];
- }
-
- public function __invoke(App $app): void
- {
- $tag = $app->getStrOpt('tag', $app->getStrOpt('t'));
- if (!$tag) {
- Color::println('Please input an exist tag for delete', 'error');
- return;
- }
-
- // operate the component project
- $first = $app->getArg(0);
- if ($first === self::MAIN) {
- $this->deleteForMainProject($tag);
- return;
- }
-
- $this->debug = $app->getBoolOpt('debug');
-
- // create runner
- $runner = Scheduler::new();
-
- foreach ($this->findComponents($app) as $dir) {
- $name = basename($dir);
- $cmd = "git push $name :refs/tags/$tag";
-
- $runner->add(function () use ($name, $cmd) {
- Color::println("====== Delete remote tag for component:【{$name}】");
- Color::println("> $cmd", 'yellow');
-
- if ($this->debug) {
- Color::println('[DEBUG] use co::sleep(1) to mock remote operation');
- Coroutine::sleep(1);
- return;
- }
-
- $ret = Coroutine::exec($cmd);
- if ((int)$ret['code'] !== 0) {
- $msg = "Delete remote tag fail of the {$name}. Output: {$ret['output']}";
- Color::println($msg, 'error');
- $this->result[$name] = 'Fail';
- return;
- }
-
- $this->result[$name] = 'OK';
- Color::println("- Complete for {$name}\n", 'cyan');
- });
- }
-
- $runner->start();
-
- Color::println("\nDelete Tag({$tag}) Complete", 'cyan');
- Show::aList($this->result);
- }
-
- private function deleteForMainProject(string $tag): void
- {
- $cmd = "git tag --delete $tag && git push origin :refs/tags/$tag";
- Color::println("> $cmd", 'yellow');
-
- $ret = Coroutine::exec($cmd);
- if ((int)$ret['code'] !== 0) {
- $msg = "Delete remote tag fail of the component. Output: {$ret['output']}";
- Color::println($msg, 'error');
- return;
- }
-
- Color::println("\nDelete Tag({$tag}) Complete", 'cyan');
- }
-}
diff --git a/script/Command/GenReadme.php b/script/Command/GenReadme.php
deleted file mode 100644
index be95341af..000000000
--- a/script/Command/GenReadme.php
+++ /dev/null
@@ -1,88 +0,0 @@
- 'gen:readme',
- 'desc' => 'generate readme file for swoft component(s)',
- 'usage' => 'gen:readme NAME(s)',
- 'help' => $help,
- ];
- }
-
- public function __construct()
- {
- parent::__construct();
-
- $this->tplFile = BASE_PATH . '/script/template/readme.tpl';
- }
-
- public function __invoke(App $app): void
- {
- $tplStr = file_get_contents($this->tplFile);
-
- foreach ($this->findComponents($app) as $dir) {
- $this->genReadmeFile($tplStr, $dir);
- }
-
- echo Color::render("Complete\n", 'cyan');
- }
-
- /**
- * @param string $str
- * @param string $dir
- */
- private function genReadmeFile(string $str, string $dir): void
- {
- $name = basename($dir);
-
- echo Color::render("Generate README.md for the component: $name\n", 'info');
-
- $data = [
- '{{component}}' => $name,
- '{{componentUpWord}}' => ucwords(str_replace('-', ' ', $name)),
- ];
-
- $str = strtr($str, $data);
-
- file_put_contents($dir . 'README.md', $str);
- }
-}
diff --git a/script/Command/GenTravisYml.php b/script/Command/GenTravisYml.php
deleted file mode 100644
index 092531c6c..000000000
--- a/script/Command/GenTravisYml.php
+++ /dev/null
@@ -1,101 +0,0 @@
-tplFile = dirname(__DIR__) . '/template/.travis.yml.tpl';
- }
-
- public function getHelpConfig(): array
- {
- $help = << 'gen:travis',
- 'desc' => 'generate an travis yml file for components',
- 'usage' => 'gen:travis NAME(s)',
- 'help' => $help,
- ];
- }
-
- public function __invoke(App $app): void
- {
- $defVersion = '';
- if (defined('SWOOLE_VERSION')) {
- $defVersion = 'v' . SWOOLE_VERSION;
- }
-
- if (!$version = $app->getStrOpt('v', $defVersion)) {
- echo Color::render("Please input an version by option: -v\n", 'error');
- return;
- }
-
- $this->version = $version;
-
- $tplStr = file_get_contents($this->tplFile);
-
- foreach ($this->findComponents($app) as $dir) {
- $this->genReadmeFile($tplStr, $dir);
- }
-
- echo Color::render("Complete\n", 'cyan');
- }
-
- /**
- * @param string $str
- * @param string $dir
- */
- private function genReadmeFile(string $str, string $dir): void
- {
- $name = basename($dir);
- if (in_array($name, ['db', 'redis'], true)) {
- echo Color::render("Skip the component: $name\n", 'yellow');
- return;
- }
-
- echo Color::render("Generate .travis.yml for the component: $name\n", 'info');
-
- $data = [
- '{{SWOOLE_VERSION}}' => $this->version,
- ];
-
- file_put_contents($dir . '.travis.yml', strtr($str, $data));
- }
-}
diff --git a/script/Command/GenVersion.php b/script/Command/GenVersion.php
deleted file mode 100644
index 914af934b..000000000
--- a/script/Command/GenVersion.php
+++ /dev/null
@@ -1,117 +0,0 @@
- 'gen:version',
- 'desc' => 'generate an version info to composer.json',
- 'usage' => 'gen:version NAME(s)',
- 'help' => $help,
- ];
- }
-
- public function __invoke(App $app): void
- {
- if (!$version = $app->getStrOpt('v')) {
- echo Color::render("Please input an version by option: -v\n", 'error');
- return;
- }
-
- $this->version = $version;
-
- echo Color::render("Input new version is: $version\n", 'info');
-
- foreach ($this->findComponents($app) as $dir) {
- $this->addVersionToComposer($dir . 'composer.json', basename($dir));
- }
-
- if ($this->updated > 0 && $app->getBoolOpt('c')) {
- self::gitCommit("update: add {$this->version} for all component composer.json");
- }
-
- echo Color::render("Complete\n", 'cyan');
- }
-
- /**
- * @param string $file
- * @param string $name
- */
- private function addVersionToComposer(string $file, string $name = ''): void
- {
- $text = file_get_contents($file);
- $name = $name ?: basename(dirname($file));
-
- // New version line
- $replace = sprintf('"version": "%s"', $this->version);
-
- $count = 0;
- $text = preg_replace(self::MATCH_VERSION, $replace, $text, 1, $count);
-
- // Not found, is first add.
- if (1 !== $count) {
- $replace = self::ADD_POSITION . "\n {$replace},";
- $text = str_replace(self::ADD_POSITION, $replace, $text, $count);
-
- $this->updated++;
- }
-
- if (0 === $count) {
- echo Color::render("Failed for add version for component: $name\n", 'error');
- return;
- }
-
- $this->updated += $count;
-
- echo Color::render("Append version for the component: $name\n", 'info');
-
- file_put_contents($file, $text);
- }
-}
diff --git a/script/Command/GitAddRemote.php b/script/Command/GitAddRemote.php
deleted file mode 100644
index da77c14ac..000000000
--- a/script/Command/GitAddRemote.php
+++ /dev/null
@@ -1,74 +0,0 @@
- 'git:addrmt',
- 'desc' => 'Add the remote repository address of each component',
- 'usage' => 'git:addrmt [options] [arguments]',
- 'help' => $help,
- ];
- }
-
- public function __invoke(App $app)
- {
- $prefix = self::REMOTE_PREFIX;
-
- foreach ($this->findComponents($app) as $dir) {
- $name = basename($dir);
- Color::println("===== Add remote for $name");
-
- $check = "git remote -v | grep swoft-{$name}.git";
- Color::println('> ' . $check, 'yellow');
-
- [$code, , ] = Sys::run($check, $this->baseDir);
- if ($code === 0) {
- Color::println("The remote '{$name}' exist, skip add");
- continue;
- }
-
- $cmd = "git remote add $name $prefix{$name}.git";
- Color::println('> ' . $cmd, 'yellow');
-
- [$code, $ret, ] = Sys::run($cmd, $this->baseDir);
- if ($code !== 0) {
- echo "Add remote error for '{$name}'. Return: $ret\n";
- continue;
- }
-
- Color::println('> OK');
- }
-
- Color::println('Complete');
- }
-}
diff --git a/script/Command/GitFindTag.php b/script/Command/GitFindTag.php
deleted file mode 100644
index 09f0706e2..000000000
--- a/script/Command/GitFindTag.php
+++ /dev/null
@@ -1,129 +0,0 @@
- v2.0.3
- --only-tag Only output tag information
-
-Example:
- {{fullCmd}}
- {{fullCmd}} --only-tag
- {{fullCmd}} -d ../view --next-tag
- {{fullCmd}} -d ../view --next-tag --only-tag
-
-STR;
-
- return [
- 'name' => 'tag:find',
- 'desc' => 'get the latest/next tag from the project directory',
- 'usage' => 'tag:find [DIR]',
- 'help' => $help,
- ];
- }
-
- /**
- * echo $(php dtool.php git:tag --only-tag -d ../view)
- *
- * @param App $app
- */
- public function __invoke(App $app): void
- {
- $dir = $app->getOpt('dir', $app->getOpt('d'));
- $dir = $dir ?: $app->getPwd();
-
- $onlyTag = $app->getBoolOpt('only-tag');
- $nextTag = $app->getBoolOpt('next-tag');
-
- $tagName = $this->findTag($dir, !$onlyTag);
- if (!$tagName) {
- Show::error('No any tags of the project', -2);
- return;
- }
-
- $title = 'The latest tag: %s';
-
- if ($nextTag) {
- $title = "The next tag: %s (current: {$tagName})";
- $nodes = explode('.', $tagName);
-
- $lastNum = array_pop($nodes);
- $nodes[] = (int)$lastNum + 1;
- $tagName = implode('.', $nodes);
- }
-
- if ($onlyTag) {
- echo $tagName;
- return;
- }
-
- Show::writef("$title", $tagName);
- }
-
- /**
- * @param string $workDir
- * @param bool $showInfo
- *
- * @return string
- */
- public function findTag(string $workDir, bool $showInfo = false): string
- {
- if (!is_dir($workDir)) {
- return '';
- }
-
- $cmd = 'git describe --tags $(git rev-list --tags --max-count=1)';
-
- if ($showInfo) {
- $info = [
- 'command' => $cmd,
- 'workDir' => $workDir,
- ];
- Show::aList($info, 'info');
- }
-
- [$code, $tagName,] = Sys::run($cmd, $workDir);
- if ($code !== 0) {
- return '';
- }
-
- return trim($tagName);
- }
-
- /**
- * Get next tag version. eg: v2.0.3 => v2.0.4
- *
- * @param string $tagName
- *
- * @return string
- */
- public function buildNextTag(string $tagName): string
- {
- $nodes = explode('.', $tagName);
-
- $lastNum = array_pop($nodes);
- $nodes[] = (int)$lastNum + 1;
-
- return implode('.', $nodes);
- }
-}
diff --git a/script/Command/GitForcePush.php b/script/Command/GitForcePush.php
deleted file mode 100644
index b33adf53d..000000000
--- a/script/Command/GitForcePush.php
+++ /dev/null
@@ -1,79 +0,0 @@
- 'git:fpush',
- 'desc' => 'Force push all update to remote sub-repo by git push with --force',
- 'usage' => 'git:fpush [options] [arguments]',
- 'help' => $help,
- ];
- }
-
- public function __invoke(App $app)
- {
- $targetBranch = 'master';
- $this->debug = $app->getBoolOpt('debug');
-
- $result = [];
- $runner = Scheduler::new();
-
- // force push:
- // git push tcp-server `git subtree split --prefix src/tcp-server master`:master --force
- foreach ($this->findComponents($app) as $dir) {
- $name = basename($dir);
- // 先分割,在强推上去
- $cmd = "git push {$name} `git subtree split --prefix src/{$name} master`:{$targetBranch} --force";
-
- $runner->add(function () use ($name, $cmd, &$result) {
- Color::println("\n====== Push the component:【{$name}】");
- Color::println("> $cmd", 'yellow');
-
- $ret = Coroutine::exec($cmd);
- if ((int)$ret['code'] !== 0) {
- $msg = "Push to remote fail of the {$name}. Output: {$ret['output']}";
- Color::println($msg, 'error');
- $result[$name] = 'Fail';
- return;
- }
-
- $result[$name] = 'OK';
- Color::println("- Complete for {$name}\n", 'cyan');
- Coroutine::sleep(1);
- });
- }
-
- $runner->start();
- Color::println("\nForce Push Complete", 'cyan');
- Show::aList($result);
- }
-}
diff --git a/script/Command/GitHubInfo.php b/script/Command/GitHubInfo.php
deleted file mode 100644
index 550be0efb..000000000
--- a/script/Command/GitHubInfo.php
+++ /dev/null
@@ -1,19 +0,0 @@
- The tag version. eg: v2.0.2
- -y, --yes No confirmation required
-
-Example:
- {{fullCmd}} -t v2.0.3 --all
- {{fullCmd}} -t v2.0.3 event
- {{fullCmd}} -t v2.0.3 event config
-
-STR;
-
- // --recopy Recopy components codes to tmp dir for operation
- return [
- 'name' => 'tag:release',
- 'desc' => 'Release all sub-repo to new tag version and push to remote repo',
- 'usage' => 'tag:release [options] [arguments]',
- 'help' => $help,
- ];
- }
-
- public function __invoke(App $app)
- {
- $newTag = $app->getStrOpt('tag', $app->getStrOpt('t'));
- if (!$newTag) {
- Color::println('Please input an new tag for release. eg: v2.0.4', 'error');
- return;
- }
-
- // operate the component project
- if ($app->getArg(0) === self::MAIN) {
- self::doTagAndPush('component', $newTag, $this->baseDir);
- Color::println("\nRelease Tag({$newTag}) Complete", 'cyan');
- return;
- }
-
- $this->tmpDir = '/tmp/sub-repos';
- $this->debug = $app->getBoolOpt('debug');
- $debugText = $this->debug ? 'True' : 'False';
-
- Color::println("Will release new tag: $newTag (DEBUG: $debugText)");
-
- $yes = $app->getBoolOpt('yes', $app->getBoolOpt('y'));
- if (!$yes && Interact::unConfirm('Now, continue')) {
- Color::println('Bye Bye');
- return;
- }
-
- // $targetBranch = 'master';
- $makeTmpDir = "rm -rf {$this->tmpDir} && mkdir {$this->tmpDir}";
-
- Color::println("> $makeTmpDir", 'yellow');
- [$code, $msg,] = Sys::run($makeTmpDir);
- if ($code !== 0) {
- Color::println('[ERROR]' . $msg, 'error');
- return;
- }
-
- $finder = new GitFindTag();
- $runner = Scheduler::new();
-
- foreach ($this->findComponents($app) as $dir) {
- $this->releaseTag($runner, $finder, basename($dir), $newTag);
- }
-
- $runner->start();
- Color::println("\nRelease Tag({$newTag}) Complete", 'cyan');
- Show::aList($this->result);
- }
-
- /**
- * @param Scheduler $runner
- * @param GitFindTag $finder
- * @param string $name
- * @param string $newTag
- */
- private function releaseTag(Scheduler $runner, GitFindTag $finder, string $name, string $newTag): void
- {
- $tmpDir = $this->tmpDir;
- $repoDir = $tmpDir . '/' . $name;
-
- // - ensure no repo dir
- $rmRepoDir = "rm -rf $repoDir";
- Color::println("> $rmRepoDir", 'yellow');
-
- [$code, $msg,] = Sys::run($rmRepoDir);
- if ($code !== 0) {
- $msg = "Remove repo dir fail of the {$name}. Output: {$msg}";
- Color::println($msg, 'error');
- return;
- }
-
- // $remoteTpl = 'https://github.com/swoft-cloud/swoft-%s.git';
- $remoteTpl = 'git@github.com:swoft-cloud/swoft-%s.git';
- $remoteUrl = sprintf($remoteTpl, $name);
-
- // - clone remote repo
- $cloneCmd = "cd {$tmpDir} && git clone {$remoteUrl} $name";
- Color::println("> $cloneCmd", 'yellow');
-
- if (!$this->debug) {
- [$code, $msg,] = Sys::run($cloneCmd, $tmpDir);
-
- if ($code !== 0) {
- $msg = "Clone repo fail of the {$name}. Output: {$msg}";
- Color::println($msg, 'error');
- return;
- }
- }
-
- // - check last tag
- Color::println("------ Check last tag for thr component: $name");
-
- $lastTag = $finder->findTag($repoDir);
- if ($lastTag === $newTag) {
- Color::println("The component '{$name}' has been exists tag: {$newTag}, skip release");
- return;
- }
-
- $runner->add(function () use ($name, $newTag, $repoDir) {
- $ok = self::doTagAndPush($name, $newTag, $repoDir);
-
- // Save result status
- $this->result[$name] = $ok ? 'OK' : 'Fail';
- Color::println("- Complete for {$name}\n", 'cyan');
- });
- }
-
- /**
- * @param string $name
- * @param string $newTag
- * @param string $repoDir
- *
- * @return bool
- */
- private static function doTagAndPush(string $name, string $newTag, string $repoDir): bool
- {
- $addTagCmd = "cd {$repoDir} && git tag -a {$newTag} -m \"Release {$newTag}\"";
-
- Color::println("====== Release the component:【{$name}】");
- Color::println("> $addTagCmd", 'yellow');
-
- // - add new tag
- $ret = Coroutine::exec($addTagCmd);
- if ((int)$ret['code'] !== 0) {
- $msg = "Add tag fail of the {$name}. Output: {$ret['output']}";
- Color::println($msg, 'error');
- return false;
- }
-
- $pushTagCmd = "cd {$repoDir} && git push origin {$newTag}";
- Color::println("> $pushTagCmd", 'yellow');
-
- // - push new tag
- $ret = Coroutine::exec($pushTagCmd);
- if ((int)$ret['code'] !== 0) {
- $msg = "Push tag fail of the {$name}. Output: {$ret['output']}";
- Color::println($msg, 'error');
- return false;
- }
-
- return true;
- }
-}
diff --git a/script/Command/GitSubtreePull.php b/script/Command/GitSubtreePull.php
deleted file mode 100644
index 8bf3976a4..000000000
--- a/script/Command/GitSubtreePull.php
+++ /dev/null
@@ -1,89 +0,0 @@
- 'git:spull',
- 'desc' => 'Pull all update from remote sub-repo by git subtree pull',
- 'usage' => 'git:spull [options] [arguments]',
- 'help' => $help,
- ];
- }
-
- public function __invoke(App $app)
- {
- if ($app->getCommand()) {
- Color::println('Please use git:fpush instead of the command', 'error');
- return;
- }
-
- $targetBranch = 'master';
- $this->debug = $app->getBoolOpt('debug');
-
- $result = [];
- $runner = Scheduler::new();
-
- // git subtree pull --prefix=src/annotation git@github.com:swoft-cloud/swoft-annotation.git master --squash
- // git subtree pull --prefix=src/stdlib stdlib master
- foreach ($this->findComponents($app) as $dir) {
- $name = basename($dir);
- $cmd = "git subtree pull --prefix=src/{$name} {$name} {$targetBranch} --squash";
-
- $runner->add(function () use ($name, $cmd, &$result) {
- Color::println("\n====== Pull the component:【{$name}】");
- Color::println("> $cmd", 'yellow');
-
- if ($this->debug) {
- Color::println('[DEBUG] use co::sleep(2) to mock remote operation');
- Coroutine::sleep(2);
- return;
- }
-
- $ret = Coroutine::exec($cmd);
- if ((int)$ret['code'] !== 0) {
- $msg = "Pull from remote fail of the {$name}. Output: {$ret['output']}";
- Color::println($msg, 'error');
- $result[$name] = 'Fail';
- return;
- }
-
- $result[$name] = 'OK';
- Color::println("- Complete for {$name}\n", 'cyan');
- Coroutine::sleep(1);
- });
- }
-
- $runner->start();
- Color::println("\nComplete", 'cyan');
- Show::aList($result);
- }
-}
diff --git a/script/Command/GitSubtreePush.php b/script/Command/GitSubtreePush.php
deleted file mode 100644
index 355960fc6..000000000
--- a/script/Command/GitSubtreePush.php
+++ /dev/null
@@ -1,91 +0,0 @@
- 'git:spush',
- 'desc' => 'Push all update to remote sub-repo by git subtree push',
- 'usage' => 'git:spush [options] [arguments]',
- 'help' => $help,
- ];
- }
-
- public function __invoke(App $app)
- {
- if ($app->getCommand()) {
- Color::println('Please use git:fpush instead of the command', 'error');
- return;
- }
-
- $targetBranch = 'master';
- $this->debug = $app->getBoolOpt('debug');
-
- $result = [];
- $runner = Scheduler::new();
-
- // git subtree push --prefix=src/annotation git@github.com:swoft-cloud/swoft-annotation.git master --squash
- // git subtree push --prefix=src/stdlib stdlib master
- foreach ($this->findComponents($app) as $dir) {
- $name = basename($dir);
- // push 加 --squash 是没有意义的
- // link https://stackoverflow.com/questions/20102594/git-subtree-push-squash-does-not-squash
- $cmd = "git subtree push --prefix=src/{$name} {$name} $targetBranch";
-
- $runner->add(function () use ($name, $cmd, &$result) {
- Color::println("\n====== Push the component:【{$name}】");
- Color::println("> $cmd", 'yellow');
-
- if ($this->debug) {
- Color::println('[DEBUG] use co::sleep(2) to mock remote operation');
- Coroutine::sleep(2);
- return;
- }
-
- $ret = Coroutine::exec($cmd);
- if ((int)$ret['code'] !== 0) {
- $msg = "Push to remote fail of the {$name}. Output: {$ret['output']}";
- Color::println($msg, 'error');
- $result[$name] = 'Fail';
- return;
- }
-
- $result[$name] = 'OK';
- Color::println("- Complete for {$name}\n", 'cyan');
- Coroutine::sleep(1);
- });
- }
-
- $runner->start();
- Color::println("\nComplete", 'cyan');
- Show::aList($result);
- }
-}
diff --git a/script/Command/ListComponents.php b/script/Command/ListComponents.php
deleted file mode 100644
index 7dafd09e0..000000000
--- a/script/Command/ListComponents.php
+++ /dev/null
@@ -1,46 +0,0 @@
- 'list',
- 'desc' => 'list all swoft components in src/ dir',
- 'usage' => 'list',
- 'help' => $help,
- ];
- }
-
-
- public function __invoke(App $app): void
- {
- $libsDir = BASE_PATH . '/src/';
-
- Color::println('Components:', 'cyan');
- $flags = GLOB_ONLYDIR | GLOB_MARK;
- $pattern = $libsDir . '*';
-
- foreach (glob($pattern, $flags) as $item) {
- echo basename($item), PHP_EOL;
- }
- }
-}
diff --git a/script/Command/Scheduler.php b/script/Command/Scheduler.php
deleted file mode 100644
index e22ac5658..000000000
--- a/script/Command/Scheduler.php
+++ /dev/null
@@ -1,93 +0,0 @@
-handlers[] = [$callable, []];
- }
- }
- }
-
- /**
- * @param callable $callable
- * @param mixed ...$args
- */
- public function add(callable $callable, ...$args): void
- {
- $this->handlers[] = [$callable, $args];
- }
-
- /**
- * @return bool
- */
- public function start(): bool
- {
- if (!$this->handlers) {
- throw new RuntimeException('Not add any callable handler, cannot start');
- }
-
- // >= 4.4
- if ($this->isGteSwoole44()) {
- $scheduler = new CoScheduler;
-
- foreach ($this->handlers as [$callable, $args]) {
- $scheduler->add($callable, ...$args);
- }
-
- return $scheduler->start();
- }
-
- // < 4.4
- foreach ($this->handlers as [$callable, $args]) {
- Coroutine::create($callable, ...$args);
- }
-
- Event::wait();
- return true;
- }
-
- /**
- * Check swoole is >= 4.4.0
- *
- * @return bool
- */
- public function isGteSwoole44(): bool
- {
- return SWOOLE_VERSION_ID >= 40400;
- }
-}
diff --git a/script/Command/UpdateSwooleVer.php b/script/Command/UpdateSwooleVer.php
deleted file mode 100644
index 9ce75ac3b..000000000
--- a/script/Command/UpdateSwooleVer.php
+++ /dev/null
@@ -1,106 +0,0 @@
- 'up:swover',
- 'desc' => 'update the swoole version for all .travis.yml',
- 'usage' => 'up:swover -v VERSION',
- 'help' => $help,
- ];
- }
-
- public function __invoke(App $app): void
- {
- $defVersion = '';
- if (defined('SWOOLE_VERSION')) {
- $defVersion = 'v' . SWOOLE_VERSION;
- }
-
- if (!$version = $app->getStrOpt('v', $defVersion)) {
- echo Color::render("Please input an version by option: -v\n", 'error');
- return;
- }
-
- $this->version = 'v' . trim($version, 'v');
-
- echo Color::render("New swoole version is: {$this->version}\n", 'info');
-
- // for all
- $app->setOpts(array_merge($app->getOpts(), ['all' => true]));
- foreach ($this->findComponents($app) as $dir) {
- $this->updateSwooleVersion($dir . '.travis.yml', basename($dir));
- }
-
- $mainDir = $app->getPwd();
- $this->updateSwooleVersion($mainDir . '/.travis.yml', basename($mainDir));
-
- if ($this->updated > 0 && $app->getBoolOpt('c')) {
- self::gitCommit('update: update the swoole version for .travis.yml');
- }
-
- echo Color::render("Complete. Updated: {$this->updated}\n", 'cyan');
- }
-
- private function updateSwooleVersion(string $file, string $cptName): void
- {
- if (!file_exists($file)) {
- Color::println("Skip the component: $cptName", 'mga');
- return;
- }
-
- $updated = 0;
- // .../swoole-src/archive/v4.4.1.tar.gz
- $regexp = '#swoole-src/archive/(v\d.\d.\d).tar.gz#';
- $replace = "swoole-src/archive/{$this->version}.tar.gz";
- $content = file_get_contents($file);
-
- // replace
- $content = preg_replace($regexp, $replace, $content, 1, $updated);
- if ($updated) {
- $this->updated++;
- }
-
- Color::println("- Updated the component: $cptName");
-
- file_put_contents($file, $content);
- }
-}
diff --git a/script/bootstrap.php b/script/bootstrap.php
deleted file mode 100644
index 32dc873cb..000000000
--- a/script/bootstrap.php
+++ /dev/null
@@ -1,40 +0,0 @@
- $dir) {
- $loader->addPsr4($prefix, $componentDir . '/' . $dir);
- }
-} else {
- exit('Please run "composer install" to install the dependencies' . PHP_EOL);
-}
-
-$libDir = __DIR__ . '/';
-$npMap = [
- 'SwoftTool\\' => $libDir,
- // 'Inhere\\ValidateTest\\' => $libDir . '/test/',
-];
-
-spl_autoload_register(function ($class) use ($npMap) {
- foreach ($npMap as $np => $dir) {
- if (strpos($class, $np) !== 0) {
- continue;
- }
-
- $file = $dir . str_replace('\\', '/', substr($class, strlen($np))) . '.php';
-
- if (file_exists($file)) {
- include $file;
- }
- }
-});
diff --git a/script/dev-docs.md b/script/dev-doc.md
similarity index 100%
rename from script/dev-docs.md
rename to script/dev-doc.md
diff --git a/src/aop/phpunit.xml b/src/aop/phpunit.xml
index 15311104a..e491bd4a9 100644
--- a/src/aop/phpunit.xml
+++ b/src/aop/phpunit.xml
@@ -1,14 +1,14 @@
+ bootstrap="test/bootstrap.php"
+ backupGlobals="false"
+ backupStaticAttributes="false"
+ colors="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ processIsolation="false"
+ stopOnFailure="false">
./test/unit
@@ -19,4 +19,4 @@
./src/*
-
\ No newline at end of file
+
diff --git a/src/aop/src/Aop.php b/src/aop/src/Aop.php
index 0813c4820..5257122c4 100644
--- a/src/aop/src/Aop.php
+++ b/src/aop/src/Aop.php
@@ -8,7 +8,6 @@
use function count;
use function explode;
use function preg_match;
-use SwoftTest\Component\Testing\Aop\RegAop;
/**
* Class AopRegister
@@ -170,4 +169,4 @@ private static function isExecution(string $class, string $method, array $execut
return false;
}
-}
\ No newline at end of file
+}
diff --git a/src/aop/src/AspectHandler.php b/src/aop/src/AspectHandler.php
index 2907a0bbf..85a5f94dd 100644
--- a/src/aop/src/AspectHandler.php
+++ b/src/aop/src/AspectHandler.php
@@ -1,6 +1,5 @@
invokeAdvice($afThw, $this->throwable);
}
throw $this->throwable;
- } else {
- // Invoke afterReturning advice
- if (!empty($afRetn)) {
- $result = $this->invokeAdvice($afRetn, null, $result);
- }
+ }
+
+ // Invoke afterReturning advice
+ if (!empty($afRetn)) {
+ $result = $this->invokeAdvice($afRetn, null, $result);
}
return $result;
@@ -244,7 +243,7 @@ private function invokeAdvice(array $aspectAry, Throwable $catch = null, $return
continue;
}
- if ($type == Throwable::class) {
+ if ($type === Throwable::class) {
$aspectArgs[] = $catch;
}
@@ -310,7 +309,7 @@ private function getJoinPoint(Throwable $catch = null, $return = null): JoinPoin
*/
private function nextHandler(): AspectHandler
{
- $aspect = clone $this;
+ $aspect = clone $this;
// Next aspect data
$aspect->aspect = array_shift($this->aspects);
@@ -318,4 +317,4 @@ private function nextHandler(): AspectHandler
return $aspect;
}
-}
\ No newline at end of file
+}
diff --git a/src/aop/src/Ast/Visitor/ProxyVisitor.php b/src/aop/src/Ast/Visitor/ProxyVisitor.php
index 7b39275fc..6c5801b9e 100644
--- a/src/aop/src/Ast/Visitor/ProxyVisitor.php
+++ b/src/aop/src/Ast/Visitor/ProxyVisitor.php
@@ -1,18 +1,16 @@
name->toString();
- $this->proxyName = sprintf('%s%s%s', $name, self::PROXY, $this->proxyId);
+ $this->proxyName = sprintf('%s%s%s', $name, self::PROXY, $this->proxyId);
$this->originalClassName = sprintf('%s\\%s', $this->namespace, $name);
return null;
@@ -196,11 +194,7 @@ private function proxyMethod(ClassMethod $node): ClassMethod
];
// Proxy method call
- $proxyCall = new Node\Expr\MethodCall(
- new Node\Expr\Variable('this'),
- '__proxyCall',
- $newParams
- );
+ $proxyCall = new Node\Expr\MethodCall(new Node\Expr\Variable('this'), '__proxyCall', $newParams);
// New method stmts
$type = $node->returnType;
diff --git a/src/aop/src/Concern/AopTrait.php b/src/aop/src/Concern/AopTrait.php
index 28894b9af..9ea043c2e 100644
--- a/src/aop/src/Concern/AopTrait.php
+++ b/src/aop/src/Concern/AopTrait.php
@@ -1,6 +1,5 @@
assertTrue(true);
}
-}
\ No newline at end of file
+}
diff --git a/src/aop/test/unit/AopTest.php b/src/aop/test/unit/AopTest.php
index 5f49725c2..2a92ec109 100644
--- a/src/aop/test/unit/AopTest.php
+++ b/src/aop/test/unit/AopTest.php
@@ -4,16 +4,16 @@
namespace SwoftTest\Aop\Unit;
-use function class_exists;
-use const PHP_EOL;
use PHPUnit\Framework\TestCase;
-use function sprintf;
use Swoft\Aop\Ast\Visitor\ProxyVisitor;
use Swoft\Aop\Proxy;
use Swoft\Proxy\Ast\Parser;
use Swoft\Proxy\Exception\ProxyException;
use Swoft\Proxy\Proxy as BaseProxy;
use SwoftTest\Aop\Testing\AopClass;
+use function class_exists;
+use function sprintf;
+use const PHP_EOL;
/**
@@ -52,7 +52,7 @@ public function testProxyCode()
// Proxy file and proxy code
$proxyCode = sprintf('assertEquals($originalClass, $className);
}
-}
\ No newline at end of file
+}
diff --git a/src/console/src/Listener/AppInitCompleteListener.php b/src/console/src/Listener/AppInitCompleteListener.php
deleted file mode 100644
index ccd0f5f10..000000000
--- a/src/console/src/Listener/AppInitCompleteListener.php
+++ /dev/null
@@ -1,27 +0,0 @@
-application->afterEnv();
}
// Load env info
@@ -55,8 +55,8 @@ public function handle(): bool
$path = dirname($envFile);
$name = basename($envFile);
- Dotenv::create($path, $name, $factory)->load();
+ Dotenv::create($path, $name, $factory)->overload();
CLog::info('Env file(%s) is loaded', $envFile);
return $this->application->afterEnv();
diff --git a/src/framework/test/testing/ConsoleProcessor.php b/src/framework/test/testing/ConsoleProcessor.php
new file mode 100644
index 000000000..02f2dc8c1
--- /dev/null
+++ b/src/framework/test/testing/ConsoleProcessor.php
@@ -0,0 +1,48 @@
+application->beforeConsole()) {
+ return false;
+ }
+
+ /** @var Router $router */
+ $router = bean('cliRouter');
+
+ // Register console routes
+ CommandRegister::register($router);
+
+ CLog::info(
+ 'Console command route registered (group %d, command %d)',
+ $router->groupCount(),
+ $router->count()
+ );
+
+ // Run console application
+ // Dont run on unit tests
+ // bean('cliApp')->run();
+
+ return $this->application->afterConsole();
+ }
+}
diff --git a/src/framework/test/testing/TestApplication.php b/src/framework/test/testing/TestApplication.php
index b28d5c658..e7f0ee87b 100644
--- a/src/framework/test/testing/TestApplication.php
+++ b/src/framework/test/testing/TestApplication.php
@@ -38,7 +38,8 @@ protected function processors(): array
new ConfigProcessor($this),
new AnnotationProcessor($this),
new BeanProcessor($this),
- new EventProcessor($this)
+ new EventProcessor($this),
+ new ConsoleProcessor($this),
];
}
}
diff --git a/src/process/phpunit.xml b/src/process/phpunit.xml
index 15311104a..e491bd4a9 100644
--- a/src/process/phpunit.xml
+++ b/src/process/phpunit.xml
@@ -1,14 +1,14 @@
+ bootstrap="test/bootstrap.php"
+ backupGlobals="false"
+ backupStaticAttributes="false"
+ colors="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ processIsolation="false"
+ stopOnFailure="false">
./test/unit
@@ -19,4 +19,4 @@
./src/*
-
\ No newline at end of file
+
diff --git a/src/process/src/Listener/AfterProcessListener.php b/src/process/src/Listener/AfterProcessListener.php
index 7b9eb8749..a2dc789b1 100644
--- a/src/process/src/Listener/AfterProcessListener.php
+++ b/src/process/src/Listener/AfterProcessListener.php
@@ -3,11 +3,11 @@
namespace Swoft\Process\Listener;
use Swoft;
+use Swoft\Event\Annotation\Mapping\Listener;
use Swoft\Event\EventHandlerInterface;
use Swoft\Event\EventInterface;
-use Swoft\SwoftEvent;
-use Swoft\Event\Annotation\Mapping\Listener;
use Swoft\Process\ProcessEvent;
+use Swoft\SwoftEvent;
/**
* Class AfterProcessListener
diff --git a/src/process/src/Process.php b/src/process/src/Process.php
index 205d129aa..05fdf0705 100644
--- a/src/process/src/Process.php
+++ b/src/process/src/Process.php
@@ -7,6 +7,8 @@
use Swoft\Process\Exception\ProcessException;
use Swoole\Coroutine\Socket;
use Swoole\Process as SwooleProcess;
+use function swoole_errno;
+use function swoole_strerror;
/**
* Class Process
@@ -307,6 +309,6 @@ public static function setAffinity(array $cpuSet): bool
private function getError(): string
{
$errno = swoole_errno();
- return (string)swoole_strerror($errno);
+ return swoole_strerror($errno);
}
}
diff --git a/src/process/src/ProcessDispatcher.php b/src/process/src/ProcessDispatcher.php
index 230aea80b..3ac223a07 100644
--- a/src/process/src/ProcessDispatcher.php
+++ b/src/process/src/ProcessDispatcher.php
@@ -3,10 +3,8 @@
namespace Swoft\Process;
-use ReflectionException;
use Swoft\Bean\Annotation\Mapping\Bean;
use Swoft\Bean\BeanFactory;
-use Swoft\Bean\Exception\ContainerException;
use Swoft\Log\Error;
use Swoft\Process\Contract\ProcessInterface;
use Swoft\Process\Exception\ProcessException;
@@ -41,9 +39,8 @@ public function dispatcher(Pool $pool, int $workerId): void
$process = $this->getProcess($workerId);
PhpHelper::call([$process, self::METHOD], $pool, $workerId);
} catch (Throwable $e) {
- Error::log(
- sprintf('Run process for process pool fail(%s %s %d)!', $e->getMessage(), $e->getFile(), $e->getLine())
- );
+ Error::log(sprintf('Run process for process pool fail(%s %s %d)!', $e->getMessage(), $e->getFile(),
+ $e->getLine()));
}
}
diff --git a/src/process/src/ProcessEvent.php b/src/process/src/ProcessEvent.php
index c985195ce..d176c2237 100644
--- a/src/process/src/ProcessEvent.php
+++ b/src/process/src/ProcessEvent.php
@@ -24,11 +24,11 @@ class ProcessEvent
* Before process
*/
public const BEFORE_PROCESS_START = 'swoft.process.start.before';
- public const AFTER_PROCESS_START = 'swoft.process.start.after';
+ public const AFTER_PROCESS_START = 'swoft.process.start.after';
/**
* After process
*/
public const BEFORE_PROCESS_STOP = 'swoft.process.stop.before';
- public const AFTER_PROCESS_STOP = 'swoft.process.stop.after';
+ public const AFTER_PROCESS_STOP = 'swoft.process.stop.after';
}
diff --git a/src/process/src/ProcessPool.php b/src/process/src/ProcessPool.php
index f30fd121f..d01caf904 100644
--- a/src/process/src/ProcessPool.php
+++ b/src/process/src/ProcessPool.php
@@ -159,6 +159,7 @@ public function stop(): bool
/**
* Quick restart
+ *
* @throws SwoftException
*/
public function restart(): void
diff --git a/src/process/src/Swoole/WorkerStartListener.php b/src/process/src/Swoole/WorkerStartListener.php
index 56aea4dc1..8608e67a9 100644
--- a/src/process/src/Swoole/WorkerStartListener.php
+++ b/src/process/src/Swoole/WorkerStartListener.php
@@ -4,16 +4,14 @@
namespace Swoft\Process\Swoole;
-use ReflectionException;
use Swoft;
use Swoft\Bean\Annotation\Mapping\Bean;
-use Swoft\Bean\Exception\ContainerException;
+use Swoft\Bean\Annotation\Mapping\Inject;
use Swoft\Process\Contract\WorkerStartInterface;
use Swoft\Process\ProcessDispatcher;
use Swoft\Process\ProcessEvent;
use Swoft\Process\ProcessPool;
use Swoole\Process\Pool;
-use Swoft\Bean\Annotation\Mapping\Inject;
/**
diff --git a/src/process/src/UserProcess.php b/src/process/src/UserProcess.php
index 64e4757ac..3bb304214 100644
--- a/src/process/src/UserProcess.php
+++ b/src/process/src/UserProcess.php
@@ -1,9 +1,7 @@
coroutine;
}
-}
\ No newline at end of file
+}
diff --git a/src/process/test/bootstrap.php b/src/process/test/bootstrap.php
index 75378126e..a3b73f86d 100644
--- a/src/process/test/bootstrap.php
+++ b/src/process/test/bootstrap.php
@@ -1,4 +1,5 @@
$dir) {
$loader->addPsr4($prefix, $componentDir . '/' . $dir);
}
@@ -25,7 +26,7 @@
$loader = require dirname(__DIR__, 5) . '/autoload.php';
// need load testing psr4 config map
- $composerData = json_decode(file_get_contents($componentJson), true);
+ $composerData = json_decode(file_get_contents($componentJson), true);
foreach ($composerData['autoload-dev']['psr-4'] as $prefix => $dir) {
$loader->addPsr4($prefix, $componentDir . '/' . $dir);
@@ -35,7 +36,7 @@
}
$application = new TestApplication([
- 'basePath' => __DIR__
+ 'basePath' => __DIR__
]);
$application->setBeanFile(__DIR__ . '/testing/bean.php');
$application->run();
diff --git a/src/process/test/testing/bean.php b/src/process/test/testing/bean.php
index b62512838..0b67a5fe4 100644
--- a/src/process/test/testing/bean.php
+++ b/src/process/test/testing/bean.php
@@ -1,4 +1,3 @@
addPsr4("Swoft\\Cache\\", 'vendor/swoft/cache/src/');
+$loader->addPsr4("Swoft\\Swlib\\", 'vendor/swoft/swlib/src/');
+$loader->addPsr4("Swoft\\Serialize\\", 'vendor/swoft/serialize/src/');
diff --git a/test/bin/swoft b/test/bin/swoft
new file mode 100644
index 000000000..a99e04b24
--- /dev/null
+++ b/test/bin/swoft
@@ -0,0 +1,15 @@
+#!/usr/bin/env php
+ 300000,
+]);
+
+// Run application
+(new \App\Application())->run();
diff --git a/test/bootstrap.php b/test/bootstrap.php
index a202591c6..76d96b076 100644
--- a/test/bootstrap.php
+++ b/test/bootstrap.php
@@ -21,6 +21,10 @@
exit('Please run "composer install" to install the dependencies' . PHP_EOL);
}
+if (defined('RUN_TEST_APP') && !RUN_TEST_APP) {
+ return;
+}
+
$application = new TestApplication();
$application->setBeanFile(__DIR__ . '/testing/bean.php');
$application->run();
diff --git a/test/testing/AutoLoader.php b/test/testing/AutoLoader.php
index 57c102a8a..96fe53d8c 100644
--- a/test/testing/AutoLoader.php
+++ b/test/testing/AutoLoader.php
@@ -1,9 +1,7 @@