/**
* Discover an available port number.
*
* @return int
* The available port number that we discovered.
*
* @throws \RuntimeException
* Thrown when there are no available ports within the range.
*/
protected function findAvailablePort() { $store =
new FlockStore(DrupalFilesystem::
getOsTemporaryDirectory());
$lock_factory =
new LockFactory($store);
$counter = 100;
while ($counter--
) { // Limit to 9999 as higher ports cause random fails on DrupalCI.
$port =
random_int(1024, 9999
);
if (isset($this->portLocks
[$port])) { continue;
}