Skip to content

Commit f6cff85

Browse files
committed
Fix (almost) all PHPStan errors
1 parent e710737 commit f6cff85

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

phpstan.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
parameters:
2+
ignoreErrors:
3+
- '#Default value of the parameter \#3 $timeout \(60\) of method WyriHaximus\AsyncTestUtilities\AsyncTestCase::await\(\) is incompatible with type float\|null.#'
4+
- '#Method [a-zA-Z0-9\\_]+::[a-zA-Z0-9_]+\(\) has parameter \$[a-zA-Z0-9_]+ with a nullable type declaration.#'
5+
- '#Method [a-zA-Z0-9\\_]+::[a-zA-Z0-9_]+\(\) has parameter \$[a-zA-Z0-9_]+ with null as default value.#'
26
classesAllowedToBeExtended:
37
- WyriHaximus\AsyncTestUtilities\AsyncTestCase
48

src/AsyncTestCase.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ abstract class AsyncTestCase extends TestCase
1717
/**
1818
* @param PromiseInterface $promise
1919
* @param LoopInterface|null $loop
20+
* @param float|null $timeout
2021
* @return mixed
2122
*/
22-
protected function await(PromiseInterface $promise, LoopInterface $loop = null, float $timeout = self::DEFAULT_AWAIT_TIMEOUT)
23+
protected function await(PromiseInterface $promise, ?LoopInterface $loop = null, ?float $timeout = self::DEFAULT_AWAIT_TIMEOUT)
2324
{
2425
if (!($loop instanceof LoopInterface)) {
2526
$loop = Factory::create();
@@ -31,9 +32,10 @@ protected function await(PromiseInterface $promise, LoopInterface $loop = null,
3132
/**
3233
* @param array $promises
3334
* @param LoopInterface|null $loop
35+
* @param float|null $timeout
3436
* @return array
3537
*/
36-
protected function awaitAll(array $promises, LoopInterface $loop = null, float $timeout = self::DEFAULT_AWAIT_TIMEOUT)
38+
protected function awaitAll(array $promises, ?LoopInterface $loop = null, ?float $timeout = self::DEFAULT_AWAIT_TIMEOUT): array
3739
{
3840
if (!($loop instanceof LoopInterface)) {
3941
$loop = Factory::create();
@@ -45,9 +47,10 @@ protected function awaitAll(array $promises, LoopInterface $loop = null, float $
4547
/**
4648
* @param array $promises
4749
* @param LoopInterface|null $loop
50+
* @param float|null $timeout
4851
* @return mixed
4952
*/
50-
protected function awaitAny(array $promises, LoopInterface $loop = null, float $timeout = self::DEFAULT_AWAIT_TIMEOUT)
53+
protected function awaitAny(array $promises, ?LoopInterface $loop = null, ?float $timeout = self::DEFAULT_AWAIT_TIMEOUT)
5154
{
5255
if (!($loop instanceof LoopInterface)) {
5356
$loop = Factory::create();

tests/AsyncTestCaseTest.php

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

1313
final class AsyncTestCaseTest extends AsyncTestCase
1414
{
15-
protected function setUp(): void
16-
{
17-
parent::setUp();
18-
}
19-
20-
protected function tearDown(): void
21-
{
22-
parent::tearDown();
23-
}
24-
25-
public function provideEventLoop()
15+
public function provideEventLoop(): iterable
2616
{
2717
yield [null];
2818
yield [Factory::create()];
@@ -32,7 +22,7 @@ public function provideEventLoop()
3222
/**
3323
* @dataProvider provideEventLoop
3424
*/
35-
public function testAwait(LoopInterface $loop = null)
25+
public function testAwait(?LoopInterface $loop): void
3626
{
3727
$value = time();
3828
static::assertSame($value, $this->await(resolve($value), $loop));
@@ -41,7 +31,7 @@ public function testAwait(LoopInterface $loop = null)
4131
/**
4232
* @dataProvider provideEventLoop
4333
*/
44-
public function testAwaitAll(LoopInterface $loop = null)
34+
public function testAwaitAll(?LoopInterface $loop): void
4535
{
4636
$value = time();
4737
static::assertSame([$value, $value], $this->awaitAll([resolve($value), resolve($value)], $loop));
@@ -50,7 +40,7 @@ public function testAwaitAll(LoopInterface $loop = null)
5040
/**
5141
* @dataProvider provideEventLoop
5242
*/
53-
public function testAwaitAny(LoopInterface $loop = null)
43+
public function testAwaitAny(?LoopInterface $loop): void
5444
{
5545
$value = time();
5646
static::assertSame($value, $this->awaitAny([resolve($value), resolve($value)], $loop));
@@ -59,7 +49,7 @@ public function testAwaitAny(LoopInterface $loop = null)
5949
/**
6050
* @dataProvider provideEventLoop
6151
*/
62-
public function testAwaitTimeout(LoopInterface $loop = null)
52+
public function testAwaitTimeout(?LoopInterface $loop): void
6353
{
6454
self::expectException(TimeoutException::class);
6555

0 commit comments

Comments
 (0)