20
20
use function str_replace ;
21
21
use function str_starts_with ;
22
22
use PHPUnit \Runner \DirectoryDoesNotExistException ;
23
+ use PHPUnit \TextUI \CannotOpenSocketException ;
23
24
use PHPUnit \TextUI \InvalidSocketException ;
24
25
use PHPUnit \Util \Filesystem ;
25
26
@@ -36,6 +37,7 @@ final class DefaultPrinter implements Printer
36
37
private bool $ isOpen ;
37
38
38
39
/**
40
+ * @throws CannotOpenSocketException
39
41
* @throws DirectoryDoesNotExistException
40
42
* @throws InvalidSocketException
41
43
*/
@@ -45,6 +47,7 @@ public static function from(string $out): self
45
47
}
46
48
47
49
/**
50
+ * @throws CannotOpenSocketException
48
51
* @throws DirectoryDoesNotExistException
49
52
* @throws InvalidSocketException
50
53
*/
@@ -54,6 +57,7 @@ public static function standardOutput(): self
54
57
}
55
58
56
59
/**
60
+ * @throws CannotOpenSocketException
57
61
* @throws DirectoryDoesNotExistException
58
62
* @throws InvalidSocketException
59
63
*/
@@ -63,6 +67,7 @@ public static function standardError(): self
63
67
}
64
68
65
69
/**
70
+ * @throws CannotOpenSocketException
66
71
* @throws DirectoryDoesNotExistException
67
72
* @throws InvalidSocketException
68
73
*/
@@ -77,7 +82,13 @@ private function __construct(string $out)
77
82
throw new InvalidSocketException ($ out );
78
83
}
79
84
80
- $ this ->stream = fsockopen ($ tmp [0 ], (int ) $ tmp [1 ]);
85
+ $ stream = @fsockopen ($ tmp [0 ], (int ) $ tmp [1 ]);
86
+
87
+ if ($ stream === false ) {
88
+ throw new CannotOpenSocketException ($ tmp [0 ], (int ) $ tmp [1 ]);
89
+ }
90
+
91
+ $ this ->stream = $ stream ;
81
92
$ this ->isOpen = true ;
82
93
83
94
return ;
0 commit comments