3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 } }
Output for 5.1.0 - 5.6.28, 7.0.0 - 7.1.0
Notice: Undefined variable: callsToMake in /in/iq4P8 on line 6 Warning: Invalid argument supplied for foreach() in /in/iq4P8 on line 6 Notice: Undefined variable: torrents in /in/iq4P8 on line 23
Output for hhvm-3.12.0
Notice: Undefined variable: callsToMake in /in/iq4P8 on line -1 Warning: Invalid argument supplied for foreach() in /in/iq4P8 on line -1 Notice: Undefined variable: torrents in /in/iq4P8 on line -1
Output for hhvm-3.10.0
Notice: Undefined variable: callsToMake in /in/iq4P8 on line 21 Warning: Invalid argument supplied for foreach() in /in/iq4P8 on line 21 Notice: Undefined variable: torrents in /in/iq4P8 on line 23
Output for 5.0.4 - 5.0.5
Warning: Invalid argument supplied for foreach() in /in/iq4P8 on line 6 Notice: Undefined variable: torrents in /in/iq4P8 on line 23
Output for 4.3.0 - 4.3.10, 4.4.0 - 5.0.3
Warning: Invalid argument supplied for foreach() in /in/iq4P8 on line 6 Notice: Undefined variable: torrents in /in/iq4P8 on line 23
Output for 4.3.11
Notice: Undefined variable: torrents in /in/iq4P8 on line 23