addTimer(0.001, function (Timer $timer) use ($process, $closure, $port, &$clientData) { $process->start($timer->getLoop()); $process->stdout->on('data', function ($output) use (&$clientData) { $clientData[] = $output; }); if (strpos(PHP_OS, 'WIN') === false || getenv('MOCKSERVER_TIMEOUT_USEC') !== false) { // wait to spin up. needed for linux. unnessecary on Windows 10. // Ugly but even with 150ms sleep test run faster on Linux usleep(getenv('MOCKSERVER_TIMEOUT_USEC') ?: 150000); } $closure($port); }); $loop->run(); return $clientData; } }