Guzzle Pool Async Requests Scope
<p>I'm using the following code to make concurrent requests with Guzzle for PHP:</p>

<pre><code>use GuzzleHttp\Pool;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;

$client = new Client();

$myvar = 12345;

$requests = function ($total) {
    $uri = 'http://127.0.0.1:8126/guzzle-server/perf';
    for ($i = 0; $i &lt; $total; $i++) {
        yield new Request('GET', $uri);
    }
};

$pool = new Pool($client, $requests(100), [
    'concurrency' =&gt; 5,
    'fulfilled' =&gt; function ($response, $index) {
        // this is delivered each successful response
        var_dump($myvar);
    },
    'rejected' =&gt; function ($reason, $index) {
        // this is delivered each failed request
    },
]);

// Initiate the transfers and create a promise
$promise = $pool-&gt;promise();

// Force the pool of requests to complete.
$promise-&gt;wait();
</code></pre>

<p>How would one access data in the 'fulfilled' handler section outside of the scope of the function? The code shown displays NULL, indicating no access to the $myvar variable.</p>