@@ -112,8 +112,14 @@ class Process extends EventEmitter
112112 * @param null|array $fds File descriptors to allocate for this process (or null = default STDIO streams)
113113 * @throws \LogicException On windows or when proc_open() is not installed
114114 */
115- public function __construct ($ cmd , $ cwd = null , array $ env = null , array $ fds = null )
115+ public function __construct ($ cmd , $ cwd = null , $ env = null , $ fds = null )
116116 {
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+ }
117123 if (!\function_exists ('proc_open ' )) {
118124 throw new \LogicException ('The Process class relies on proc_open(), which is not available on your PHP installation. ' );
119125 }
@@ -164,8 +170,11 @@ public function __construct($cmd, $cwd = null, array $env = null, array $fds = n
164170 * @param float $interval Interval to periodically monitor process state (seconds)
165171 * @throws \RuntimeException If the process is already running or fails to start
166172 */
167- public function start (LoopInterface $ loop = null , $ interval = 0.1 )
173+ public function start ($ loop = null , $ interval = 0.1 )
168174 {
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+ }
169178 if ($ this ->isRunning ()) {
170179 throw new \RuntimeException ('Process is already running ' );
171180 }
0 commit comments