Change EventHandler to always pass by reference and kill return-value semantics.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user