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 1111 strategy :
1212 matrix :
1313 php :
14+ - 8.4
1415 - 8.3
1516 - 8.2
1617 - 8.1
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/connection-manager-extra" : " ^1.3" ,
2020 "phpunit/phpunit" : " ^9.6 || ^8.5 || ^5.7 || ^4.8.36" ,
21- "react/async" : " ^4 || ^3 || ^2" ,
21+ "react/async" : " ^4.3 || ^3 || ^2" ,
2222 "react/event-loop" : " ^1.2" ,
23- "react/http" : " ^1.6 "
23+ "react/http" : " ^1.11 "
2424 },
2525 "autoload" : {
2626 "psr-4" : {
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 @@ -121,6 +121,12 @@ public function testInvalidProtocolVersion()
121121 $ this ->client = new Client ('socks3://127.0.0.1:9050 ' , $ this ->connector );
122122 }
123123
124+ public function testCtorThrowsForInvalidConnector ()
125+ {
126+ $ this ->setExpectedException ('InvalidArgumentException ' , 'Argument #2 ($connector) expected null|React\Socket\ConnectorInterface ' );
127+ new Client ('127.0.0.1:1080 ' , 'connector ' );
128+ }
129+
124130 public function testCreateWillConnectToProxy ()
125131 {
126132 $ promise = new Promise (function () { });
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