title: Symfony event addListener and variable Scope/State
body: <p>I'm currently using sitl/curl-easy to make a multi-curl parallel requets, but I'm having some hard time with scope / state:</p>
  
  <pre><code>// Init queue of requests
  $queue = new \cURL\RequestsQueue;
  </code></pre>
  
  <p>... init queue options</p>
  
  <pre><code>// Set function to be executed when request will be completed
  $queue-&gt;addListener('complete', function (\cURL\Event $event) 
  {
      $response = $event-&gt;response-&gt;getContent();
  
      // ugly :D, get the key from the object request
      $key = explode("&amp;key=", array_values($event-&gt;request-&gt;getOptions()-&gt;toArray())[0])[1];
  
      // if response is not null, truncate it to use less space 
      if ($response != null){
          $response = str_replace(array("\r", "\n"), "", $response);
      }
  
      &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; DON'T WORK, $banner_holder is declared on the top of the php page
      array_push($banner_holder, array("key"=&gt; $key,"content"=&gt;$response));
  });
  </code></pre>
  
  <p>How to push the array of $key and $response outside the listener?</p>
  
  <p>Thanks in advance.</p>