File tree Expand file tree Collapse file tree 9 files changed +52
-5
lines changed
Expand file tree Collapse file tree 9 files changed +52
-5
lines changed Original file line number Diff line number Diff line change 22/.github /workflows / export-ignore
33/.gitignore export-ignore
44/examples / export-ignore
5+ /phpstan.neon.dist export-ignore
56/phpunit.xml.dist export-ignore
67/phpunit.xml.legacy export-ignore
78/tests / export-ignore
Original file line number Diff line number Diff line change 3737 <?php
3838 $metrics = simplexml_load_file('clover.xml')->project->metrics;
3939 exit((int) $metrics['statements'] === (int) $metrics['coveredstatements'] ? 0 : 1);
40+
41+ PHPStan :
42+ name : PHPStan (PHP ${{ matrix.php }})
43+ runs-on : ubuntu-22.04
44+ strategy :
45+ matrix :
46+ php :
47+ - 8.2
48+ - 8.1
49+ - 8.0
50+ - 7.4
51+ - 7.3
52+ - 7.2
53+ - 7.1
54+ steps :
55+ - uses : actions/checkout@v3
56+ - uses : shivammathur/setup-php@v2
57+ with :
58+ php-version : ${{ matrix.php }}
59+ coverage : none
60+ - run : composer install
61+ - run : vendor/bin/phpstan
Original file line number Diff line number Diff line change 2121 },
2222 "require-dev" : {
2323 "clue/block-react" : " ^1.5" ,
24+ "phpstan/phpstan" : " 1.8.11 || 1.4.10" ,
2425 "phpunit/phpunit" : " ^9.5 || ^7.5"
2526 },
2627 "autoload" : {
Original file line number Diff line number Diff line change 1+ parameters:
2+ level: 3
3+
4+ paths:
5+ - examples/
6+ - src/
7+ - tests/
8+
9+ reportUnmatchedIgnoredErrors: false
10+ ignoreErrors:
11+ # ignore generic usage like `PromiseInterface<T>` until fixed upstream
12+ - '/^PHPDoc tag @return contains generic type React\\Promise\\PromiseInterface<.+> but interface React\\Promise\\PromiseInterface is not generic\.$/'
13+ # ignore undefined methods due to magic `__call()` method
14+ - '/^Call to an undefined method Clue\\React\\Redis\\RedisClient::.+\(\)\.$/'
15+ - '/^Call to an undefined method Clue\\React\\Redis\\Io\\StreamingClient::.+\(\)\.$/'
Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ public function createClient(string $uri): PromiseInterface
9191 $ connecting ->then (function (ConnectionInterface $ connection ) {
9292 $ connection ->close ();
9393 });
94+ assert (\method_exists ($ connecting , 'cancel ' ));
9495 $ connecting ->cancel ();
9596 });
9697
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ class RedisClient extends EventEmitter
4646 /** @var float */
4747 private $ idlePeriod = 0.001 ;
4848
49- /** @var ?TimerInterface */
49+ /** @var ?\React\EventLoop\ TimerInterface */
5050 private $ idleTimer = null ;
5151
5252 /** @var int */
@@ -221,6 +221,7 @@ public function close(): void
221221 $ redis ->close ();
222222 });
223223 if ($ this ->promise !== null ) {
224+ assert (\method_exists ($ this ->promise , 'cancel ' ));
224225 $ this ->promise ->cancel ();
225226 $ this ->promise = null ;
226227 }
Original file line number Diff line number Diff line change @@ -106,6 +106,7 @@ public function testInvalidCommand()
106106 if (method_exists ($ this , 'expectException ' )) {
107107 $ this ->expectException ('Exception ' );
108108 } else {
109+ assert (method_exists ($ this , 'setExpectedException ' ));
109110 $ this ->setExpectedException ('Exception ' );
110111 }
111112 await ($ promise , $ this ->loop );
Original file line number Diff line number Diff line change @@ -444,6 +444,8 @@ public function testCancelWillRejectPromise()
444444 $ this ->connector ->expects ($ this ->once ())->method ('connect ' )->with ('127.0.0.1:2 ' )->willReturn ($ promise );
445445
446446 $ promise = $ this ->factory ->createClient ('redis://127.0.0.1:2 ' );
447+
448+ assert (method_exists ($ promise , 'cancel ' ));
447449 $ promise ->cancel ();
448450
449451 $ promise ->then (null , $ this ->expectCallableOnceWith ($ this ->isInstanceOf (\RuntimeException::class)));
@@ -526,6 +528,8 @@ public function testCancelWillRejectWithUriInMessageAndCancelConnectorWhenConnec
526528 $ this ->connector ->expects ($ this ->once ())->method ('connect ' )->willReturn ($ deferred ->promise ());
527529
528530 $ promise = $ this ->factory ->createClient ($ uri );
531+
532+ assert (method_exists ($ promise , 'cancel ' ));
529533 $ promise ->cancel ();
530534
531535 $ promise ->then (null , $ this ->expectCallableOnceWith (
@@ -550,6 +554,8 @@ public function testCancelWillCloseConnectionWhenConnectionWaitsForSelect()
550554 $ this ->connector ->expects ($ this ->once ())->method ('connect ' )->willReturn (resolve ($ stream ));
551555
552556 $ promise = $ this ->factory ->createClient ('redis://127.0.0.1:2/123 ' );
557+
558+ assert (method_exists ($ promise , 'cancel ' ));
553559 $ promise ->cancel ();
554560
555561 $ promise ->then (null , $ this ->expectCallableOnceWith (
Original file line number Diff line number Diff line change @@ -356,11 +356,10 @@ public function testCloseAfterPingRejectsWillEmitClose()
356356 $ this ->loop ->expects ($ this ->once ())->method ('addTimer ' )->willReturn ($ timer );
357357 $ this ->loop ->expects ($ this ->once ())->method ('cancelTimer ' )->with ($ timer );
358358
359- $ ref = $ this ->redis ;
360- $ ref ->ping ()->then (null , function () use ($ ref , $ client ) {
361- $ ref ->close ();
359+ $ this ->redis ->ping ()->then (null , function () {
360+ $ this ->redis ->close ();
362361 });
363- $ ref ->on ('close ' , $ this ->expectCallableOnce ());
362+ $ this -> redis ->on ('close ' , $ this ->expectCallableOnce ());
364363 $ deferred ->reject (new \RuntimeException ());
365364 }
366365
You can’t perform that action at this time.
0 commit comments