@@ -103,8 +103,14 @@ class Process extends EventEmitter
103103 * @param null|array $fds File descriptors to allocate for this process (or null = default STDIO streams)
104104 * @throws \LogicException On windows or when proc_open() is not installed
105105 */
106- public function __construct ($ cmd , $ cwd = null , array $ env = null , array $ fds = null )
106+ public function __construct ($ cmd , $ cwd = null , $ env = null , $ fds = null )
107107 {
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+ }
108114 if (!\function_exists ('proc_open ' )) {
109115 throw new \LogicException ('The Process class relies on proc_open(), which is not available on your PHP installation. ' );
110116 }
@@ -154,8 +160,11 @@ public function __construct($cmd, $cwd = null, array $env = null, array $fds = n
154160 * @param float $interval Interval to periodically monitor process state (seconds)
155161 * @throws \RuntimeException If the process is already running or fails to start
156162 */
157- public function start (LoopInterface $ loop = null , $ interval = 0.1 )
163+ public function start ($ loop = null , $ interval = 0.1 )
158164 {
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+ }
159168 if ($ this ->isRunning ()) {
160169 throw new \RuntimeException ('Process is already running ' );
161170 }
0 commit comments