From d7330a75f5c076d7c581ae2112045a261cd76b1a Mon Sep 17 00:00:00 2001 From: Nicolas Hedger Date: Sat, 17 Sep 2022 09:07:07 +0200 Subject: [PATCH] ci: set up PHPStan --- .github/workflows/ci.yml | 20 ++++ phpstan-baseline.neon | 216 +++++++++++++++++++++++++++++++++++++++ phpstan.neon | 8 ++ 3 files changed, 244 insertions(+) create mode 100644 phpstan-baseline.neon create mode 100644 phpstan.neon diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0724232..b2fe2d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,3 +47,23 @@ jobs: - run: composer self-update --2.2 # downgrade Composer for HHVM - run: hhvm $(which composer) install - run: hhvm vendor/bin/phpunit + + PHPStan: + name: PHPStan + runs-on: ubuntu-20.04 + strategy: + matrix: + php: [ 8.1 ] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + tools: phpstan + - name: Install Composer dependencies + run: composer install + - name: Run static analysis + run: phpstan analyse diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..ec0fa59 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,216 @@ +parameters: + ignoreErrors: + - + message: "#^Method React\\\\Cache\\\\ArrayCache\\:\\:getMultiple\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/ArrayCache.php + + - + message: "#^Method React\\\\Cache\\\\ArrayCache\\:\\:setMultiple\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#" + count: 1 + path: src/ArrayCache.php + + - + message: "#^Property React\\\\Cache\\\\ArrayCache\\:\\:\\$data has no type specified\\.$#" + count: 1 + path: src/ArrayCache.php + + - + message: "#^Property React\\\\Cache\\\\ArrayCache\\:\\:\\$expires has no type specified\\.$#" + count: 1 + path: src/ArrayCache.php + + - + message: "#^Property React\\\\Cache\\\\ArrayCache\\:\\:\\$limit has no type specified\\.$#" + count: 1 + path: src/ArrayCache.php + + - + message: "#^Property React\\\\Cache\\\\ArrayCache\\:\\:\\$supportsHighResolution has no type specified\\.$#" + count: 1 + path: src/ArrayCache.php + + - + message: "#^Method React\\\\Cache\\\\CacheInterface\\:\\:getMultiple\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/CacheInterface.php + + - + message: "#^Method React\\\\Cache\\\\CacheInterface\\:\\:setMultiple\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#" + count: 1 + path: src/CacheInterface.php + + - + message: "#^PHPDoc tag @return contains generic type React\\\\Promise\\\\PromiseInterface\\ but interface React\\\\Promise\\\\PromiseInterface is not generic\\.$#" + count: 1 + path: src/CacheInterface.php + + - + message: "#^PHPDoc tag @return contains generic type React\\\\Promise\\\\PromiseInterface\\ but interface React\\\\Promise\\\\PromiseInterface is not generic\\.$#" + count: 6 + path: src/CacheInterface.php + + - + message: "#^PHPDoc tag @return contains generic type React\\\\Promise\\\\PromiseInterface\\ but interface React\\\\Promise\\\\PromiseInterface is not generic\\.$#" + count: 1 + path: src/CacheInterface.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:deleteShouldDeleteKey\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:getShouldResolvePromiseWithNullForNonExistentKey\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:hasShouldResolvePromiseForExistingKey\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:hasShouldResolvePromiseForNonExistentKey\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:setShouldSetKey\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:setUpArrayCache\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testClearShouldClearCache\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testDeleteMultiple\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testGetMultiple\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testGetWillResolveWithDefaultIfItemIsExpired\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testGetWillResolveWithDefaultValueForCacheMiss\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testGetWillResolveWithExplicitNullValueForCacheHit\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testGetWillResolveWithNullForCacheMiss\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testGetWillResolveWithValueIfItemIsNotExpired\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testGetWithLimitedSizeWillUpdateLRUInfo\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testHasWillResolveForExplicitNullValue\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testHasWillResolveIfItemIsExpired\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testHasWillResolveIfItemIsNotExpired\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testHasWithLimitedSizeWillUpdateLRUInfo\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testLimitSizeToOneWillOnlyReturnLastWrite\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testLimitSizeToZeroDoesNotStoreAnyData\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testOverwriteWithLimitedSizeWillUpdateLRUInfo\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testSetMultiple\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testSetWillOverwritOldestItemIfNoEntryIsExpired\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\ArrayCacheTest\\:\\:testSetWillOverwriteExpiredItemIfAnyEntryIsExpired\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/ArrayCacheTest.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\TestCase\\:\\:createCallableMock\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/TestCase.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\TestCase\\:\\:expectCallableExactly\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/TestCase.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\TestCase\\:\\:expectCallableExactly\\(\\) has parameter \\$amount with no type specified\\.$#" + count: 1 + path: tests/TestCase.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\TestCase\\:\\:expectCallableNever\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/TestCase.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\TestCase\\:\\:expectCallableOnce\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/TestCase.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\TestCase\\:\\:expectCallableOnceWith\\(\\) has no return type specified\\.$#" + count: 1 + path: tests/TestCase.php + + - + message: "#^Method React\\\\Tests\\\\Cache\\\\TestCase\\:\\:expectCallableOnceWith\\(\\) has parameter \\$param with no type specified\\.$#" + count: 1 + path: tests/TestCase.php diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..00d959f --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,8 @@ +includes: + - phpstan-baseline.neon + +parameters: + level: 9 + paths: + - src + - tests