From 8f4c573a9457646db3e629dacabe064eebaf8cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Sat, 23 Mar 2024 19:28:51 +0800 Subject: [PATCH] Format code by the latest `cs-fixer`. (#6617) --- src/Channel/Caller.php | 1 + src/Channel/Manager.php | 1 + src/Channel/Pool.php | 1 + src/Concurrent.php | 1 + src/Coroutine.php | 3 ++- src/Exception/ChannelClosedException.php | 1 + src/Exception/ExceptionThrower.php | 1 + src/Exception/InvalidArgumentException.php | 1 + src/Exception/ParallelExecutionException.php | 1 + src/Exception/TimeoutException.php | 1 + src/Exception/WaitTimeoutException.php | 1 + src/Functions.php | 6 ++++-- src/Locker.php | 1 + src/Parallel.php | 1 + src/WaitGroup.php | 1 + src/Waiter.php | 1 + tests/Channel/CallerTest.php | 1 + tests/Channel/ChannelManagerTest.php | 1 + tests/ConcurrentTest.php | 1 + tests/ContainerTest.php | 1 + tests/CoroutineTest.php | 4 +++- tests/FunctionTest.php | 4 +++- tests/LockerTest.php | 1 + tests/ParallelTest.php | 4 +++- tests/Stub/Bar.php | 1 + tests/Stub/Foo.php | 1 + tests/WaitGroupTest.php | 1 + tests/WaiterTest.php | 1 + 28 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/Channel/Caller.php b/src/Channel/Caller.php index b4ecbbc..245da99 100644 --- a/src/Channel/Caller.php +++ b/src/Channel/Caller.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Coroutine\Channel; use Closure; diff --git a/src/Channel/Manager.php b/src/Channel/Manager.php index 7ff85b9..7ec4646 100644 --- a/src/Channel/Manager.php +++ b/src/Channel/Manager.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Coroutine\Channel; use Hyperf\Engine\Channel; diff --git a/src/Channel/Pool.php b/src/Channel/Pool.php index 43da649..d64f463 100644 --- a/src/Channel/Pool.php +++ b/src/Channel/Pool.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Coroutine\Channel; use Hyperf\Engine\Channel; diff --git a/src/Concurrent.php b/src/Concurrent.php index c66a14b..968a43b 100644 --- a/src/Concurrent.php +++ b/src/Concurrent.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Coroutine; use Hyperf\Context\ApplicationContext; diff --git a/src/Coroutine.php b/src/Coroutine.php index 39ad513..a65dfb2 100644 --- a/src/Coroutine.php +++ b/src/Coroutine.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Coroutine; use Hyperf\Context\ApplicationContext; @@ -84,7 +85,7 @@ public static function create(callable $callable): int try { return $coroutine->getId(); - } catch (\Throwable) { + } catch (Throwable) { return -1; } } diff --git a/src/Exception/ChannelClosedException.php b/src/Exception/ChannelClosedException.php index a90c444..d352918 100644 --- a/src/Exception/ChannelClosedException.php +++ b/src/Exception/ChannelClosedException.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Coroutine\Exception; use RuntimeException; diff --git a/src/Exception/ExceptionThrower.php b/src/Exception/ExceptionThrower.php index 5b2f94e..4568efc 100644 --- a/src/Exception/ExceptionThrower.php +++ b/src/Exception/ExceptionThrower.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Coroutine\Exception; use Throwable; diff --git a/src/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php index c9b8614..0676d71 100644 --- a/src/Exception/InvalidArgumentException.php +++ b/src/Exception/InvalidArgumentException.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Coroutine\Exception; class InvalidArgumentException extends \InvalidArgumentException diff --git a/src/Exception/ParallelExecutionException.php b/src/Exception/ParallelExecutionException.php index c674dca..304a43d 100644 --- a/src/Exception/ParallelExecutionException.php +++ b/src/Exception/ParallelExecutionException.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Coroutine\Exception; use RuntimeException; diff --git a/src/Exception/TimeoutException.php b/src/Exception/TimeoutException.php index fae8576..77e353c 100644 --- a/src/Exception/TimeoutException.php +++ b/src/Exception/TimeoutException.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Coroutine\Exception; use RuntimeException; diff --git a/src/Exception/WaitTimeoutException.php b/src/Exception/WaitTimeoutException.php index 8393231..1ad1296 100644 --- a/src/Exception/WaitTimeoutException.php +++ b/src/Exception/WaitTimeoutException.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Coroutine\Exception; class WaitTimeoutException extends TimeoutException diff --git a/src/Functions.php b/src/Functions.php index e4c97ac..aafaf8e 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -9,11 +9,13 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Coroutine; use Closure; use Hyperf\Context\ApplicationContext; use RuntimeException; +use Swoole\Runtime; /** * @param callable[] $callables @@ -65,11 +67,11 @@ function run($callbacks, int $flags = SWOOLE_HOOK_ALL): bool throw new RuntimeException('Function \'run\' only execute in non-coroutine environment.'); } - \Swoole\Runtime::enableCoroutine($flags); + Runtime::enableCoroutine($flags); /* @phpstan-ignore-next-line */ $result = \Swoole\Coroutine\run(...(array) $callbacks); - \Swoole\Runtime::enableCoroutine(false); + Runtime::enableCoroutine(false); return $result; } diff --git a/src/Locker.php b/src/Locker.php index b8deaa2..3d59473 100644 --- a/src/Locker.php +++ b/src/Locker.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Coroutine; use Hyperf\Engine\Channel; diff --git a/src/Parallel.php b/src/Parallel.php index 22d4083..14f464a 100644 --- a/src/Parallel.php +++ b/src/Parallel.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Coroutine; use Hyperf\Coroutine\Exception\ParallelExecutionException; diff --git a/src/WaitGroup.php b/src/WaitGroup.php index 67837d9..fa1fa0c 100644 --- a/src/WaitGroup.php +++ b/src/WaitGroup.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Coroutine; use BadMethodCallException; diff --git a/src/Waiter.php b/src/Waiter.php index 7d41ed0..febb0ec 100644 --- a/src/Waiter.php +++ b/src/Waiter.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Coroutine; use Closure; diff --git a/tests/Channel/CallerTest.php b/tests/Channel/CallerTest.php index bb390f4..9a480ac 100644 --- a/tests/Channel/CallerTest.php +++ b/tests/Channel/CallerTest.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\Coroutine\Channel; use Hyperf\Coroutine\Channel\Caller; diff --git a/tests/Channel/ChannelManagerTest.php b/tests/Channel/ChannelManagerTest.php index 2a34074..19c830f 100644 --- a/tests/Channel/ChannelManagerTest.php +++ b/tests/Channel/ChannelManagerTest.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\Coroutine\Channel; use Hyperf\Coroutine\Channel\Manager as ChannelManager; diff --git a/tests/ConcurrentTest.php b/tests/ConcurrentTest.php index 9286945..9b5168b 100644 --- a/tests/ConcurrentTest.php +++ b/tests/ConcurrentTest.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\Coroutine; use Exception; diff --git a/tests/ContainerTest.php b/tests/ContainerTest.php index d585df2..6943fcf 100644 --- a/tests/ContainerTest.php +++ b/tests/ContainerTest.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\Coroutine; use HyperfTest\Coroutine\Stub\Bar; diff --git a/tests/CoroutineTest.php b/tests/CoroutineTest.php index 6498284..a8c67dc 100644 --- a/tests/CoroutineTest.php +++ b/tests/CoroutineTest.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\Coroutine; use Exception; @@ -20,6 +21,7 @@ use Hyperf\ExceptionHandler\Formatter\FormatterInterface; use Mockery; use PHPUnit\Framework\Attributes\CoversNothing; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; use Throwable; @@ -70,7 +72,7 @@ public function testCoroutineParentIdHasBeenDestroyed() } } - #[\PHPUnit\Framework\Attributes\Group('NonCoroutine')] + #[Group('NonCoroutine')] public function testCoroutineInTopCoroutine() { run(function () { diff --git a/tests/FunctionTest.php b/tests/FunctionTest.php index 342f687..b1dcc6c 100644 --- a/tests/FunctionTest.php +++ b/tests/FunctionTest.php @@ -9,11 +9,13 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\Coroutine; use Hyperf\Coroutine\Coroutine; use Hyperf\Engine\Channel; use PHPUnit\Framework\Attributes\CoversNothing; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Swoole\Runtime; @@ -40,7 +42,7 @@ public function testReturnOfGo() $this->assertSame('Hyperf', $uniqid); } - #[\PHPUnit\Framework\Attributes\Group('NonCoroutine')] + #[Group('NonCoroutine')] public function testRun() { $asserts = [ diff --git a/tests/LockerTest.php b/tests/LockerTest.php index e20cc76..91fc2a8 100644 --- a/tests/LockerTest.php +++ b/tests/LockerTest.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\Coroutine; use Hyperf\Coroutine\Locker; diff --git a/tests/ParallelTest.php b/tests/ParallelTest.php index f267161..00d7475 100644 --- a/tests/ParallelTest.php +++ b/tests/ParallelTest.php @@ -9,12 +9,14 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\Coroutine; use Exception; use Hyperf\Coroutine\Coroutine; use Hyperf\Coroutine\Exception\ParallelExecutionException; use Hyperf\Coroutine\Parallel; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use RuntimeException; use Throwable; @@ -25,7 +27,7 @@ * @internal * @coversNothing */ -#[\PHPUnit\Framework\Attributes\CoversClass(\Hyperf\Coroutine\Parallel::class)] +#[CoversClass(Parallel::class)] class ParallelTest extends TestCase { public function testParallel() diff --git a/tests/Stub/Bar.php b/tests/Stub/Bar.php index 0f66e10..e59fae5 100644 --- a/tests/Stub/Bar.php +++ b/tests/Stub/Bar.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\Coroutine\Stub; use Hyperf\Support\Traits\Container; diff --git a/tests/Stub/Foo.php b/tests/Stub/Foo.php index bf9d907..192764c 100644 --- a/tests/Stub/Foo.php +++ b/tests/Stub/Foo.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\Coroutine\Stub; use Hyperf\Support\Traits\Container; diff --git a/tests/WaitGroupTest.php b/tests/WaitGroupTest.php index 7670d01..09f57aa 100644 --- a/tests/WaitGroupTest.php +++ b/tests/WaitGroupTest.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\Coroutine; use Hyperf\Coroutine\WaitGroup; diff --git a/tests/WaiterTest.php b/tests/WaiterTest.php index 5f93850..f81268c 100644 --- a/tests/WaiterTest.php +++ b/tests/WaiterTest.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\Coroutine; use Hyperf\Context\ApplicationContext;