Skip to content

Commit 410f891

Browse files
committed
Apply Psalm return types
1 parent 4e4d63d commit 410f891

File tree

6 files changed

+29
-23
lines changed

6 files changed

+29
-23
lines changed

src/Commands/HandlersCache.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class HandlersCache extends BaseCommand
1414
protected $description = 'Discovers and caches all handlers';
1515
protected $usage = 'handlers:cache';
1616

17+
/**
18+
* @return void
19+
*/
1720
public function run(array $params = [])
1821
{
1922
// Make sure caching is enabled

src/Commands/HandlersClear.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ class HandlersClear extends BaseCommand
1212
protected $description = 'Clears cached versions of discovered handlers';
1313
protected $usage = 'handlers:clear';
1414

15+
/**
16+
* @return void
17+
*/
1518
public function run(array $params = [])
1619
{
1720
$count = cache()->deleteMatching('handlers-*');

tests/BaseFactoryTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
final class BaseFactoryTest extends TestCase
1212
{
13-
public function testNoDiscoveryReturnsEmptyArray()
13+
public function testNoDiscoveryReturnsEmptyArray(): void
1414
{
1515
$factory = new class () extends BaseFactory {
1616
public const HANDLER_PATH = 'Bananas';
@@ -19,7 +19,7 @@ public function testNoDiscoveryReturnsEmptyArray()
1919
$this->assertSame([], $factory::findAll());
2020
}
2121

22-
public function testGetHandlerClassReturnsClass()
22+
public function testGetHandlerClassReturnsClass(): void
2323
{
2424
$expected = 'Tests\Support\Cars\WidgetCar';
2525

@@ -29,36 +29,36 @@ public function testGetHandlerClassReturnsClass()
2929
$this->assertSame($expected, $result);
3030
}
3131

32-
public function testGetHandlerClassRequiresPhpExtension()
32+
public function testGetHandlerClassRequiresPhpExtension(): void
3333
{
3434
$result = CarFactory::getHandlerClass('foo', 'bar');
3535

3636
$this->assertNull($result);
3737
}
3838

39-
public function testGetHandlerClassRequiresInterfaces()
39+
public function testGetHandlerClassRequiresInterfaces(): void
4040
{
4141
$result = CarFactory::getHandlerClass(SUPPORTPATH . 'Cars/NotCar.php', 'Tests\Support');
4242

4343
$this->assertNull($result);
4444
}
4545

46-
public function testGetHandlerClassRequiresHandlerInterface()
46+
public function testGetHandlerClassRequiresHandlerInterface(): void
4747
{
4848
$result = CarFactory::getHandlerClass(SUPPORTPATH . 'Cars/BadCar.php', 'Tests\Support');
4949

5050
$this->assertNull($result);
5151
}
5252

53-
public function testGetHandlerClassFails()
53+
public function testGetHandlerClassFails(): void
5454
{
5555
$file = realpath(SUPPORTPATH . 'Cars/WidgetCar.php');
5656
$result = CarFactory::getHandlerClass($file, 'Foo\Bar');
5757

5858
$this->assertNull($result);
5959
}
6060

61-
public function testIgnoresClass()
61+
public function testIgnoresClass(): void
6262
{
6363
config('Handlers')->ignoredClasses[] = 'Tests\Support\Cars\PopCar';
6464

@@ -68,7 +68,7 @@ public function testIgnoresClass()
6868
$this->assertSame($expected, $result);
6969
}
7070

71-
public function testCollision()
71+
public function testCollision(): void
7272
{
7373
// Stop ignoring the collision clas
7474
config('Handlers')->ignoredClasses = [];
@@ -79,7 +79,7 @@ public function testCollision()
7979
CarFactory::findAll();
8080
}
8181

82-
public function testFindAll()
82+
public function testFindAll(): void
8383
{
8484
$expected = [
8585
'pop' => 'Tests\Support\Cars\PopCar',
@@ -91,7 +91,7 @@ public function testFindAll()
9191
$this->assertSame($expected, $result);
9292
}
9393

94-
public function testFind()
94+
public function testFind(): void
9595
{
9696
$expected = 'Tests\Support\Cars\PopCar';
9797

@@ -100,15 +100,15 @@ public function testFind()
100100
$this->assertSame($expected, $result);
101101
}
102102

103-
public function testFindThrows()
103+
public function testFindThrows(): void
104104
{
105105
$this->expectException('RuntimeException');
106106
$this->expectExceptionMessage('Unknown handler "banana" for ' . CarFactory::class);
107107

108108
CarFactory::find('banana');
109109
}
110110

111-
public function testResetSingle()
111+
public function testResetSingle(): void
112112
{
113113
CarFactory::findAll();
114114
FactoryFactory::findAll();
@@ -121,7 +121,7 @@ public function testResetSingle()
121121
$this->assertSame(['Factories'], array_keys($result));
122122
}
123123

124-
public function testResetAll()
124+
public function testResetAll(): void
125125
{
126126
CarFactory::findAll();
127127
FactoryFactory::findAll();

tests/CacheTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ protected function tearDown(): void
1515
CarFactory::clearCache();
1616
}
1717

18-
public function testDiscoveryUsesCache()
18+
public function testDiscoveryUsesCache(): void
1919
{
2020
// Reenable caching
2121
config('Handlers')->cacheDuration = MINUTE;
@@ -28,7 +28,7 @@ public function testDiscoveryUsesCache()
2828
$this->assertSame($expected, $result); // @phpstan-ignore-line
2929
}
3030

31-
public function testDiscoveryCreatesCache()
31+
public function testDiscoveryCreatesCache(): void
3232
{
3333
// Reenable caching
3434
config('Handlers')->cacheDuration = MINUTE;
@@ -41,7 +41,7 @@ public function testDiscoveryCreatesCache()
4141
$this->assertSame('Tests\Support\Cars\PopCar', $result['pop']);
4242
}
4343

44-
public function testDiscoveryIgnoresCache()
44+
public function testDiscoveryIgnoresCache(): void
4545
{
4646
$expected = [
4747
'pop' => 'Tests\Support\Cars\PopCar',

tests/CommandsTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ protected function tearDown(): void
3434
stream_filter_remove($this->streamFilter);
3535
}
3636

37-
protected function getBuffer()
37+
protected function getBuffer(): string
3838
{
3939
return CITestStreamFilter::$buffer;
4040
}
4141

42-
public function testCacheFailsCachingDisabled()
42+
public function testCacheFailsCachingDisabled(): void
4343
{
4444
config('Handlers')->cacheDuration = null;
4545

@@ -48,7 +48,7 @@ public function testCacheFailsCachingDisabled()
4848
$this->assertStringContainsString('Handler caching is disabled by the Tatter\Handlers Config file', $this->getBuffer());
4949
}
5050

51-
public function testCacheCreatesCache()
51+
public function testCacheCreatesCache(): void
5252
{
5353
command('handlers:cache');
5454

@@ -61,7 +61,7 @@ public function testCacheCreatesCache()
6161
$this->assertSame('Tests\Support\Cars\PopCar', $result['pop']);
6262
}
6363

64-
public function testCacheReportsErrors()
64+
public function testCacheReportsErrors(): void
6565
{
6666
// Stop ignoring the ErrorFactory
6767
unset(config('Handlers')->ignoredClasses[1]);
@@ -76,7 +76,7 @@ public function testCacheReportsErrors()
7676
$this->assertSame(ErrorFactory::class, $result['error']);
7777
}
7878

79-
public function testCacheErrorsNoHandlers()
79+
public function testCacheErrorsNoHandlers(): void
8080
{
8181
// Ignore all Factories
8282
config('Handlers')->ignoredClasses = [
@@ -90,7 +90,7 @@ public function testCacheErrorsNoHandlers()
9090
$this->assertStringContainsString('No factories discovered!', $this->getBuffer());
9191
}
9292

93-
public function testClearRemovesCache()
93+
public function testClearRemovesCache(): void
9494
{
9595
command('handlers:cache');
9696
$this->assertNotNull(cache()->get('handlers-factories'));

tests/FactoryFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
final class FactoryFactoryTest extends TestCase
1111
{
12-
public function testDiscovers()
12+
public function testDiscovers(): void
1313
{
1414
// Discovery is alphabetical by ID
1515
$expected = [

0 commit comments

Comments
 (0)