Permalink
Browse files

Merge branch '2.0' into 2.1

* 2.0:
  [EventDispatcher] Added assertion.
  [EventDispathcer] Fix removeListener

Conflicts:
	src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php
  • Loading branch information...
fabpot committed Feb 11, 2013
2 parents 023521a + 3b20aef commit e1d18ff0ff6f3e45ac82f000bc221135df635527
Showing with 24 additions and 1 deletion.
  1. +1 −1 EventDispatcher.php
  2. +23 −0 Tests/EventDispatcherTest.php
View
@@ -106,7 +106,7 @@ public function removeListener($eventName, $listener)
}
foreach ($this->listeners[$eventName] as $priority => $listeners) {
- if (false !== ($key = array_search($listener, $listeners))) {
+ if (false !== ($key = array_search($listener, $listeners, true))) {
unset($this->listeners[$eventName][$priority][$key], $this->sorted[$eventName]);
}
}
@@ -244,6 +244,29 @@ public function testEventReceivesTheDispatcherInstance()
$this->dispatcher->dispatch('test');
$this->assertSame($this->dispatcher, $dispatcher);
}
+
+ /**
+ * @see https://bugs.php.net/bug.php?id=62976
+ *
+ * This bug affects:
+ * - The PHP 5.3 branch for versions < 5.3.18
+ * - The PHP 5.4 branch for versions < 5.4.8
+ * - The PHP 5.5 branch is not affected
+ */
+ public function testWorkaroundForPhpBug62976()
+ {
+ $dispatcher = new EventDispatcher();
+ $dispatcher->addListener('bug.62976', new CallableClass());
+ $dispatcher->removeListener('bug.62976', function() {});
+ $this->assertTrue($dispatcher->hasListeners('bug.62976'));
+ }
+}
+
+class CallableClass
+{
+ public function __invoke()
+ {
+ }
}
class TestEventListener

0 comments on commit e1d18ff

Please sign in to comment.