From ee1f3afb3b3d62a066ae3978ca24c2a789e8faec Mon Sep 17 00:00:00 2001 From: Lianbo Date: Mon, 8 Apr 2024 13:24:47 +0800 Subject: [PATCH] Add missing dependencies to dev (#73) * Add new dev-dependencies to composer.json The dependencies illuminate/contracts, predis/predis, ext-redis, and ext-swoole have been added to the "require-dev" section of composer.json file. This provides additional functionality for development purposes, including dependency injection, connection with Redis, and asynchronous tasks. * Update GitHub workflows and remove unnecessary packages This commit modifies the fail-fast strategy in the static analysis workflow and removes the installation of 'predis/predis' and 'illuminate/contracts' packages across multiple workflow files. This results in a cleaner setup, less dependency on external packages, and a more effective fail-fast configuration. Now, the workflows will use a matrix strategy for the PHP version, targeting specifically PHP * fix missing dependencies in action * fix php stan --- .github/workflows/codestyle.yml | 6 ------ .github/workflows/static-analysis.yml | 9 +++++---- .github/workflows/test.yml | 6 ------ composer.json | 7 ++++++- src/LaravelSequenceResolver.php | 6 ++---- 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/.github/workflows/codestyle.yml b/.github/workflows/codestyle.yml index b5b83ec..4783104 100644 --- a/.github/workflows/codestyle.yml +++ b/.github/workflows/codestyle.yml @@ -36,12 +36,6 @@ jobs: - name: Install dependencies with composer run: composer update --no-ansi --no-interaction --no-progress - - name: Install Laravel Illuminate Contracts - run: composer require "illuminate/contracts" - - - name: Install Predis Package - run: composer require "predis/predis:^2.0" - - name: Code Style run: vendor/bin/pint --test --config ./pint.json diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 2f53bee..28eaa0b 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -16,7 +16,10 @@ jobs: runs-on: ubuntu-22.04 strategy: - fail-fast: true + fail-fast: false + matrix: + php-version: + - 8.2 name: Static Analysis @@ -30,6 +33,7 @@ jobs: php-version: 8.2 tools: composer:v2 coverage: none + extensions: swoole, redis, pcntl - name: Install dependencies uses: nick-fields/retry@v2 @@ -38,8 +42,5 @@ jobs: max_attempts: 3 command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress - - name: Install Predis Package - run: composer require "predis/predis:^2.0" - - name: Execute type checking run: vendor/bin/phpstan \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d167cbc..49e9972 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,12 +37,6 @@ jobs: - name: Install dependencies run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress - - name: Install Laravel Illuminate Contracts - run: composer require "illuminate/contracts" - - - name: Install Predis Package - run: composer require "predis/predis:^2.0" - - name: PHPUnit Test run: vendor/bin/phpunit --display-incomplete --display-skipped --display-deprecations --display-errors --display-notices --display-warnings env: diff --git a/composer.json b/composer.json index 09d82b5..ac5e8b7 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,11 @@ "require-dev": { "phpunit/phpunit": "^10", "laravel/pint": "^1.10", - "phpstan/phpstan": "^1.10" + "phpstan/phpstan": "^1.10", + "illuminate/contracts": "^10.0 || ^11.0", + "predis/predis": "^2.0", + "ext-redis": "*", + "ext-swoole": "*" }, "autoload-dev": { "psr-4": { @@ -38,6 +42,7 @@ }, "scripts": { "test": "vendor/bin/phpunit", + "phpstan": "vendor/bin/phpstan", "pint": "vendor/bin/pint --config pint.json" }, "config": { diff --git a/src/LaravelSequenceResolver.php b/src/LaravelSequenceResolver.php index 45e29dc..f93a30b 100644 --- a/src/LaravelSequenceResolver.php +++ b/src/LaravelSequenceResolver.php @@ -24,7 +24,7 @@ class LaravelSequenceResolver implements SequenceResolver /** * Init resolve instance, must be connected. */ - public function __construct(protected Repository $cache) // @phpstan-ignore-line + public function __construct(protected Repository $cache) { } @@ -32,13 +32,11 @@ public function sequence(int $currentTime): int { $key = $this->prefix.$currentTime; - // @phpstan-ignore-next-line if ($this->cache->add($key, 1, 10)) { return 0; } - // @phpstan-ignore-next-line - return $this->cache->increment($key, 1); + return $this->cache->increment($key) | 0; } public function setCachePrefix(string $prefix): self