Change EventHandler to always pass by reference and kill return-value semantics.

This commit is contained in:
Austen McDonald
2016-08-01 06:52:36 +00:00
parent 318531c6ad
commit 1d24aa973f
4 changed files with 3 additions and 6 deletions
+1 -1
View File
@@ -13,5 +13,5 @@ interface EventHandler
* the next handler is called. Otherwise, return null. Any changes made will be propogated
* to the event publisher as well.
*/
public static function handleEvent(string $event, array $context);
public static function handleEvent(string $event, array &$context);
}
-3
View File
@@ -47,9 +47,6 @@ class EventManager
if (preg_match($s->getPattern(), $event)) {
$class = $s->getClass();
$c = $class::handleEvent($event, $context);
if ($c !== null) {
$context = $c;
}
}
}
}
+1 -1
View File
@@ -19,7 +19,7 @@ class EventManagerTestInvalidSubscriber
class EventManagerTestSubscriber implements EventHandler
{
public static function handleEvent(string $event, array $context) {}
public static function handleEvent(string $event, array &$context) {}
}
class EventManagerTest extends ModelTestCase
+1 -1
View File
@@ -6,7 +6,7 @@ use LotGD\Core\Game;
use LotGD\Core\Module as ModuleBase;
class Module implements ModuleBase {
public static function handleEvent(string $event, array $context) {
public static function handleEvent(string $event, array &$context) {
$context['foo'] = 'baz';
return $context;
}