From f02f3356db4f8f5bb30cb63bc11d83c6ac888611 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 4 Mar 2026 09:37:52 +0100 Subject: [PATCH 1/2] allow to trigger workflows manually --- .github/workflows/ci.yml | 1 + .github/workflows/spellcheck.yml | 1 + .github/workflows/static.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d2332a0..ffde1671 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,7 @@ on: branches: - "*.x" pull_request: + workflow_dispatch: env: DEPENDENCIES: 'toflar/psr6-symfony-http-cache-store:^2|^3|^4' diff --git a/.github/workflows/spellcheck.yml b/.github/workflows/spellcheck.yml index c8f7308c..6f82d82d 100644 --- a/.github/workflows/spellcheck.yml +++ b/.github/workflows/spellcheck.yml @@ -5,6 +5,7 @@ on: branches: - "*.x" pull_request: + workflow_dispatch: jobs: build: diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 9b07dcc9..f61a627b 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -5,6 +5,7 @@ on: branches: - "*.x" pull_request: + workflow_dispatch: jobs: phpstan-src: From bcba9a2bea68963644ad82bcbde4e881ce89f506 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 4 Mar 2026 10:04:06 +0100 Subject: [PATCH 2/2] adjust to phpstan being more precise which line of chained calls triggers an error --- .gitignore | 1 + .../Symfony/EventDispatchingHttpCacheTest.php | 4 ++-- .../Varnish/UserContextFailureTest.php | 4 +--- tests/Unit/CacheInvalidatorTest.php | 16 ++++++++-------- tests/Unit/ResponseTaggerTest.php | 12 ++++++------ .../PHPUnit/IsCacheHitConstraintTestCase.php | 8 ++++---- .../PHPUnit/IsCacheMissConstraintTestCase.php | 4 ++-- 7 files changed, 24 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index ac24059a..13d47e4a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ vendor/ composer.lock phpunit.xml +phpstan.neon doc/_build/ .php-cs-fixer.cache puli.json diff --git a/tests/Functional/Symfony/EventDispatchingHttpCacheTest.php b/tests/Functional/Symfony/EventDispatchingHttpCacheTest.php index ef76c7e4..bbb70cf8 100644 --- a/tests/Functional/Symfony/EventDispatchingHttpCacheTest.php +++ b/tests/Functional/Symfony/EventDispatchingHttpCacheTest.php @@ -44,10 +44,10 @@ public function testEventListeners(): void ->shouldReceive('handle') ->andReturn($expectedResponse) ->getMock(); - // https://github.com/phpstan/phpstan-mockery/issues/8 - /** @phpstan-ignore-next-line */ $store = \Mockery::mock(StoreInterface::class) ->shouldReceive('lookup')->andReturn(null)->times(1) + // https://github.com/phpstan/phpstan-mockery/issues/8 + /* @phpstan-ignore-next-line */ ->shouldReceive('write')->times(1) ->shouldReceive('unlock')->times(1) // need to declare the cleanup function explicitly to avoid issue between register_shutdown_function and mockery diff --git a/tests/Functional/Varnish/UserContextFailureTest.php b/tests/Functional/Varnish/UserContextFailureTest.php index 93089919..b202b319 100644 --- a/tests/Functional/Varnish/UserContextFailureTest.php +++ b/tests/Functional/Varnish/UserContextFailureTest.php @@ -26,9 +26,7 @@ class UserContextFailureTest extends VarnishTestCase public function setUp(): void { // needs to be decided before doing the setup - // phpunit 9 calls the method getName(), phpunit 10 name() - $name = method_exists($this, 'name') ? $this->name() : $this->getName(); /* @phpstan-ignore-line */ - $this->mode = 'testHashRequestFailure' === $name ? 'failure' : 'cache'; + $this->mode = 'testHashRequestFailure' === $this->name() ? 'failure' : 'cache'; parent::setUp(); } diff --git a/tests/Unit/CacheInvalidatorTest.php b/tests/Unit/CacheInvalidatorTest.php index db50f578..7d505f21 100644 --- a/tests/Unit/CacheInvalidatorTest.php +++ b/tests/Unit/CacheInvalidatorTest.php @@ -78,10 +78,10 @@ public function testSupportsInvalid(): void public function testInvalidatePath(): void { /** @var MockInterface&PurgeCapable $purge */ - // https://github.com/phpstan/phpstan-mockery/issues/8 - /** @phpstan-ignore-next-line */ $purge = \Mockery::mock(PurgeCapable::class) ->shouldReceive('purge')->once()->with('/my/route', []) + // https://github.com/phpstan/phpstan-mockery/issues/8 + /* @phpstan-ignore-next-line */ ->shouldReceive('purge')->once()->with('/my/route', ['X-Test-Header' => 'xyz']) ->shouldReceive('flush')->once() ->getMock(); @@ -99,10 +99,10 @@ public function testRefreshPath(): void { $headers = ['X' => 'Y']; /** @var MockInterface&RefreshCapable $refresh */ - // https://github.com/phpstan/phpstan-mockery/issues/8 - /** @phpstan-ignore-next-line */ $refresh = \Mockery::mock(RefreshCapable::class) ->shouldReceive('refresh')->once()->with('/my/route', $headers) + // https://github.com/phpstan/phpstan-mockery/issues/8 + /* @phpstan-ignore-next-line */ ->shouldReceive('flush')->never() ->getMock(); @@ -194,10 +194,10 @@ public function testProxyClientExceptionsAreLogged(): void $unreachableException = ProxyUnreachableException::proxyUnreachable($clientException); - // https://github.com/phpstan/phpstan-mockery/issues/8 - /** @phpstan-ignore-next-line */ $response = \Mockery::mock(ResponseInterface::class) ->shouldReceive('getStatusCode')->andReturn(403) + // https://github.com/phpstan/phpstan-mockery/issues/8 + /* @phpstan-ignore-next-line */ ->shouldReceive('getReasonPhrase')->andReturn('Forbidden') ->getMock(); $responseException = ProxyResponseException::proxyResponse(new HttpException('test', $failedRequest, $response)); @@ -212,8 +212,6 @@ public function testProxyClientExceptionsAreLogged(): void $cacheInvalidator = new CacheInvalidator($proxyClient); - // https://github.com/phpstan/phpstan-mockery/issues/8 - /** @phpstan-ignore-next-line */ $logger = \Mockery::mock(LoggerInterface::class) ->shouldReceive('log')->once() ->with( @@ -221,6 +219,8 @@ public function testProxyClientExceptionsAreLogged(): void 'Request to caching proxy at 127.0.0.1 failed with message "Couldn\'t connect to host"', ['exception' => $unreachableException] ) + // https://github.com/phpstan/phpstan-mockery/issues/8 + /* @phpstan-ignore-next-line */ ->shouldReceive('log')->once() ->with( 'critical', diff --git a/tests/Unit/ResponseTaggerTest.php b/tests/Unit/ResponseTaggerTest.php index a8309624..6ca5fbc9 100644 --- a/tests/Unit/ResponseTaggerTest.php +++ b/tests/Unit/ResponseTaggerTest.php @@ -48,13 +48,13 @@ public function testGetTagsHeaderValue(): void public function testTagResponseReplace(): void { - // https://github.com/phpstan/phpstan-mockery/issues/8 - /** @phpstan-ignore-next-line */ $headerFormatter = \Mockery::mock(TagHeaderFormatter::class) ->shouldReceive('getTagsHeaderValue') ->with(['tag-1', 'tag-2']) ->once() ->andReturn('tag-1,tag-2') + // https://github.com/phpstan/phpstan-mockery/issues/8 + /* @phpstan-ignore-next-line */ ->shouldReceive('getTagsHeaderName') ->once() ->andReturn('FOS-Tags') @@ -75,13 +75,13 @@ public function testTagResponseReplace(): void public function testTagResponseAdd(): void { - // https://github.com/phpstan/phpstan-mockery/issues/8 - /** @phpstan-ignore-next-line */ $headerFormatter = \Mockery::mock(TagHeaderFormatter::class) ->shouldReceive('getTagsHeaderValue') ->with(['tag-1', 'tag-2']) ->once() ->andReturn('tag-1,tag-2') + // https://github.com/phpstan/phpstan-mockery/issues/8 + /* @phpstan-ignore-next-line */ ->shouldReceive('getTagsHeaderName') ->once() ->andReturn('FOS-Tags') @@ -109,10 +109,10 @@ public function testTagResponseNoTags(): void $tagger = new ResponseTagger(['header_formatter' => $headerFormatter]); - // https://github.com/phpstan/phpstan-mockery/issues/8 - /** @phpstan-ignore-next-line */ $response = \Mockery::mock(ResponseInterface::class) ->shouldReceive('withHeader')->never() + // https://github.com/phpstan/phpstan-mockery/issues/8 + /* @phpstan-ignore-next-line */ ->shouldReceive('withAddedHeader')->never() ->getMock(); diff --git a/tests/Unit/Test/PHPUnit/IsCacheHitConstraintTestCase.php b/tests/Unit/Test/PHPUnit/IsCacheHitConstraintTestCase.php index 58bda109..39cc175b 100644 --- a/tests/Unit/Test/PHPUnit/IsCacheHitConstraintTestCase.php +++ b/tests/Unit/Test/PHPUnit/IsCacheHitConstraintTestCase.php @@ -26,10 +26,10 @@ public function setUp(): void public function testMatches(): void { - // https://github.com/phpstan/phpstan-mockery/issues/8 - /** @phpstan-ignore-next-line */ $response = $this->getResponseMock() ->shouldReceive('hasHeader')->with('cache-header')->andReturn(true) + // https://github.com/phpstan/phpstan-mockery/issues/8 + /* @phpstan-ignore-next-line */ ->shouldReceive('getHeaderLine')->with('cache-header')->once()->andReturn('MISS') ->shouldReceive('getStatusCode')->andReturn(500) ->shouldReceive('getHeaders')->andReturn([]) @@ -46,10 +46,10 @@ public function testMatchesThrowsExceptionIfHeaderIsMissing(): void $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Response has no "cache-header" header'); - // https://github.com/phpstan/phpstan-mockery/issues/8 - /** @phpstan-ignore-next-line */ $response = $this->getResponseMock() ->shouldReceive('hasHeader')->with('cache-header')->once()->andReturn(false) + // https://github.com/phpstan/phpstan-mockery/issues/8 + /* @phpstan-ignore-next-line */ ->shouldReceive('getStatusCode')->andReturn(200) ->shouldReceive('getHeaders')->andReturn([]) ->shouldReceive('getBody')->andReturn(new Stream(fopen('php://temp', 'r+'))) diff --git a/tests/Unit/Test/PHPUnit/IsCacheMissConstraintTestCase.php b/tests/Unit/Test/PHPUnit/IsCacheMissConstraintTestCase.php index 4f4133bc..11cb845b 100644 --- a/tests/Unit/Test/PHPUnit/IsCacheMissConstraintTestCase.php +++ b/tests/Unit/Test/PHPUnit/IsCacheMissConstraintTestCase.php @@ -25,10 +25,10 @@ public function setUp(): void public function testMatches(): void { - // https://github.com/phpstan/phpstan-mockery/issues/8 - /** @phpstan-ignore-next-line */ $response = $this->getResponseMock() ->shouldReceive('hasHeader')->with('cache-header')->andReturn(true) + // https://github.com/phpstan/phpstan-mockery/issues/8 + /* @phpstan-ignore-next-line */ ->shouldReceive('getHeaderLine')->with('cache-header')->once()->andReturn('HIT') ->shouldReceive('getStatusCode')->andReturn(200) ->getMock();