@@ -112,8 +112,14 @@ class Process extends EventEmitter
112
112
* @param null|array $fds File descriptors to allocate for this process (or null = default STDIO streams)
113
113
* @throws \LogicException On windows or when proc_open() is not installed
114
114
*/
115
- public function __construct ($ cmd , $ cwd = null , array $ env = null , array $ fds = null )
115
+ public function __construct ($ cmd , $ cwd = null , $ env = null , $ fds = null )
116
116
{
117
+ if ($ env !== null && !\is_array ($ env )) { // manual type check to support legacy PHP < 7.1
118
+ throw new \InvalidArgumentException ('Argument #3 ($env) expected null|array ' );
119
+ }
120
+ if ($ fds !== null && !\is_array ($ fds )) { // manual type check to support legacy PHP < 7.1
121
+ throw new \InvalidArgumentException ('Argument #4 ($fds) expected null|array ' );
122
+ }
117
123
if (!\function_exists ('proc_open ' )) {
118
124
throw new \LogicException ('The Process class relies on proc_open(), which is not available on your PHP installation. ' );
119
125
}
@@ -164,8 +170,11 @@ public function __construct($cmd, $cwd = null, array $env = null, array $fds = n
164
170
* @param float $interval Interval to periodically monitor process state (seconds)
165
171
* @throws \RuntimeException If the process is already running or fails to start
166
172
*/
167
- public function start (LoopInterface $ loop = null , $ interval = 0.1 )
173
+ public function start ($ loop = null , $ interval = 0.1 )
168
174
{
175
+ if ($ loop !== null && !$ loop instanceof LoopInterface) { // manual type check to support legacy PHP < 7.1
176
+ throw new \InvalidArgumentException ('Argument #1 ($loop) expected null|React\EventLoop\LoopInterface ' );
177
+ }
169
178
if ($ this ->isRunning ()) {
170
179
throw new \RuntimeException ('Process is already running ' );
171
180
}
0 commit comments