@@ -103,8 +103,14 @@ class Process extends EventEmitter
103
103
* @param null|array $fds File descriptors to allocate for this process (or null = default STDIO streams)
104
104
* @throws \LogicException On windows or when proc_open() is not installed
105
105
*/
106
- public function __construct ($ cmd , $ cwd = null , array $ env = null , array $ fds = null )
106
+ public function __construct ($ cmd , $ cwd = null , $ env = null , $ fds = null )
107
107
{
108
+ if ($ env !== null && !\is_array ($ env )) { // manual type check to support legacy PHP < 7.1
109
+ throw new \InvalidArgumentException ('Argument #3 ($env) expected null|array ' );
110
+ }
111
+ if ($ fds !== null && !\is_array ($ fds )) { // manual type check to support legacy PHP < 7.1
112
+ throw new \InvalidArgumentException ('Argument #4 ($fds) expected null|array ' );
113
+ }
108
114
if (!\function_exists ('proc_open ' )) {
109
115
throw new \LogicException ('The Process class relies on proc_open(), which is not available on your PHP installation. ' );
110
116
}
@@ -154,8 +160,11 @@ public function __construct($cmd, $cwd = null, array $env = null, array $fds = n
154
160
* @param float $interval Interval to periodically monitor process state (seconds)
155
161
* @throws \RuntimeException If the process is already running or fails to start
156
162
*/
157
- public function start (LoopInterface $ loop = null , $ interval = 0.1 )
163
+ public function start ($ loop = null , $ interval = 0.1 )
158
164
{
165
+ if ($ loop !== null && !$ loop instanceof LoopInterface) { // manual type check to support legacy PHP < 7.1
166
+ throw new \InvalidArgumentException ('Argument #1 ($loop) expected null|React\EventLoop\LoopInterface ' );
167
+ }
159
168
if ($ this ->isRunning ()) {
160
169
throw new \RuntimeException ('Process is already running ' );
161
170
}
0 commit comments