File tree 6 files changed +63
-8
lines changed
6 files changed +63
-8
lines changed Original file line number Diff line number Diff line change 7
7
jobs :
8
8
PHPUnit :
9
9
name : PHPUnit (PHP ${{ matrix.php }})
10
- runs-on : ubuntu-22 .04
10
+ runs-on : ubuntu-24 .04
11
11
strategy :
12
12
matrix :
13
13
php :
14
+ - 8.4
14
15
- 8.3
15
16
- 8.2
16
17
- 8.1
39
40
40
41
PHPUnit-hhvm :
41
42
name : PHPUnit (HHVM)
42
- runs-on : ubuntu-22 .04
43
+ runs-on : ubuntu-24 .04
43
44
continue-on-error : true
44
45
services :
45
46
redis :
Original file line number Diff line number Diff line change 12
12
],
13
13
"require" : {
14
14
"php" : " >=5.3" ,
15
- "clue/redis-protocol" : " 0.3.* " ,
15
+ "clue/redis-protocol" : " ^ 0.3.2 " ,
16
16
"evenement/evenement" : " ^3.0 || ^2.0 || ^1.0" ,
17
17
"react/event-loop" : " ^1.2" ,
18
- "react/promise" : " ^3 || ^2.0 || ^1.1" ,
19
- "react/promise-timer" : " ^1.9 " ,
20
- "react/socket" : " ^1.12 "
18
+ "react/promise" : " ^3.2 || ^2.0 || ^1.1" ,
19
+ "react/promise-timer" : " ^1.11 " ,
20
+ "react/socket" : " ^1.16 "
21
21
},
22
22
"require-dev" : {
23
23
"clue/block-react" : " ^1.5" ,
Original file line number Diff line number Diff line change @@ -27,8 +27,18 @@ class Factory
27
27
* @param ?ConnectorInterface $connector
28
28
* @param ?ProtocolFactory $protocol
29
29
*/
30
- public function __construct (LoopInterface $ loop = null , ConnectorInterface $ connector = null , ProtocolFactory $ protocol = null )
30
+ public function __construct ($ loop = null , $ connector = null , $ protocol = null )
31
31
{
32
+ if ($ loop !== null && !$ loop instanceof LoopInterface) { // manual type check to support legacy PHP < 7.1
33
+ throw new \InvalidArgumentException ('Argument #1 ($loop) expected null|React\EventLoop\LoopInterface ' );
34
+ }
35
+ if ($ connector !== null && !$ connector instanceof ConnectorInterface) { // manual type check to support legacy PHP < 7.1
36
+ throw new \InvalidArgumentException ('Argument #2 ($connector) expected null|React\Socket\ConnectorInterface ' );
37
+ }
38
+ if ($ protocol !== null && !$ protocol instanceof LoopInterface) { // manual type check to support legacy PHP < 7.1
39
+ throw new \InvalidArgumentException ('Argument #3 ($protocol) expected null|Clue\Redis\Protocol\Factory ' );
40
+ }
41
+
32
42
$ this ->loop = $ loop ?: Loop::get ();
33
43
$ this ->connector = $ connector ?: new Connector (array (), $ this ->loop );
34
44
$ this ->protocol = $ protocol ?: new ProtocolFactory ();
Original file line number Diff line number Diff line change @@ -28,8 +28,17 @@ class StreamingClient extends EventEmitter implements Client
28
28
private $ subscribed = 0 ;
29
29
private $ psubscribed = 0 ;
30
30
31
- public function __construct (DuplexStreamInterface $ stream , ParserInterface $ parser = null , SerializerInterface $ serializer = null )
31
+ /**
32
+ * @param DuplexStreamInterface $stream
33
+ * @param ?ParserInterface $parser
34
+ * @param ?SerializerInterface $serializer
35
+ */
36
+ public function __construct (DuplexStreamInterface $ stream , $ parser = null , $ serializer = null )
32
37
{
38
+ // manual type checks to support legacy PHP < 7.1
39
+ assert ($ parser === null || $ parser instanceof ParserInterface);
40
+ assert ($ serializer === null || $ serializer instanceof SerializerInterface);
41
+
33
42
if ($ parser === null || $ serializer === null ) {
34
43
$ factory = new ProtocolFactory ();
35
44
if ($ parser === null ) {
Original file line number Diff line number Diff line change @@ -32,6 +32,24 @@ public function testConstructWithoutLoopAssignsLoopAutomatically()
32
32
$ this ->assertInstanceOf ('React\EventLoop\LoopInterface ' , $ loop );
33
33
}
34
34
35
+ public function testContructorThrowsExceptionForInvalidLoop ()
36
+ {
37
+ $ this ->setExpectedException ('InvalidArgumentException ' , 'Argument #1 ($loop) expected null|React\EventLoop\LoopInterface ' );
38
+ new Factory ('loop ' );
39
+ }
40
+
41
+ public function testContructorThrowsExceptionForInvalidConnector ()
42
+ {
43
+ $ this ->setExpectedException ('InvalidArgumentException ' , 'Argument #2 ($connector) expected null|React\Socket\ConnectorInterface ' );
44
+ new Factory (null , 'connector ' );
45
+ }
46
+
47
+ public function testContructorThrowsExceptionForInvalidProtocolFactory ()
48
+ {
49
+ $ this ->setExpectedException ('InvalidArgumentException ' , 'Argument #3 ($protocol) expected null|Clue\Redis\Protocol\Factory ' );
50
+ new Factory (null , null , 'protocol ' );
51
+ }
52
+
35
53
public function testWillConnectWithDefaultPort ()
36
54
{
37
55
$ this ->connector ->expects ($ this ->never ())->method ('connect ' );
Original file line number Diff line number Diff line change @@ -69,4 +69,21 @@ protected function expectPromiseReject($promise)
69
69
70
70
return $ promise ;
71
71
}
72
+
73
+ public function setExpectedException ($ exception , $ exceptionMessage = '' , $ exceptionCode = null )
74
+ {
75
+ if (method_exists ($ this , 'expectException ' )) {
76
+ // PHPUnit 5.2+
77
+ $ this ->expectException ($ exception );
78
+ if ($ exceptionMessage !== '' ) {
79
+ $ this ->expectExceptionMessage ($ exceptionMessage );
80
+ }
81
+ if ($ exceptionCode !== null ) {
82
+ $ this ->expectExceptionCode ($ exceptionCode );
83
+ }
84
+ } else {
85
+ // legacy PHPUnit
86
+ parent ::setExpectedException ($ exception , $ exceptionMessage , $ exceptionCode );
87
+ }
88
+ }
72
89
}
You can’t perform that action at this time.
0 commit comments