File tree Expand file tree Collapse file tree 6 files changed +37
-7
lines changed
Expand file tree Collapse file tree 6 files changed +37
-7
lines changed Original file line number Diff line number Diff line change 77jobs :
88 PHPUnit :
99 name : PHPUnit (PHP ${{ matrix.php }})
10- runs-on : ubuntu-22 .04
10+ runs-on : ubuntu-24 .04
1111 strategy :
1212 matrix :
1313 php :
14+ - 8.4
1415 - 8.3
1516 - 8.2
1617 - 8.1
3536
3637 PHPUnit-hhvm :
3738 name : PHPUnit (HHVM)
38- runs-on : ubuntu-22 .04
39+ runs-on : ubuntu-24 .04
3940 continue-on-error : true
4041 steps :
4142 - uses : actions/checkout@v4
Original file line number Diff line number Diff line change 1212 ],
1313 "require" : {
1414 "php" : " >=5.3" ,
15- "react/promise" : " ^3 || ^2.1 || ^1.2" ,
16- "react/socket" : " ^1.12 "
15+ "react/promise" : " ^3.2 || ^2.1 || ^1.2" ,
16+ "react/socket" : " ^1.16 "
1717 },
1818 "require-dev" : {
1919 "clue/block-react" : " ^1.5" ,
Original file line number Diff line number Diff line change @@ -34,8 +34,12 @@ final class Client implements ConnectorInterface
3434 public function __construct (
3535 #[\SensitiveParameter]
3636 $ socksUri ,
37- ConnectorInterface $ connector = null
37+ $ connector = null
3838 ) {
39+ if ($ connector !== null && !$ connector instanceof ConnectorInterface) { // manual type check to support legacy PHP < 7.1
40+ throw new InvalidArgumentException ('Argument #2 ($connector) expected null|React\Socket\ConnectorInterface ' );
41+ }
42+
3943 // support `sockss://` scheme for SOCKS over TLS
4044 // support `socks+unix://` scheme for Unix domain socket (UDS) paths
4145 if (preg_match ('/^(socks(?:5|4)?)(s|\+unix):\/\/(.*?@)?(.+?)$/ ' , $ socksUri , $ match )) {
Original file line number Diff line number Diff line change @@ -58,11 +58,18 @@ final class Server
5858 * @param null|array|callable $auth
5959 */
6060 public function __construct (
61- LoopInterface $ loop = null ,
62- ConnectorInterface $ connector = null ,
61+ $ loop = null ,
62+ $ connector = null ,
6363 #[\SensitiveParameter]
6464 $ auth = null
6565 ) {
66+ if ($ loop !== null && !$ loop instanceof LoopInterface) { // manual type check to support legacy PHP < 7.1
67+ throw new \InvalidArgumentException ('Argument #1 ($loop) expected null|React\EventLoop\LoopInterface ' );
68+ }
69+ if ($ connector !== null && !$ connector instanceof ConnectorInterface) { // manual type check to support legacy PHP < 7.1
70+ throw new \InvalidArgumentException ('Argument #2 ($connector) expected null|React\Socket\ConnectorInterface ' );
71+ }
72+
6673 if (\is_array ($ auth )) {
6774 // wrap authentication array in authentication callback
6875 $ this ->auth = function (
Original file line number Diff line number Diff line change @@ -83,6 +83,12 @@ public function testCtorAcceptsUriWithSocks5UnixScheme()
8383 $ this ->assertTrue (true );
8484 }
8585
86+ public function testCtorThrowsForInvalidConnector ()
87+ {
88+ $ this ->setExpectedException ('InvalidArgumentException ' , 'Argument #2 ($connector) expected null|React\Socket\ConnectorInterface ' );
89+ new Client ('127.0.0.1:1080 ' , 'connector ' );
90+ }
91+
8692 public function testCtorThrowsForInvalidUri ()
8793 {
8894 $ this ->setExpectedException ("InvalidArgumentException " );
Original file line number Diff line number Diff line change @@ -68,6 +68,18 @@ public function testConstructorWithStaticAuthArray()
6868 ));
6969 }
7070
71+ public function testConstructorThrowsForInvalidLoop ()
72+ {
73+ $ this ->setExpectedException ('InvalidArgumentException ' , 'Argument #1 ($loop) expected null|React\EventLoop\LoopInterface ' );
74+ new Server ('loop ' );
75+ }
76+
77+ public function testConstructorThrowsForInvalidConnector ()
78+ {
79+ $ this ->setExpectedException ('InvalidArgumentException ' , 'Argument #2 ($connector) expected null|React\Socket\ConnectorInterface ' );
80+ new Server (null , 'connector ' );
81+ }
82+
7183 public function testConstructorWithInvalidAuthenticatorThrows ()
7284 {
7385 $ this ->setExpectedException ("InvalidArgumentException " );
You can’t perform that action at this time.
0 commit comments