From fd48954d1b2381b8a3c15f89683da98188ef24d9 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Fri, 3 Jan 2025 10:25:16 +0100 Subject: [PATCH] phpstan level 4 --- .github/workflows/static.yml | 4 ++-- phpstan.neon.dist | 3 +-- src/ProxyClient/MultiplexerClient.php | 6 ++++-- src/Test/WebServerSubscriber.php | 2 -- tests/Functional/ProxyClient/NginxProxyClientTest.php | 4 ++-- tests/Unit/SymfonyCache/KernelDispatcherTest.php | 3 +-- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 6aa269f7..9b07dcc9 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -8,7 +8,7 @@ on: jobs: phpstan-src: - name: PHPStan src + name: PHPStan runs-on: ubuntu-latest steps: @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@v4 - name: Pull in optional dependencies - run: composer require --no-update phpunit/phpunit toflar/psr6-symfony-http-cache-store:^4.2 symfony/process phpstan/phpstan-mockery + run: composer require --no-update phpunit/phpunit toflar/psr6-symfony-http-cache-store:^4.2 symfony/process mockery/mockery phpstan/phpstan-mockery guzzlehttp/guzzle php-http/mock-client - name: Cache Vendor id: cache-vendor diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 74898875..e03bb8ad 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -4,5 +4,4 @@ parameters: - src - tests -includes: - - vendor/phpstan/phpstan-mockery/extension.neon + treatPhpDocTypesAsCertain: false diff --git a/src/ProxyClient/MultiplexerClient.php b/src/ProxyClient/MultiplexerClient.php index e31d5bc5..896fbbe1 100644 --- a/src/ProxyClient/MultiplexerClient.php +++ b/src/ProxyClient/MultiplexerClient.php @@ -133,7 +133,7 @@ public function clear(): static * Invoke the given $method on all available ProxyClients implementing the * given $interface. * - * @param string $interface The FQN of the interface + * @param class-string $interface The FQN of the interface * @param string $method The method to invoke * @param array $arguments The arguments to be passed to the method */ @@ -155,7 +155,9 @@ private function getProxyClients(string $interface): array { return array_filter( $this->proxyClients, - static function ($proxyClient) use ($interface) { + static function (ProxyClient $proxyClient) use ($interface) { + // https://github.com/phpstan/phpstan/issues/8464 + // @phpstan-ignore-next-line return is_subclass_of($proxyClient, $interface); } ); diff --git a/src/Test/WebServerSubscriber.php b/src/Test/WebServerSubscriber.php index 3e26b49f..00120d7d 100644 --- a/src/Test/WebServerSubscriber.php +++ b/src/Test/WebServerSubscriber.php @@ -52,8 +52,6 @@ private function hasTestsWithGroup(TestSuite $testSuite, string $group): bool continue; } - assert($test instanceof TestMethod); - foreach ($test->metadata()->isGroup() as $testGroup) { assert($testGroup instanceof Group); diff --git a/tests/Functional/ProxyClient/NginxProxyClientTest.php b/tests/Functional/ProxyClient/NginxProxyClientTest.php index e9ee423f..2df464e0 100644 --- a/tests/Functional/ProxyClient/NginxProxyClientTest.php +++ b/tests/Functional/ProxyClient/NginxProxyClientTest.php @@ -35,7 +35,7 @@ public function testPurgeContentType(): void { $this->markTestSkipped('Not working with nginx, it can only purge one type'); - $this->assertPurgeContentType($this->getProxyClient()); + // $this->assertPurgeContentType($this->getProxyClient()); } public function testPurgeSeparateLocationHost(): void @@ -57,6 +57,6 @@ public function testRefreshContentType(): void { $this->markTestSkipped('TODO: is nginx mixing up variants?'); - $this->assertRefreshContentType($this->getProxyClient()); + // $this->assertRefreshContentType($this->getProxyClient()); } } diff --git a/tests/Unit/SymfonyCache/KernelDispatcherTest.php b/tests/Unit/SymfonyCache/KernelDispatcherTest.php index 0008e2d2..8820a109 100644 --- a/tests/Unit/SymfonyCache/KernelDispatcherTest.php +++ b/tests/Unit/SymfonyCache/KernelDispatcherTest.php @@ -33,8 +33,7 @@ public function testFlush(): void ->with($this->callback(function (Request $request) { // Test if the Symfony request contains the relevant information // from the PSR-7 request - $valid = true; - $valid = $valid && 'PURGETAGS' === $request->getMethod(); + $valid = 'PURGETAGS' === $request->getMethod(); $valid = $valid && 'foobar' === $request->headers->get('content-type'); $valid = $valid && 'foo,bar,stuff' === $request->headers->get('x-cache-tags'); $valid = $valid && ['query' => 'string', 'more' => 'stuff'] === $request->query->all();