Skip to content

Commit cf90df3

Browse files
committed
test: remove void from test methods
allow Symfony-style test signatures while keeping PHPStan strict for production code.
1 parent 50febdc commit cf90df3

15 files changed

Lines changed: 71 additions & 67 deletions

‎phpstan.neon‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ parameters:
22
level: 9
33
phpVersion: 80200
44
treatPhpDocTypesAsCertain: false
5+
ignoreErrors:
6+
-
7+
message: '#^Method Cache\\CacheBundle\\Tests\\.*::test[A-Z][A-Za-z0-9_]*\(\) has no return type specified\.$#'
8+
identifier: missingType.return
59
paths:
610
- src
711
- tests

‎tests/Functional/BundleInitializationTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected static function createKernel(array $options = []): KernelInterface
4040
}
4141

4242
#[RunInSeparateProcess]
43-
public function testBootsWithRouterAndProfilerIntegrations(): void
43+
public function testBootsWithRouterAndProfilerIntegrations()
4444
{
4545
self::bootKernel();
4646
$container = self::getContainer();

‎tests/Unit/Cache/FixedTaggingCachePoolTest.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
final class FixedTaggingCachePoolTest extends TestCase
1414
{
15-
public function testReturnsTaggableItems(): void
15+
public function testReturnsTaggableItems()
1616
{
1717
$pool = new FixedTaggingCachePool(new ArrayCachePool(), ['tag']);
1818

@@ -25,7 +25,7 @@ public function testReturnsTaggableItems(): void
2525
self::assertSame(['one', '123'], $keys);
2626
}
2727

28-
public function testSavedItemsReceiveTheFixedTags(): void
28+
public function testSavedItemsReceiveTheFixedTags()
2929
{
3030
$inner = new ArrayCachePool();
3131
$pool = new FixedTaggingCachePool($inner, ['session']);
@@ -37,7 +37,7 @@ public function testSavedItemsReceiveTheFixedTags(): void
3737
self::assertFalse($pool->getItem('key')->isHit());
3838
}
3939

40-
public function testDeferredItemsReceiveTheFixedTags(): void
40+
public function testDeferredItemsReceiveTheFixedTags()
4141
{
4242
$inner = new ArrayCachePool();
4343
$pool = new FixedTaggingCachePool($inner, ['router']);
@@ -49,15 +49,15 @@ public function testDeferredItemsReceiveTheFixedTags(): void
4949
self::assertFalse($pool->getItem('key')->isHit());
5050
}
5151

52-
public function testRejectsItemsFromNonTaggablePools(): void
52+
public function testRejectsItemsFromNonTaggablePools()
5353
{
5454
$pool = new FixedTaggingCachePool(new ArrayCachePool(), ['tag']);
5555

5656
$this->expectException(\InvalidArgumentException::class);
5757
$pool->save($this->createMock(CacheItemInterface::class));
5858
}
5959

60-
public function testDelegatesRegularPoolOperations(): void
60+
public function testDelegatesRegularPoolOperations()
6161
{
6262
$inner = new ArrayCachePool();
6363
$pool = new FixedTaggingCachePool($inner, ['tag']);

‎tests/Unit/CacheBundleTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
final class CacheBundleTest extends TestCase
1616
{
17-
public function testRegistersCompilerPasses(): void
17+
public function testRegistersCompilerPasses()
1818
{
1919
$container = new ContainerBuilder();
2020

‎tests/Unit/Command/CacheFlushCommandTest.php‎

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

2020
final class CacheFlushCommandTest extends TestCase
2121
{
22-
public function testClearsAProvider(): void
22+
public function testClearsAProvider()
2323
{
2424
$pool = new ArrayCachePool();
2525
$pool->save($pool->getItem('key')->set('value'));
@@ -35,7 +35,7 @@ public function testClearsAProvider(): void
3535
self::assertFalse($pool->hasItem('key'));
3636
}
3737

38-
public function testClearsAPrivateConfiguredProviderAfterCompilation(): void
38+
public function testClearsAPrivateConfiguredProviderAfterCompilation()
3939
{
4040
$container = new ContainerBuilder();
4141
$container->setParameter('cache.provider_service_ids', ['cache.pool']);
@@ -59,7 +59,7 @@ public function testClearsAPrivateConfiguredProviderAfterCompilation(): void
5959
self::assertSame(Command::SUCCESS, $status);
6060
}
6161

62-
public function testOnlyExposesPublicAliasesForTaggedProvidersAfterCompilation(): void
62+
public function testOnlyExposesPublicAliasesForTaggedProvidersAfterCompilation()
6363
{
6464
$container = new ContainerBuilder();
6565
$container->setParameter('cache.provider_service_ids', []);
@@ -92,7 +92,7 @@ public function testOnlyExposesPublicAliasesForTaggedProvidersAfterCompilation()
9292
]));
9393
}
9494

95-
public function testInvalidatesTheTagForABuiltInIntegration(): void
95+
public function testInvalidatesTheTagForABuiltInIntegration()
9696
{
9797
$pool = new ArrayCachePool();
9898
$router = $pool->getItem('router')->set('router')->setTags(['router']);
@@ -109,7 +109,7 @@ public function testInvalidatesTheTagForABuiltInIntegration(): void
109109
self::assertTrue($pool->hasItem('session'));
110110
}
111111

112-
public function testRejectsUnknownTypes(): void
112+
public function testRejectsUnknownTypes()
113113
{
114114
$tester = $this->tester(new ContainerBuilder());
115115

@@ -119,7 +119,7 @@ public function testRejectsUnknownTypes(): void
119119
self::assertStringContainsString('Unknown cache type "unknown"', $tester->getDisplay());
120120
}
121121

122-
public function testProviderRequiresAnExistingService(): void
122+
public function testProviderRequiresAnExistingService()
123123
{
124124
$tester = $this->tester(new ContainerBuilder());
125125

@@ -129,7 +129,7 @@ public function testProviderRequiresAnExistingService(): void
129129
self::assertStringContainsString('Pass a cache pool service ID', $tester->getDisplay());
130130
}
131131

132-
public function testProviderRejectsServicesThatAreNotPools(): void
132+
public function testProviderRejectsServicesThatAreNotPools()
133133
{
134134
$container = new ContainerBuilder();
135135
$container->set('not_a_pool', new \stdClass());
@@ -142,7 +142,7 @@ public function testProviderRejectsServicesThatAreNotPools(): void
142142
self::assertSame(Command::FAILURE, $status);
143143
}
144144

145-
public function testClearsANonTaggableBuiltInPool(): void
145+
public function testClearsANonTaggableBuiltInPool()
146146
{
147147
$inner = new ArrayCachePool();
148148
$pool = new TraceableCachePool($inner, 'cache.pool');
@@ -156,7 +156,7 @@ public function testClearsANonTaggableBuiltInPool(): void
156156
self::assertFalse($inner->hasItem('key'));
157157
}
158158

159-
public function testFailsForInvalidBuiltInConfiguration(): void
159+
public function testFailsForInvalidBuiltInConfiguration()
160160
{
161161
$container = new ContainerBuilder();
162162
self::assertSame(
@@ -165,15 +165,15 @@ public function testFailsForInvalidBuiltInConfiguration(): void
165165
);
166166
}
167167

168-
public function testMissingBuiltInConfigurationIsAlreadyClear(): void
168+
public function testMissingBuiltInConfigurationIsAlreadyClear()
169169
{
170170
self::assertSame(
171171
Command::SUCCESS,
172172
$this->tester(new ContainerBuilder())->execute(['type' => 'router']),
173173
);
174174
}
175175

176-
public function testRunsTheSymfonyCacheClearCommand(): void
176+
public function testRunsTheSymfonyCacheClearCommand()
177177
{
178178
$tester = $this->tester(new ContainerBuilder(), new class('cache:clear') extends Command {
179179
protected function execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output): int
@@ -190,23 +190,23 @@ protected function execute(\Symfony\Component\Console\Input\InputInterface $inpu
190190
self::assertStringContainsString('cleared', $tester->getDisplay());
191191
}
192192

193-
public function testSymfonyClearFailsWhenTheCommandIsUnavailable(): void
193+
public function testSymfonyClearFailsWhenTheCommandIsUnavailable()
194194
{
195195
self::assertSame(
196196
Command::FAILURE,
197197
$this->tester(new ContainerBuilder())->execute(['type' => 'symfony']),
198198
);
199199
}
200200

201-
public function testDecliningTheInteractivePromptDoesNothing(): void
201+
public function testDecliningTheInteractivePromptDoesNothing()
202202
{
203203
$tester = $this->tester(new ContainerBuilder());
204204
$tester->setInputs(['no']);
205205

206206
self::assertSame(Command::SUCCESS, $tester->execute([]));
207207
}
208208

209-
public function testConfirmingTheInteractivePromptClearsEverything(): void
209+
public function testConfirmingTheInteractivePromptClearsEverything()
210210
{
211211
$tester = $this->tester(new ContainerBuilder(), new class('cache:clear') extends Command {
212212
protected function execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output): int
@@ -219,7 +219,7 @@ protected function execute(\Symfony\Component\Console\Input\InputInterface $inpu
219219
self::assertSame(Command::SUCCESS, $tester->execute([]));
220220
}
221221

222-
public function testClearAllPropagatesFailures(): void
222+
public function testClearAllPropagatesFailures()
223223
{
224224
$container = new ContainerBuilder();
225225
self::assertSame(

‎tests/Unit/DataCollector/CacheDataCollectorTest.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
final class CacheDataCollectorTest extends TestCase
1717
{
18-
public function testCollectsPerPoolAndTotalStatistics(): void
18+
public function testCollectsPerPoolAndTotalStatistics()
1919
{
2020
$pool = new TraceableCachePool(new ArrayCachePool(), 'cache.pool');
2121
$item = $pool->getItem('key')->set('value');
@@ -45,7 +45,7 @@ public function testCollectsPerPoolAndTotalStatistics(): void
4545
self::assertSame('php-cache', $collector->getName());
4646
}
4747

48-
public function testResetClearsCollectedData(): void
48+
public function testResetClearsCollectedData()
4949
{
5050
$collector = new CacheDataCollector();
5151
$collector->collect(new Request(), new Response());
@@ -56,7 +56,7 @@ public function testResetClearsCollectedData(): void
5656
self::assertNull($collector->getTotals()['hit_read_ratio']);
5757
}
5858

59-
public function testResetPreventsCallsLeakingIntoTheNextRequest(): void
59+
public function testResetPreventsCallsLeakingIntoTheNextRequest()
6060
{
6161
$pool = new TraceableCachePool(new ArrayCachePool(), 'cache.pool');
6262
$collector = new CacheDataCollector();
@@ -77,7 +77,7 @@ public function testResetPreventsCallsLeakingIntoTheNextRequest(): void
7777
self::assertSame('hasItem', $secondRequestCalls[0]->name);
7878
}
7979

80-
public function testCountsBulkDeletesWithoutInventingAReadRatio(): void
80+
public function testCountsBulkDeletesWithoutInventingAReadRatio()
8181
{
8282
$event = new TraceableAdapterEvent('deleteItems', ['one', 'two'], 1.0);
8383
$event->end = 2.0;

‎tests/Unit/DataCollector/TraceableCachePoolTest.php‎

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

1818
final class TraceableCachePoolTest extends TestCase
1919
{
20-
public function testFactoryKeepsNonTaggablePoolsNonTaggable(): void
20+
public function testFactoryKeepsNonTaggablePoolsNonTaggable()
2121
{
2222
$pool = TraceableCachePool::create($this->createMock(CacheItemPoolInterface::class), 'cache.pool');
2323

2424
self::assertSame(TraceableCachePool::class, $pool::class);
2525
}
2626

27-
public function testRecordsPoolOperationsAndHitCounts(): void
27+
public function testRecordsPoolOperationsAndHitCounts()
2828
{
2929
$pool = new TraceableCachePool(new ArrayCachePool(), 'cache.pool');
3030
$item = $pool->getItem('key')->set('value');
@@ -43,7 +43,7 @@ public function testRecordsPoolOperationsAndHitCounts(): void
4343
self::assertSame('cache.pool', $pool->getName());
4444
}
4545

46-
public function testDelegatesDeferredAndBulkOperations(): void
46+
public function testDelegatesDeferredAndBulkOperations()
4747
{
4848
$pool = new TraceableCachePool(new ArrayCachePool(), 'cache.pool');
4949
$item = $pool->getItem('one')->set('value');
@@ -58,7 +58,7 @@ public function testDelegatesDeferredAndBulkOperations(): void
5858
);
5959
}
6060

61-
public function testGetItemsPreservesNumericStringKeys(): void
61+
public function testGetItemsPreservesNumericStringKeys()
6262
{
6363
$pool = new TraceableCachePool(new ArrayCachePool(), 'cache.pool');
6464

@@ -71,7 +71,7 @@ public function testGetItemsPreservesNumericStringKeys(): void
7171
self::assertSame(['123'], $keys);
7272
}
7373

74-
public function testRecordsPublicKeysFromNamespacedPools(): void
74+
public function testRecordsPublicKeysFromNamespacedPools()
7575
{
7676
$pool = new TraceableCachePool(
7777
new NamespacedCachePool(new ArrayCachePool(), 'namespace'),
@@ -91,7 +91,7 @@ public function testRecordsPublicKeysFromNamespacedPools(): void
9191
* @param \Closure(TraceableCachePool, CacheItemInterface): mixed $operation
9292
*/
9393
#[DataProvider('failingOperations')]
94-
public function testFinalizesTheTraceAndRethrowsPoolExceptions(string $method, \Closure $operation): void
94+
public function testFinalizesTheTraceAndRethrowsPoolExceptions(string $method, \Closure $operation)
9595
{
9696
$inner = $this->createMock(CacheItemPoolInterface::class);
9797
$exception = new \RuntimeException('pool failed');
@@ -117,7 +117,7 @@ public function testFinalizesTheTraceAndRethrowsPoolExceptions(string $method, \
117117
self::assertSame(1, $collector->getTotals()['calls']);
118118
}
119119

120-
public function testTracesTagInvalidationOperations(): void
120+
public function testTracesTagInvalidationOperations()
121121
{
122122
$inner = new ArrayCachePool();
123123
$pool = TraceableCachePool::create($inner, 'cache.pool');
@@ -131,7 +131,7 @@ public function testTracesTagInvalidationOperations(): void
131131
self::assertSame([true, true], array_column($calls, 'result'));
132132
}
133133

134-
public function testTaggableTraceReturnsAndRecordsTaggableItems(): void
134+
public function testTaggableTraceReturnsAndRecordsTaggableItems()
135135
{
136136
$pool = TraceableCachePool::create(new ArrayCachePool(), 'cache.pool');
137137
self::assertInstanceOf(TaggableCacheItemPoolInterface::class, $pool);
@@ -147,7 +147,7 @@ public function testTaggableTraceReturnsAndRecordsTaggableItems(): void
147147
self::assertSame(['getItem', 'getItems'], array_column($pool->getCalls(), 'name'));
148148
}
149149

150-
public function testTaggableTraceRejectsNonTaggableBulkItems(): void
150+
public function testTaggableTraceRejectsNonTaggableBulkItems()
151151
{
152152
$inner = $this->createMock(TaggableCacheItemPoolInterface::class);
153153
$inner->method('getItems')->willReturn([$this->createMock(CacheItemInterface::class)]);

‎tests/Unit/DependencyInjection/CacheExtensionTest.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
final class CacheExtensionTest extends TestCase
1313
{
14-
public function testUsesCacheAlias(): void
14+
public function testUsesCacheAlias()
1515
{
1616
self::assertSame('cache', (new CacheExtension())->getAlias());
1717
}
1818

19-
public function testRegistersRetainedIntegrations(): void
19+
public function testRegistersRetainedIntegrations()
2020
{
2121
$container = $this->createContainer(false);
2222

@@ -48,7 +48,7 @@ public function testRegistersRetainedIntegrations(): void
4848
self::assertFalse($container->hasDefinition('cache.data_collector'));
4949
}
5050

51-
public function testDebugModeEnablesTheDataCollectorByDefault(): void
51+
public function testDebugModeEnablesTheDataCollectorByDefault()
5252
{
5353
$container = $this->createContainer(true);
5454

@@ -61,7 +61,7 @@ public function testDebugModeEnablesTheDataCollectorByDefault(): void
6161
]], $definition->getTag('data_collector'));
6262
}
6363

64-
public function testDataCollectorCanBeDisabledInDebugMode(): void
64+
public function testDataCollectorCanBeDisabledInDebugMode()
6565
{
6666
$container = $this->createContainer(true);
6767

0 commit comments

Comments
 (0)