From da3517675a5c3f41c598b75d5393c909ef6bbfa7 Mon Sep 17 00:00:00 2001 From: Martin Mitterhauser Date: Thu, 4 Apr 2024 16:12:37 +0200 Subject: [PATCH] beautify git workflow, use proper parameter and return types --- .github/workflows/main.yml | 47 +++++++++++++++++-------------- phpstan.neon | 2 -- src/Cache/Engine/PredisEngine.php | 6 ++-- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 30be7ac..d38d66c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,38 +15,43 @@ on: jobs: # Composer config validation composer: - name: Composer config validation - runs-on: ubuntu-latest + name: "Composer config validation" + runs-on: "ubuntu-latest" steps: - - uses: actions/checkout@v3 - - name: Validate composer.json - run: composer validate --strict + - uses: "actions/checkout@v3" + - name: "Validate composer.json" + run: "composer validate --strict" # PHP syntax validation php: - name: PHP syntax validation - runs-on: ubuntu-latest + name: "PHP syntax validation" + runs-on: "ubuntu-latest" + strategy: + matrix: + php_version: [ 8.0, 8.1, 8.2, 8.3 ] steps: - - uses: actions/checkout@v3 - - name: Check PHP syntax of config/phinx.php - run: php -l src/ + - uses: "actions/checkout@v3" + - uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php_version }}" + - name: "Check PHP syntax of package" + run: "php -l src/" # phpstan for several php versions phpstan: - runs-on: ubuntu-latest + runs-on: "ubuntu-latest" strategy: matrix: - php_version: [8.1, 8.2, 8.3] + php_version: [8.0, 8.1, 8.2, 8.3] steps: - - uses: actions/checkout@v3 - - uses: php-actions/composer@v6 + - uses: "actions/checkout@v3" + - uses: "php-actions/composer@v6" with: - php_version: ${{ matrix.php_version }} - php_extensions: redis intl + php_version: "${{ matrix.php_version }}" + php_extensions: "redis intl" - - name: PHPStan Static Analysis - uses: php-actions/phpstan@v3 + - name: "PHPStan Static Analysis" + uses: "php-actions/phpstan@v3" with: - php_version: ${{ matrix.php_version }} - configuration: phpstan.neon - path: src/ + php_version: "${{ matrix.php_version }}" + configuration: "phpstan.neon" diff --git a/phpstan.neon b/phpstan.neon index 4a76af1..b6743d2 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,5 @@ parameters: level: 9 - treatPhpDocTypesAsCertain: false - checkGenericClassInNonGenericObjectType: false ignoreErrors: - message: '#Call to an undefined method Predis\\Client::[a-zA-Z0-9\\_]+\(\)#' diff --git a/src/Cache/Engine/PredisEngine.php b/src/Cache/Engine/PredisEngine.php index 440bfd6..592eb57 100644 --- a/src/Cache/Engine/PredisEngine.php +++ b/src/Cache/Engine/PredisEngine.php @@ -78,7 +78,7 @@ class PredisEngine extends CacheEngine * @param array $config array of setting for the engine * @return bool True if the engine has been successfully initialized, false if not */ - public function init($config = array()): bool + public function init(array $config = []): bool { if (!class_exists('\Predis\Client')) { return false; @@ -302,7 +302,7 @@ public function deleteAsync(string $key): bool * @param bool $check * @return bool */ - public function clear($check = false): bool + public function clear(bool $check = false): bool { if ($check) { return true; @@ -337,7 +337,7 @@ public function clearBlocking(): bool while (true) { $keys = $this->_Redis->scan($iterator, $pattern); - if ($keys === false) { + if (empty($keys)) { break; }