3v4l.org

run code in 300+ PHP versions simultaneously
<?php // THIS IS SYNC CODE /** Make the calls **/ foreach ($callsToMake as $serverClients) { foreach ($serverClients as $keys) { /** @var ConnectionConfig $clientConfig */ $clientConfig = $keys['config']; /** Transport returns json **/ $transport = $this->transportFactory->build($this->client, $this->request, $clientConfig); /** Adapter returns Torrent objects **/ $adapter = $this->adapterFactory->build($transport); $torrents = array_merge($torrents, $adapter->getTorrents($keys['hashes'])); } } return $torrents; // TRYING TO MAKE IT ASYNC WITH $callable /** Make the calls **/ foreach ($callsToMake as $serverClients) { foreach ($serverClients as $keys) { /** @var ConnectionConfig $clientConfig */ $clientConfig = $keys['config']; /** Transport returns json **/ $transport = $this->transportFactory->build($this->client, $this->request, $clientConfig, $async = true); /** Adapter returns Torrent objects **/ $adapter = $this->adapterFactory->build($transport); $torrents = array_merge($torrents, $adapter->getTorrents($keys['hashes'], $callable)); // Obviously, this will only happen once } }

preferences:
42.06 ms | 402 KiB | 5 Q