updated depency libaries

This commit is contained in:
kremsy 2015-06-19 18:51:09 +02:00
parent 090830fa8c
commit 925b7a38a4
18 changed files with 207 additions and 56 deletions

View File

@ -121,7 +121,7 @@ class ContainerAwareEventDispatcher extends EventDispatcher
public function getListeners($eventName = null) public function getListeners($eventName = null)
{ {
if (null === $eventName) { if (null === $eventName) {
foreach (array_keys($this->listenerIds) as $serviceEventName) { foreach ($this->listenerIds as $serviceEventName => $args) {
$this->lazyLoad($serviceEventName); $this->lazyLoad($serviceEventName);
} }
} else { } else {

View File

@ -31,6 +31,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
private $called; private $called;
private $dispatcher; private $dispatcher;
private $wrappedListeners;
/** /**
* Constructor. * Constructor.
@ -45,6 +46,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
$this->stopwatch = $stopwatch; $this->stopwatch = $stopwatch;
$this->logger = $logger; $this->logger = $logger;
$this->called = array(); $this->called = array();
$this->wrappedListeners = array();
} }
/** /**
@ -68,6 +70,16 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
*/ */
public function removeListener($eventName, $listener) public function removeListener($eventName, $listener)
{ {
if (isset($this->wrappedListeners[$eventName])) {
foreach ($this->wrappedListeners[$eventName] as $index => $wrappedListener) {
if ($wrappedListener->getWrappedListener() === $listener) {
$listener = $wrappedListener;
unset($this->wrappedListeners[$eventName][$index]);
break;
}
}
}
return $this->dispatcher->removeListener($eventName, $listener); return $this->dispatcher->removeListener($eventName, $listener);
} }
@ -146,7 +158,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
$allListeners = $this->getListeners(); $allListeners = $this->getListeners();
} catch (\Exception $e) { } catch (\Exception $e) {
if (null !== $this->logger) { if (null !== $this->logger) {
$this->logger->info(sprintf('An exception was thrown while getting the uncalled listeners (%s)', $e->getMessage()), array('exception' => $e)); $this->logger->info('An exception was thrown while getting the uncalled listeners.', array('exception' => $e));
} }
// unable to retrieve the uncalled listeners // unable to retrieve the uncalled listeners
@ -216,12 +228,15 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
$this->dispatcher->removeListener($eventName, $listener); $this->dispatcher->removeListener($eventName, $listener);
$info = $this->getListenerInfo($listener, $eventName); $info = $this->getListenerInfo($listener, $eventName);
$name = isset($info['class']) ? $info['class'] : $info['type']; $name = isset($info['class']) ? $info['class'] : $info['type'];
$this->dispatcher->addListener($eventName, new WrappedListener($listener, $name, $this->stopwatch)); $wrappedListener = new WrappedListener($listener, $name, $this->stopwatch, $this);
$this->wrappedListeners[$eventName][] = $wrappedListener;
$this->dispatcher->addListener($eventName, $wrappedListener);
} }
} }
private function postProcess($eventName) private function postProcess($eventName)
{ {
unset($this->wrappedListeners[$eventName]);
$skipped = false; $skipped = false;
foreach ($this->dispatcher->getListeners($eventName) as $listener) { foreach ($this->dispatcher->getListeners($eventName) as $listener) {
if (!$listener instanceof WrappedListener) { // #12845: a new listener was added during dispatch. if (!$listener instanceof WrappedListener) { // #12845: a new listener was added during dispatch.
@ -259,7 +274,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
} }
/** /**
* Returns information about the listener * Returns information about the listener.
* *
* @param object $listener The listener * @param object $listener The listener
* @param string $eventName The event name * @param string $eventName The event name

View File

@ -25,12 +25,14 @@ class WrappedListener
private $called; private $called;
private $stoppedPropagation; private $stoppedPropagation;
private $stopwatch; private $stopwatch;
private $dispatcher;
public function __construct($listener, $name, Stopwatch $stopwatch) public function __construct($listener, $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = null)
{ {
$this->listener = $listener; $this->listener = $listener;
$this->name = $name; $this->name = $name;
$this->stopwatch = $stopwatch; $this->stopwatch = $stopwatch;
$this->dispatcher = $dispatcher;
$this->called = false; $this->called = false;
$this->stoppedPropagation = false; $this->stoppedPropagation = false;
} }
@ -56,7 +58,7 @@ class WrappedListener
$e = $this->stopwatch->start($this->name, 'event_listener'); $e = $this->stopwatch->start($this->name, 'event_listener');
call_user_func($this->listener, $event, $eventName, $dispatcher); call_user_func($this->listener, $event, $eventName, $this->dispatcher ?: $dispatcher);
if ($e->isStarted()) { if ($e->isStarted()) {
$e->stop(); $e->stop();

View File

@ -91,8 +91,12 @@ class RegisterListenersPass implements CompilerPassInterface
throw new \InvalidArgumentException(sprintf('The service "%s" must be public as event subscribers are lazy-loaded.', $id)); throw new \InvalidArgumentException(sprintf('The service "%s" must be public as event subscribers are lazy-loaded.', $id));
} }
if ($def->isAbstract()) {
throw new \InvalidArgumentException(sprintf('The service "%s" must not be abstract as event subscribers are lazy-loaded.', $id));
}
// We must assume that the class value has been correctly filled, even if the service is created by a factory // We must assume that the class value has been correctly filled, even if the service is created by a factory
$class = $def->getClass(); $class = $container->getParameterBag()->resolveValue($def->getClass());
$refClass = new \ReflectionClass($class); $refClass = new \ReflectionClass($class);
$interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface'; $interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface';

View File

@ -77,7 +77,7 @@ class Event
* *
* @param EventDispatcherInterface $dispatcher * @param EventDispatcherInterface $dispatcher
* *
* @deprecated Deprecated in 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call. * @deprecated since version 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call.
* *
* @api * @api
*/ */
@ -91,12 +91,14 @@ class Event
* *
* @return EventDispatcherInterface * @return EventDispatcherInterface
* *
* @deprecated Deprecated in 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call. * @deprecated since version 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call.
* *
* @api * @api
*/ */
public function getDispatcher() public function getDispatcher()
{ {
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0. The event dispatcher instance can be received in the listener call instead.', E_USER_DEPRECATED);
return $this->dispatcher; return $this->dispatcher;
} }
@ -105,12 +107,14 @@ class Event
* *
* @return string * @return string
* *
* @deprecated Deprecated in 2.4, to be removed in 3.0. The event name is passed to the listener call. * @deprecated since version 2.4, to be removed in 3.0. The event name is passed to the listener call.
* *
* @api * @api
*/ */
public function getName() public function getName()
{ {
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0. The event name can be received in the listener call instead.', E_USER_DEPRECATED);
return $this->name; return $this->name;
} }
@ -119,7 +123,7 @@ class Event
* *
* @param string $name The event name. * @param string $name The event name.
* *
* @deprecated Deprecated in 2.4, to be removed in 3.0. The event name is passed to the listener call. * @deprecated since version 2.4, to be removed in 3.0. The event name is passed to the listener call.
* *
* @api * @api
*/ */

View File

@ -68,7 +68,7 @@ class EventDispatcher implements EventDispatcherInterface
return $this->sorted[$eventName]; return $this->sorted[$eventName];
} }
foreach (array_keys($this->listeners) as $eventName) { foreach ($this->listeners as $eventName => $eventListeners) {
if (!isset($this->sorted[$eventName])) { if (!isset($this->sorted[$eventName])) {
$this->sortListeners($eventName); $this->sortListeners($eventName);
} }

View File

@ -77,7 +77,7 @@ interface EventDispatcherInterface
public function removeSubscriber(EventSubscriberInterface $subscriber); public function removeSubscriber(EventSubscriberInterface $subscriber);
/** /**
* Gets the listeners of a specific event or all listeners. * Gets the listeners of a specific event or all listeners sorted by descending priority.
* *
* @param string $eventName The name of the event * @param string $eventName The name of the event
* *

View File

@ -71,7 +71,7 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
return $this->arguments[$key]; return $this->arguments[$key];
} }
throw new \InvalidArgumentException(sprintf('%s not found in %s', $key, $this->getName())); throw new \InvalidArgumentException(sprintf('Argument "%s" not found.', $key));
} }
/** /**

View File

@ -23,5 +23,5 @@ Resources
You can run the unit tests with the following command: You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/EventDispatcher/ $ cd path/to/Symfony/Component/EventDispatcher/
$ composer.phar install $ composer install
$ phpunit $ phpunit

View File

@ -118,10 +118,21 @@ abstract class AbstractEventDispatcherTest extends \PHPUnit_Framework_TestCase
$this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(self::preFoo)); $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(self::preFoo));
$event = new Event(); $event = new Event();
$return = $this->dispatcher->dispatch(self::preFoo, $event); $return = $this->dispatcher->dispatch(self::preFoo, $event);
$this->assertEquals('pre.foo', $event->getName());
$this->assertSame($event, $return); $this->assertSame($event, $return);
} }
/**
* @group legacy
*/
public function testLegacyDispatch()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$event = new Event();
$return = $this->dispatcher->dispatch(self::preFoo, $event);
$this->assertEquals('pre.foo', $event->getName());
}
public function testDispatchForClosure() public function testDispatchForClosure()
{ {
$invoked = 0; $invoked = 0;
@ -239,8 +250,13 @@ abstract class AbstractEventDispatcherTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($this->dispatcher->hasListeners(self::preFoo)); $this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
} }
public function testEventReceivesTheDispatcherInstance() /**
* @group legacy
*/
public function testLegacyEventReceivesTheDispatcherInstance()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$dispatcher = null; $dispatcher = null;
$this->dispatcher->addListener('test', function ($event) use (&$dispatcher) { $this->dispatcher->addListener('test', function ($event) use (&$dispatcher) {
$dispatcher = $event->getDispatcher(); $dispatcher = $event->getDispatcher();

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\EventDispatcher\Tests\Debug; namespace Symfony\Component\EventDispatcher\Tests\Debug;
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher; use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\Event;
@ -86,6 +87,20 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array(), $tdispatcher->getNotCalledListeners()); $this->assertEquals(array(), $tdispatcher->getNotCalledListeners());
} }
public function testGetCalledListenersNested()
{
$tdispatcher = null;
$dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch());
$dispatcher->addListener('foo', function (Event $event, $eventName, $dispatcher) use (&$tdispatcher) {
$tdispatcher = $dispatcher;
$dispatcher->dispatch('bar');
});
$dispatcher->addListener('bar', function (Event $event) {});
$dispatcher->dispatch('foo');
$this->assertSame($dispatcher, $tdispatcher);
$this->assertCount(2, $dispatcher->getCalledListeners());
}
public function testLogger() public function testLogger()
{ {
$logger = $this->getMock('Psr\Log\LoggerInterface'); $logger = $this->getMock('Psr\Log\LoggerInterface');
@ -160,6 +175,19 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
$dispatcher->dispatch('foo'); $dispatcher->dispatch('foo');
$this->assertTrue($nestedCall); $this->assertTrue($nestedCall);
} }
public function testListenerCanRemoveItselfWhenExecuted()
{
$eventDispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch());
$listener1 = function ($event, $eventName, EventDispatcherInterface $dispatcher) use (&$listener1) {
$dispatcher->removeListener('foo', $listener1);
};
$eventDispatcher->addListener('foo', $listener1);
$eventDispatcher->addListener('foo', function () {});
$eventDispatcher->dispatch('foo');
$this->assertCount(1, $eventDispatcher->getListeners('foo'), 'expected listener1 to be removed');
}
} }
class EventSubscriber implements EventSubscriberInterface class EventSubscriber implements EventSubscriberInterface

View File

@ -138,6 +138,58 @@ class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase
$registerListenersPass = new RegisterListenersPass(); $registerListenersPass = new RegisterListenersPass();
$registerListenersPass->process($container); $registerListenersPass->process($container);
} }
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The service "foo" must not be abstract as event subscribers are lazy-loaded.
*/
public function testAbstractEventSubscriber()
{
$container = new ContainerBuilder();
$container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_subscriber', array());
$container->register('event_dispatcher', 'stdClass');
$registerListenersPass = new RegisterListenersPass();
$registerListenersPass->process($container);
}
public function testEventSubscriberResolvableClassName()
{
$container = new ContainerBuilder();
$container->setParameter('subscriber.class', 'Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService');
$container->register('foo', '%subscriber.class%')->addTag('kernel.event_subscriber', array());
$container->register('event_dispatcher', 'stdClass');
$registerListenersPass = new RegisterListenersPass();
$registerListenersPass->process($container);
$definition = $container->getDefinition('event_dispatcher');
$expected_calls = array(
array(
'addSubscriberService',
array(
'foo',
'Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService',
),
),
);
$this->assertSame($expected_calls, $definition->getMethodCalls());
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage You have requested a non-existent parameter "subscriber.class"
*/
public function testEventSubscriberUnresolvableClassName()
{
$container = new ContainerBuilder();
$container->register('foo', '%subscriber.class%')->addTag('kernel.event_subscriber', array());
$container->register('event_dispatcher', 'stdClass');
$registerListenersPass = new RegisterListenersPass();
$registerListenersPass->process($container);
}
} }
class SubscriberService implements \Symfony\Component\EventDispatcher\EventSubscriberInterface class SubscriberService implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

View File

@ -60,6 +60,9 @@ class EventTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($this->event->isPropagationStopped()); $this->assertTrue($this->event->isPropagationStopped());
} }
/**
* @group legacy
*/
public function testLegacySetDispatcher() public function testLegacySetDispatcher()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
@ -67,18 +70,27 @@ class EventTest extends \PHPUnit_Framework_TestCase
$this->assertSame($this->dispatcher, $this->event->getDispatcher()); $this->assertSame($this->dispatcher, $this->event->getDispatcher());
} }
/**
* @group legacy
*/
public function testLegacyGetDispatcher() public function testLegacyGetDispatcher()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->assertNull($this->event->getDispatcher()); $this->assertNull($this->event->getDispatcher());
} }
/**
* @group legacy
*/
public function testLegacyGetName() public function testLegacyGetName()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->assertNull($this->event->getName()); $this->assertNull($this->event->getName());
} }
/**
* @group legacy
*/
public function testLegacySetName() public function testLegacySetName()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);

View File

@ -3,7 +3,7 @@
"type": "library", "type": "library",
"description": "Symfony EventDispatcher Component", "description": "Symfony EventDispatcher Component",
"keywords": [], "keywords": [],
"homepage": "http://symfony.com", "homepage": "https://symfony.com",
"license": "MIT", "license": "MIT",
"authors": [ "authors": [
{ {
@ -12,13 +12,14 @@
}, },
{ {
"name": "Symfony Community", "name": "Symfony Community",
"homepage": "http://symfony.com/contributors" "homepage": "https://symfony.com/contributors"
} }
], ],
"require": { "require": {
"php": ">=5.3.3" "php": ">=5.3.9"
}, },
"require-dev": { "require-dev": {
"symfony/phpunit-bridge": "~2.7",
"symfony/dependency-injection": "~2.6", "symfony/dependency-injection": "~2.6",
"symfony/expression-language": "~2.6", "symfony/expression-language": "~2.6",
"symfony/config": "~2.0,>=2.0.5", "symfony/config": "~2.0,>=2.0.5",
@ -30,13 +31,12 @@
"symfony/http-kernel": "" "symfony/http-kernel": ""
}, },
"autoload": { "autoload": {
"psr-0": { "Symfony\\Component\\EventDispatcher\\": "" } "psr-4": { "Symfony\\Component\\EventDispatcher\\": "" }
}, },
"target-dir": "Symfony/Component/EventDispatcher",
"minimum-stability": "dev", "minimum-stability": "dev",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.6-dev" "dev-master": "2.7-dev"
} }
} }
} }

View File

@ -7,9 +7,9 @@
bootstrap="vendor/autoload.php" bootstrap="vendor/autoload.php"
> >
<php> <php>
<!-- Silence E_USER_DEPRECATED (-16385 == -1 & ~E_USER_DEPRECATED) --> <ini name="error_reporting" value="-1" />
<ini name="error_reporting" value="-16385"/>
</php> </php>
<testsuites> <testsuites>
<testsuite name="Symfony EventDispatcher Component Test Suite"> <testsuite name="Symfony EventDispatcher Component Test Suite">
<directory>./Tests/</directory> <directory>./Tests/</directory>

View File

@ -5,6 +5,18 @@ use Symfony\Component\EventDispatcher\Event as SymfonyEvent;
class Event extends SymfonyEvent class Event extends SymfonyEvent
{ {
/** @var Response $response */ /**
public $response = null; * @var Response
*/
public $response;
/**
* @var Request
*/
public $request;
/**
* @var RequestsQueue
*/
public $queue;
} }

View File

@ -54,7 +54,7 @@ class Request extends EventDispatcher implements RequestInterface
public function getOptions() public function getOptions()
{ {
if (!isset($this->options)) { if (!isset($this->options)) {
$this->options = new Options; $this->options = new Options();
} }
return $this->options; return $this->options;
} }
@ -97,6 +97,8 @@ class Request extends EventDispatcher implements RequestInterface
* This function should be called after initializing a cURL * This function should be called after initializing a cURL
* session and all the options for the session are set. * session and all the options for the session are set.
* *
* Warning: it doesn't fire 'complete' event.
*
* @return Response * @return Response
*/ */
public function send() public function send()
@ -114,31 +116,30 @@ class Request extends EventDispatcher implements RequestInterface
return $response; return $response;
} }
protected function prepareQueue() /**
{ * Creates new RequestsQueue with single Request attached to it
if (!isset($this->queue)) { * and calls RequestsQueue::socketPerform() method.
$request = $this; *
$this->queue = new RequestsQueue; * @see RequestsQueue::socketPerform()
$this->queue->addListener( */
'complete',
function ($event) use ($request) {
$request->dispatch('complete', $event);
}
);
$this->queue->attach($this);
}
}
public function socketPerform() public function socketPerform()
{ {
$this->prepareQueue(); if (!isset($this->queue)) {
$this->queue = new RequestsQueue();
$this->queue->attach($this);
}
return $this->queue->socketPerform(); return $this->queue->socketPerform();
} }
/**
* Calls socketSelect() on previously created RequestsQueue
*
* @see RequestsQueue::socketSelect()
*/
public function socketSelect($timeout = 1) public function socketSelect($timeout = 1)
{ {
if (!isset($this->queue)) { if (!isset($this->queue)) {
throw new Exception('Cannot select without perform before.'); throw new Exception('You need to call socketPerform() before.');
} }
return $this->queue->socketSelect($timeout); return $this->queue->socketSelect($timeout);
} }

View File

@ -2,9 +2,8 @@
namespace cURL; namespace cURL;
use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\EventDispatcher;
use Countable;
class RequestsQueue extends EventDispatcher implements RequestsQueueInterface, Countable class RequestsQueue extends EventDispatcher implements RequestsQueueInterface, \Countable
{ {
/** /**
* @var Options Default options for new Requests attached to RequestsQueue * @var Options Default options for new Requests attached to RequestsQueue
@ -59,7 +58,7 @@ class RequestsQueue extends EventDispatcher implements RequestsQueueInterface, C
public function getDefaultOptions() public function getDefaultOptions()
{ {
if (!isset($this->defaultOptions)) { if (!isset($this->defaultOptions)) {
$this->defaultOptions = new Options; $this->defaultOptions = new Options();
} }
return $this->defaultOptions; return $this->defaultOptions;
} }
@ -126,7 +125,7 @@ class RequestsQueue extends EventDispatcher implements RequestsQueueInterface, C
unset($this->running[$request->getUID()]); unset($this->running[$request->getUID()]);
$this->detach($request); $this->detach($request);
$event = new Event; $event = new Event();
$event->request = $request; $event->request = $request;
$event->response = new Response($request, curl_multi_getcontent($request->getHandle())); $event->response = new Response($request, curl_multi_getcontent($request->getHandle()));
if ($result !== CURLE_OK) { if ($result !== CURLE_OK) {
@ -134,6 +133,7 @@ class RequestsQueue extends EventDispatcher implements RequestsQueueInterface, C
} }
$event->queue = $this; $event->queue = $this;
$this->dispatch('complete', $event); $this->dispatch('complete', $event);
$request->dispatch('complete', $event);
} }
return $n; return $n;
@ -168,7 +168,9 @@ class RequestsQueue extends EventDispatcher implements RequestsQueueInterface, C
*/ */
protected function getRequestsNotRunning() protected function getRequestsNotRunning()
{ {
return array_diff_key($this->queue, $this->running); $map = $this->queue;
foreach($this->running as $k => $v) unset($map[$k]);
return $map;
} }
/** /**
@ -201,11 +203,14 @@ class RequestsQueue extends EventDispatcher implements RequestsQueueInterface, C
} while ($mrc === CURLM_CALL_MULTI_PERFORM); } while ($mrc === CURLM_CALL_MULTI_PERFORM);
$runningAfter = $this->runningCount; $runningAfter = $this->runningCount;
$completed = ($runningAfter < $runningBefore) ? $this->read() : 0; if ($runningAfter < $runningBefore) {
$this->read();
}
$notRunning = $this->getRequestsNotRunning(); $notRunning = $this->getRequestsNotRunning();
} while (count($notRunning) > 0); } while (count($notRunning) > 0);
// Why the loop? New requests might be added at runtime on 'complete' event.
// So we need to attach them to curl_multi handle immediately.
return $this->count() > 0; return $this->count() > 0;
} }