private static function findBestPort(string $host): string
    {
        $port = 8000;

        while (false !== $fp = @\fsockopen($host, $port, $errno, $errstr, 1)) {
            \fclose($fp);

            if ($port++ >= 8100) {
                throw new RuntimeException('Unable to find a port available to run the web server.');
            }
        }

        return (string) $port;
    }
private static function findBestPort(string $host): string
    {
        $port = 8000;

        while (false !== $fp = @\fsockopen($host, $port, $errno, $errstr, 1)) {
            \fclose($fp);

            if ($port++ >= 8100) {
                throw new RuntimeException('Unable to find a port available to run the web server.');
            }
        }

        return (string) $port;
    }
private static function findBestPort ( string $ host ) : string { $ port = 8000 ; while ( false !== $ fp = @ \ fsockopen ( $ host , $ port , $ errno , $ errstr , 1 ) ) { \ fclose ( $ fp ) ; if ( $ port ++ >= 8100 ) { throw new RuntimeException ( 'Unable to find a port available to run the web server.' ) ; } } return ( string ) $ port ; }
Searching for the port between 8000 and 8100.

@param string $host

@return string
Searching for the port between 8000 and 8100 .