From 4610cbf6c5ba5eb20fc1f6a7e74edbf9c6eeb780 Mon Sep 17 00:00:00 2001 From: Aleksandr Denisyuk Date: Thu, 30 Mar 2023 22:23:21 +0300 Subject: [PATCH] Update php-cs-fixer issues --- .github/workflows/continuous-integration.yml | 53 ------------------- LICENSE.txt | 21 -------- src/Generator/Generator.php | 2 +- .../ExceptionClassifier.php | 8 +-- src/Retry/Retry.php | 2 +- tests/ExponentialBackOffTest.php | 2 +- tests/Generator/GeneratorTest.php | 6 +-- tests/LinearBackOffTest.php | 2 +- tests/Retry/RetryTest.php | 6 +-- tests/Strategy/ConstantStrategyTest.php | 2 +- tests/Strategy/DecorrelatedStrategyTest.php | 2 +- tests/Strategy/ExponentialStrategyTest.php | 2 +- tests/Strategy/LinearStrategyTest.php | 2 +- 13 files changed, 16 insertions(+), 94 deletions(-) delete mode 100644 .github/workflows/continuous-integration.yml delete mode 100644 LICENSE.txt diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml deleted file mode 100644 index 77baa68..0000000 --- a/.github/workflows/continuous-integration.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: build - -on: - push: - paths-ignore: - - 'docs/**' - - 'LICENSE.txt' - - 'README.md' - pull_request: - paths-ignore: - - 'docs/**' - - 'LICENSE.txt' - - 'README.md' - -jobs: - unit-tests: - name: Unit tests - - strategy: - fail-fast: false - matrix: - php-versions: [8.1] - stability: [prefer-lowest, prefer-stable] - - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Cache Composer packages - id: composer-cache - run: | - echo "::set-output name=dir::$(composer config cache-files-dir)" - - uses: actions/cache@v2 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - tools: composer:v2 - coverage: none - - - name: Install Composer dependencies - run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress - - - name: Run Unit tests - run: vendor/bin/phpunit --verbose --no-interaction diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 697699e..0000000 --- a/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2022 Orangesoft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/src/Generator/Generator.php b/src/Generator/Generator.php index 823c61d..2cb4d1f 100644 --- a/src/Generator/Generator.php +++ b/src/Generator/Generator.php @@ -6,8 +6,8 @@ use Orangesoft\BackOff\Duration\DurationInterface; use Orangesoft\BackOff\Duration\Nanoseconds; -use Orangesoft\BackOff\Strategy\StrategyInterface; use Orangesoft\BackOff\Jitter\JitterInterface; +use Orangesoft\BackOff\Strategy\StrategyInterface; final class Generator implements GeneratorInterface { diff --git a/src/Retry/ExceptionClassifier/ExceptionClassifier.php b/src/Retry/ExceptionClassifier/ExceptionClassifier.php index 52ca893..dd89d9a 100644 --- a/src/Retry/ExceptionClassifier/ExceptionClassifier.php +++ b/src/Retry/ExceptionClassifier/ExceptionClassifier.php @@ -12,7 +12,7 @@ final class ExceptionClassifier implements ExceptionClassifierInterface public function __construct( private array $classNames = [], ) { - if (0 === count($classNames)) { + if (0 === \count($classNames)) { $this->classNames = [ \Error::class, \Exception::class, @@ -20,11 +20,7 @@ public function __construct( } else { foreach ($classNames as $className) { if (!class_exists($className) || !is_a($className, \Throwable::class, true)) { - throw new \InvalidArgumentException( - vsprintf('Exception class must be a class that exists and can be thrown, "%s" given.', [ - get_debug_type($className), - ]) - ); + throw new \InvalidArgumentException(vsprintf('Exception class must be a class that exists and can be thrown, "%s" given.', [get_debug_type($className)])); } $this->classNames[] = $className; diff --git a/src/Retry/Retry.php b/src/Retry/Retry.php index 18d106a..7b1d7b8 100644 --- a/src/Retry/Retry.php +++ b/src/Retry/Retry.php @@ -30,7 +30,7 @@ public function call(callable $callback, array $args = []): mixed $this->backOff->backOff($attempt, $throwable); - $attempt++; + ++$attempt; goto retrying; } diff --git a/tests/ExponentialBackOffTest.php b/tests/ExponentialBackOffTest.php index 44aefb7..cb7599a 100644 --- a/tests/ExponentialBackOffTest.php +++ b/tests/ExponentialBackOffTest.php @@ -4,8 +4,8 @@ namespace Orangesoft\BackOff\Tests; -use Orangesoft\BackOff\ExponentialBackOff; use Orangesoft\BackOff\Duration\Nanoseconds; +use Orangesoft\BackOff\ExponentialBackOff; use Orangesoft\BackOff\Jitter\NullJitter; use Orangesoft\BackOff\Sleeper\Sleeper; use PHPUnit\Framework\TestCase; diff --git a/tests/Generator/GeneratorTest.php b/tests/Generator/GeneratorTest.php index 8fc7dfc..720955f 100644 --- a/tests/Generator/GeneratorTest.php +++ b/tests/Generator/GeneratorTest.php @@ -4,12 +4,12 @@ namespace Orangesoft\BackOff\Tests\Generator; -use Orangesoft\BackOff\Generator\Generator; use Orangesoft\BackOff\Duration\Nanoseconds; +use Orangesoft\BackOff\Generator\Generator; +use Orangesoft\BackOff\Jitter\EqualJitter; +use Orangesoft\BackOff\Jitter\NullJitter; use Orangesoft\BackOff\Strategy\ConstantStrategy; use Orangesoft\BackOff\Strategy\LinearStrategy; -use Orangesoft\BackOff\Jitter\NullJitter; -use Orangesoft\BackOff\Jitter\EqualJitter; use PHPUnit\Framework\TestCase; class GeneratorTest extends TestCase diff --git a/tests/LinearBackOffTest.php b/tests/LinearBackOffTest.php index c159912..55ece26 100644 --- a/tests/LinearBackOffTest.php +++ b/tests/LinearBackOffTest.php @@ -4,9 +4,9 @@ namespace Orangesoft\BackOff\Tests; -use Orangesoft\BackOff\LinearBackOff; use Orangesoft\BackOff\Duration\Nanoseconds; use Orangesoft\BackOff\Jitter\NullJitter; +use Orangesoft\BackOff\LinearBackOff; use Orangesoft\BackOff\Sleeper\Sleeper; use PHPUnit\Framework\TestCase; diff --git a/tests/Retry/RetryTest.php b/tests/Retry/RetryTest.php index 6ea4f4a..9cde45f 100644 --- a/tests/Retry/RetryTest.php +++ b/tests/Retry/RetryTest.php @@ -18,7 +18,7 @@ public function testReturnValue(): void exceptionClassifier: new ExceptionClassifier(), ); - $result = $retry->call(fn(int $a, int $b): int => $a + $b, [5, 10]); + $result = $retry->call(fn (int $a, int $b): int => $a + $b, [5, 10]); $this->assertSame(15, $result); } @@ -34,7 +34,7 @@ public function testThrowException(): void $this->expectExceptionObject($throwable); - $retry->call(fn() => throw $throwable); + $retry->call(fn () => throw $throwable); } public function testAttemptsCounter(): void @@ -45,7 +45,7 @@ public function testAttemptsCounter(): void ); try { - $retry->call(fn() => throw new \Exception()); + $retry->call(fn () => throw new \Exception()); } catch (\Exception) { $this->assertSame(3, $attemptsCounterBackOff->getLastAttempt()); } diff --git a/tests/Strategy/ConstantStrategyTest.php b/tests/Strategy/ConstantStrategyTest.php index 548c688..91ce494 100644 --- a/tests/Strategy/ConstantStrategyTest.php +++ b/tests/Strategy/ConstantStrategyTest.php @@ -4,8 +4,8 @@ namespace Orangesoft\BackOff\Tests\Strategy; -use Orangesoft\BackOff\Strategy\ConstantStrategy; use Orangesoft\BackOff\Duration\Nanoseconds; +use Orangesoft\BackOff\Strategy\ConstantStrategy; use PHPUnit\Framework\TestCase; class ConstantStrategyTest extends TestCase diff --git a/tests/Strategy/DecorrelatedStrategyTest.php b/tests/Strategy/DecorrelatedStrategyTest.php index eb7f7a3..0745059 100644 --- a/tests/Strategy/DecorrelatedStrategyTest.php +++ b/tests/Strategy/DecorrelatedStrategyTest.php @@ -4,8 +4,8 @@ namespace Orangesoft\BackOff\Tests\Strategy; -use Orangesoft\BackOff\Strategy\DecorrelatedStrategy; use Orangesoft\BackOff\Duration\Nanoseconds; +use Orangesoft\BackOff\Strategy\DecorrelatedStrategy; use PHPUnit\Framework\TestCase; class DecorrelatedStrategyTest extends TestCase diff --git a/tests/Strategy/ExponentialStrategyTest.php b/tests/Strategy/ExponentialStrategyTest.php index e77621e..e125bee 100644 --- a/tests/Strategy/ExponentialStrategyTest.php +++ b/tests/Strategy/ExponentialStrategyTest.php @@ -4,8 +4,8 @@ namespace Orangesoft\BackOff\Tests\Strategy; -use Orangesoft\BackOff\Strategy\ExponentialStrategy; use Orangesoft\BackOff\Duration\Nanoseconds; +use Orangesoft\BackOff\Strategy\ExponentialStrategy; use PHPUnit\Framework\TestCase; class ExponentialStrategyTest extends TestCase diff --git a/tests/Strategy/LinearStrategyTest.php b/tests/Strategy/LinearStrategyTest.php index 727b75f..b7c73bc 100644 --- a/tests/Strategy/LinearStrategyTest.php +++ b/tests/Strategy/LinearStrategyTest.php @@ -4,8 +4,8 @@ namespace Orangesoft\BackOff\Tests\Strategy; -use Orangesoft\BackOff\Strategy\LinearStrategy; use Orangesoft\BackOff\Duration\Nanoseconds; +use Orangesoft\BackOff\Strategy\LinearStrategy; use PHPUnit\Framework\TestCase; class LinearStrategyTest extends TestCase