Skip to content

Commit 3974c97

Browse files
committed
add return declaration to all remaining methods missing them
1 parent 63a2641 commit 3974c97

13 files changed

+45
-55
lines changed

src/ProxyClient/Dispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ interface Dispatcher
2929
* a base uri or the invalidation request
3030
* specifies the host
3131
*/
32-
public function invalidate(RequestInterface $invalidationRequest, bool $validateHost = true);
32+
public function invalidate(RequestInterface $invalidationRequest, bool $validateHost = true): void;
3333

3434
/**
3535
* Send all pending invalidation requests and make sure the requests have

src/UserContext/ContextProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface ContextProvider
1919
/**
2020
* This function is called before generating the hash of a UserContext.
2121
*
22-
* This allow to add a parameter on UserContext or set the whole array of parameters
22+
* This allows to add parameters on UserContext or replace the whole array of parameters
2323
*/
24-
public function updateUserContext(UserContext $context);
24+
public function updateUserContext(UserContext $context): void;
2525
}

tests/Unit/CacheInvalidatorTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class CacheInvalidatorTest extends TestCase
3737
{
3838
use MockeryPHPUnitIntegration;
3939

40-
public function testSupportsTrue()
40+
public function testSupportsTrue(): void
4141
{
4242
/** @var MockInterface&Varnish $proxyClient */
4343
$proxyClient = \Mockery::mock(Varnish::class);
@@ -50,7 +50,7 @@ public function testSupportsTrue()
5050
$this->assertTrue($cacheInvalidator->supports(CacheInvalidator::TAGS));
5151
}
5252

53-
public function testSupportsFalse()
53+
public function testSupportsFalse(): void
5454
{
5555
/** @var MockInterface&ProxyClient $proxyClient */
5656
$proxyClient = \Mockery::mock(ProxyClient::class);
@@ -63,7 +63,7 @@ public function testSupportsFalse()
6363
$this->assertFalse($cacheInvalidator->supports(CacheInvalidator::TAGS));
6464
}
6565

66-
public function testSupportsInvalid()
66+
public function testSupportsInvalid(): void
6767
{
6868
/** @var MockInterface&ProxyClient $proxyClient */
6969
$proxyClient = \Mockery::mock(ProxyClient::class);
@@ -74,7 +74,7 @@ public function testSupportsInvalid()
7474
$cacheInvalidator->supports('garbage');
7575
}
7676

77-
public function testInvalidatePath()
77+
public function testInvalidatePath(): void
7878
{
7979
/** @var MockInterface&PurgeCapable $purge */
8080
$purge = \Mockery::mock(PurgeCapable::class)
@@ -92,7 +92,7 @@ public function testInvalidatePath()
9292
;
9393
}
9494

95-
public function testRefreshPath()
95+
public function testRefreshPath(): void
9696
{
9797
$headers = ['X' => 'Y'];
9898
/** @var MockInterface&RefreshCapable $refresh */
@@ -108,7 +108,7 @@ public function testRefreshPath()
108108
;
109109
}
110110

111-
public function testInvalidate()
111+
public function testInvalidate(): void
112112
{
113113
$headers = [
114114
'X-Header' => '^value.*$',
@@ -126,7 +126,7 @@ public function testInvalidate()
126126
$cacheInvalidator->invalidate($headers);
127127
}
128128

129-
public function testInvalidateTags()
129+
public function testInvalidateTags(): void
130130
{
131131
$tags = [
132132
'post-8',
@@ -144,7 +144,7 @@ public function testInvalidateTags()
144144
$cacheInvalidator->invalidateTags($tags);
145145
}
146146

147-
public function testInvalidateRegex()
147+
public function testInvalidateRegex(): void
148148
{
149149
/** @var MockInterface&BanCapable $ban */
150150
$ban = \Mockery::mock(BanCapable::class)
@@ -181,7 +181,7 @@ public function testMethodException(string $method, $arg): void
181181
$cacheInvalidator->$method($arg);
182182
}
183183

184-
public function testProxyClientExceptionsAreLogged()
184+
public function testProxyClientExceptionsAreLogged(): void
185185
{
186186
/** @var MockInterface&RequestInterface $failedRequest */
187187
$failedRequest = \Mockery::mock(RequestInterface::class)
@@ -230,7 +230,7 @@ public function testProxyClientExceptionsAreLogged()
230230
;
231231
}
232232

233-
public function testEventDispatcher()
233+
public function testEventDispatcher(): void
234234
{
235235
/** @var MockInterface&Varnish $proxyClient */
236236
$proxyClient = \Mockery::mock(Varnish::class);
@@ -241,7 +241,7 @@ public function testEventDispatcher()
241241
$this->assertSame($eventDispatcher, $cacheInvalidator->getEventDispatcher());
242242
}
243243

244-
public function testEventDispatcherImmutable()
244+
public function testEventDispatcherImmutable(): void
245245
{
246246
/** @var MockInterface&Varnish $proxyClient */
247247
$proxyClient = \Mockery::mock(Varnish::class);

tests/Unit/Test/NginxTestTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace FOS\HttpCache\Tests\Unit\Test;
1313

1414
use FOS\HttpCache\Test\NginxTest;
15-
use FOS\HttpCache\Test\Proxy\NginxProxy;
1615
use PHPUnit\Framework\TestCase;
1716

1817
class NginxTestTest extends TestCase
@@ -24,20 +23,19 @@ protected function setUp(): void
2423
// do not try to set up proxy
2524
}
2625

27-
protected function getBinary()
26+
protected function getBinary(): string
2827
{
2928
return '/test/binary';
3029
}
3130

32-
protected function getCacheDir()
31+
protected function getCacheDir(): string
3332
{
3433
return '/tmp/foobar';
3534
}
3635

37-
public function testGetProxy()
36+
public function testGetProxy(): void
3837
{
3938
$proxy = $this->getProxy();
40-
$this->assertInstanceOf(NginxProxy::class, $proxy);
4139

4240
$this->assertEquals('/test/binary', $proxy->getBinary());
4341
$this->assertEquals('/tmp/foobar', $proxy->getCacheDir());

tests/Unit/Test/PHPUnit/AbstractCacheConstraintTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
namespace FOS\HttpCache\Tests\Unit\Test\PHPUnit;
1313

1414
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
15+
use Mockery\MockInterface;
1516
use PHPUnit\Framework\TestCase;
17+
use Psr\Http\Message\ResponseInterface;
1618

1719
abstract class AbstractCacheConstraintTest extends TestCase
1820
{
1921
use MockeryPHPUnitIntegration;
2022

21-
protected function getResponseMock()
23+
protected function getResponseMock(): ResponseInterface&MockInterface
2224
{
23-
$mock = \Mockery::mock(
25+
return \Mockery::mock(
2426
'\Psr\Http\Message\ResponseInterface[hasHeader,getHeaderLine,getStatusCode,getHeaders,getBody]'
2527
);
26-
27-
return $mock;
2828
}
2929
}

tests/Unit/Test/PHPUnit/IsCacheHitConstraintTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,14 @@
1717

1818
class IsCacheHitConstraintTest extends AbstractCacheConstraintTest
1919
{
20-
/**
21-
* @var IsCacheHitConstraint
22-
*/
23-
private $constraint;
20+
private IsCacheHitConstraint $constraint;
2421

2522
public function setUp(): void
2623
{
2724
$this->constraint = new IsCacheHitConstraint('cache-header');
2825
}
2926

30-
public function testMatches()
27+
public function testMatches(): void
3128
{
3229
$response = $this->getResponseMock()
3330
->shouldReceive('hasHeader')->with('cache-header')->andReturn(true)
@@ -42,7 +39,7 @@ public function testMatches()
4239
$this->constraint->evaluate($response);
4340
}
4441

45-
public function testMatchesThrowsExceptionIfHeaderIsMissing()
42+
public function testMatchesThrowsExceptionIfHeaderIsMissing(): void
4643
{
4744
$this->expectException(\RuntimeException::class);
4845
$this->expectExceptionMessage('Response has no "cache-header" header');

tests/Unit/Test/PHPUnit/IsCacheMissConstraintTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,14 @@
1616

1717
class IsCacheMissConstraintTest extends AbstractCacheConstraintTest
1818
{
19-
/**
20-
* @var IsCacheMissConstraint
21-
*/
22-
private $constraint;
19+
private IsCacheMissConstraint $constraint;
2320

2421
public function setUp(): void
2522
{
2623
$this->constraint = new IsCacheMissConstraint('cache-header');
2724
}
2825

29-
public function testMatches()
26+
public function testMatches(): void
3027
{
3128
$response = $this->getResponseMock()
3229
->shouldReceive('hasHeader')->with('cache-header')->andReturn(true)

tests/Unit/Test/Proxy/SymfonyProxyTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class SymfonyProxyTest extends TestCase
1818
{
19-
public function testStart()
19+
public function testStart(): void
2020
{
2121
$proxy = new SymfonyProxy();
2222
$proxy->start();
@@ -25,7 +25,7 @@ public function testStart()
2525
$this->addToAssertionCount(1);
2626
}
2727

28-
public function testInvalidDirectoryThrowsException()
28+
public function testInvalidDirectoryThrowsException(): void
2929
{
3030
define('SYMFONY_CACHE_DIR', '/');
3131
$proxy = new SymfonyProxy();

tests/Unit/Test/Proxy/VarnishProxyTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function testStart(bool $inlineC): void
6262
$this->assertEquals($arguments, $proxy->arguments);
6363
}
6464

65-
public function testWaitThrowsException()
65+
public function testWaitThrowsException(): void
6666
{
6767
$proxy = new VarnishProxyMock('config.vcl');
6868
$proxy->wait = false;

tests/Unit/Test/VarnishTestTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace FOS\HttpCache\Tests\Unit\Test;
1313

14-
use FOS\HttpCache\Test\Proxy\VarnishProxy;
1514
use FOS\HttpCache\Test\VarnishTest;
1615
use PHPUnit\Framework\TestCase;
1716

@@ -24,30 +23,29 @@ protected function setUp(): void
2423
// do not try to set up proxy
2524
}
2625

27-
protected function getBinary()
26+
protected function getBinary(): string
2827
{
2928
return '/test/binary';
3029
}
3130

32-
protected function getCachingProxyPort()
31+
protected function getCachingProxyPort(): int
3332
{
3433
return 123;
3534
}
3635

37-
protected function getVarnishMgmtPort()
36+
protected function getVarnishMgmtPort(): int
3837
{
3938
return 321;
4039
}
4140

42-
protected function getCacheDir()
41+
protected function getCacheDir(): string
4342
{
4443
return '/tmp/foobar';
4544
}
4645

47-
public function testGetProxy()
46+
public function testGetProxy(): void
4847
{
4948
$proxy = $this->getProxy();
50-
$this->assertInstanceOf(VarnishProxy::class, $proxy);
5149

5250
$this->assertEquals('/test/binary', $proxy->getBinary());
5351
$this->assertEquals(123, $proxy->getPort());

tests/Unit/UserContext/AnonymousRequestMatcherTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class AnonymousRequestMatcherTest extends TestCase
2020
{
2121
use MockeryPHPUnitIntegration;
2222

23-
public function testMatchAnonymousRequest()
23+
public function testMatchAnonymousRequest(): void
2424
{
2525
$request = new Request();
2626

@@ -32,7 +32,7 @@ public function testMatchAnonymousRequest()
3232
$this->assertTrue($requestMatcher->matches($request));
3333
}
3434

35-
public function testNoMatchIfCookie()
35+
public function testNoMatchIfCookie(): void
3636
{
3737
$request = new Request();
3838
$request->headers->set('Cookie', 'foo=bar');
@@ -46,7 +46,7 @@ public function testNoMatchIfCookie()
4646
$this->assertFalse($requestMatcher->matches($request));
4747
}
4848

49-
public function testNoMatchIfSession()
49+
public function testNoMatchIfSession(): void
5050
{
5151
$request = new Request();
5252
$request->headers->set('Cookie', 'PHPSESSID7e476fc9f29f69d2ad6f11dbcd663b42=25f6d9c5a843e3c948cd26902385a527');
@@ -60,7 +60,7 @@ public function testNoMatchIfSession()
6060
$this->assertFalse($requestMatcher->matches($request));
6161
}
6262

63-
public function testMatchIfNoSessionCookie()
63+
public function testMatchIfNoSessionCookie(): void
6464
{
6565
$request = new Request();
6666
$request->headers->set('Cookie', 'foo=bar');
@@ -74,7 +74,7 @@ public function testMatchIfNoSessionCookie()
7474
$this->assertTrue($requestMatcher->matches($request));
7575
}
7676

77-
public function testNoMatchIfAuthenticationHeader()
77+
public function testNoMatchIfAuthenticationHeader(): void
7878
{
7979
$request = new Request();
8080
$request->headers->set('Authorization', 'foo: bar');

tests/Unit/UserContext/HashGeneratorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
class HashGeneratorTest extends TestCase
2121
{
22-
public function testGenerateHash()
22+
public function testGenerateHash(): void
2323
{
2424
$hashGenerator = new DefaultHashGenerator([new FooProvider()]);
2525

@@ -28,7 +28,7 @@ public function testGenerateHash()
2828
$this->assertEquals($expectedHash, $hashGenerator->generateHash());
2929
}
3030

31-
public function testConstructorError()
31+
public function testConstructorError(): void
3232
{
3333
$this->expectException(InvalidArgumentException::class);
3434
new DefaultHashGenerator([]);
@@ -37,7 +37,7 @@ public function testConstructorError()
3737

3838
class FooProvider implements ContextProvider
3939
{
40-
public function updateUserContext(UserContext $context)
40+
public function updateUserContext(UserContext $context): void
4141
{
4242
$context->addParameter('foo', 'bar');
4343
}

tests/Unit/UserContext/UserContextTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class UserContextTest extends TestCase
1818
{
19-
public function testAddParameter()
19+
public function testAddParameter(): void
2020
{
2121
$userContext = new UserContext();
2222
$userContext->addParameter('authenticated', true);
@@ -25,10 +25,10 @@ public function testAddParameter()
2525

2626
$parameters = $userContext->getParameters();
2727

28-
$this->assertEquals(true, $parameters['authenticated']);
28+
$this->assertTrue($parameters['authenticated']);
2929
}
3030

31-
public function testSetParameters()
31+
public function testSetParameters(): void
3232
{
3333
$userContext = new UserContext();
3434

0 commit comments

Comments
 (0)