File tree Expand file tree Collapse file tree 4 files changed +23
-3
lines changed Expand file tree Collapse file tree 4 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 1414 "php" : " >=5.4" ,
1515 "ext-sqlite3" : " *" ,
1616 "clue/ndjson-react" : " ^1.0" ,
17- "react/child-process" : " ^0.6" ,
17+ "react/child-process" : " ^0.6.6 " ,
1818 "react/event-loop" : " ^1.2" ,
19- "react/promise" : " ^3 || ^2.7 || ^1.2.1"
19+ "react/promise" : " ^3.2 || ^2.7 || ^1.2.1"
2020 },
2121 "require-dev" : {
2222 "phpunit/phpunit" : " ^9.6 || ^5.7 || ^4.8.36"
Original file line number Diff line number Diff line change @@ -62,8 +62,12 @@ class Factory
6262 * @param ?LoopInterface $loop
6363 * @param ?string $binary
6464 */
65- public function __construct (LoopInterface $ loop = null , $ binary = null )
65+ public function __construct ($ loop = null , $ binary = null )
6666 {
67+ if ($ loop !== null && !$ loop instanceof LoopInterface) { // manual type check to support legacy PHP < 7.1
68+ throw new \InvalidArgumentException ('Argument #1 ($loop) expected null|React\EventLoop\LoopInterface ' );
69+ }
70+
6771 $ this ->loop = $ loop ?: Loop::get ();
6872 $ this ->bin = $ binary === null ? $ this ->php () : $ binary ;
6973
Original file line number Diff line number Diff line change @@ -32,6 +32,20 @@ public function testConstructWitLoopAndBinaryAssignsBothVariables()
3232 $ this ->assertSame ('php6.0 ' , $ ref ->getValue ($ factory ));
3333 }
3434
35+ public function testCtorThrowsForInvalidLoop ()
36+ {
37+ if (method_exists ($ this , 'expectException ' )) {
38+ // PHPUnit 5.2+
39+ $ this ->expectException ('InvalidArgumentException ' );
40+ $ this ->expectExceptionMessage ('Argument #1 ($loop) expected null|React\EventLoop\LoopInterface ' );
41+ } else {
42+ // legacy PHPUnit
43+ $ this ->setExpectedException ('InvalidArgumentException ' , 'Argument #1 ($loop) expected null|React\EventLoop\LoopInterface ' );
44+ }
45+
46+ new Factory ('loop ' );
47+ }
48+
3549 public function testLoadLazyReturnsDatabaseImmediately ()
3650 {
3751 $ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
Original file line number Diff line number Diff line change @@ -9,8 +9,10 @@ class BlockingDatabaseTest extends TestCase
99 public function testCtorThrowsForInvalidPath ()
1010 {
1111 if (method_exists ($ this , 'expectException ' )) {
12+ // PHPUnit 5.2+
1213 $ this ->expectException ('Exception ' );
1314 } else {
15+ // legacy PHPUnit
1416 $ this ->setExpectedException ('Exception ' );
1517 }
1618 new BlockingDatabase ('/dev/foobar ' );
You can’t perform that action at this time.
0 commit comments