https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/EventBus/+/498393/ - T204575 - refactors the EventBus code, since that patch set many $events variable are used as array in EventBusHooks.php, but are not declared before use.
<file name="includes\EventBusHooks.php"> <error line="82" severity="info" message="Variable $events was undeclared, but array fields are being added to it." source="PhanUndeclaredVariableDim"/> <error line="115" severity="info" message="Variable $events was undeclared, but array fields are being added to it." source="PhanUndeclaredVariableDim"/> <error line="154" severity="info" message="Variable $events was undeclared, but array fields are being added to it." source="PhanUndeclaredVariableDim"/> <error line="192" severity="info" message="Variable $events was undeclared, but array fields are being added to it." source="PhanUndeclaredVariableDim"/> <error line="256" severity="info" message="Variable $events was undeclared, but array fields are being added to it." source="PhanUndeclaredVariableDim"/> <error line="331" severity="info" message="Variable $events was undeclared, but array fields are being added to it." source="PhanUndeclaredVariableDim"/> <error line="393" severity="info" message="Variable $events was undeclared, but array fields are being added to it." source="PhanUndeclaredVariableDim"/> <error line="424" severity="info" message="Variable $events was undeclared, but array fields are being added to it." source="PhanUndeclaredVariableDim"/> <error line="482" severity="info" message="Variable $propEvents was undeclared, but array fields are being added to it." source="PhanUndeclaredVariableDim"/> <error line="503" severity="info" message="Variable $linkEvents was undeclared, but array fields are being added to it." source="PhanUndeclaredVariableDim"/> <error line="542" severity="info" message="Variable $events was undeclared, but array fields are being added to it." source="PhanUndeclaredVariableDim"/> <error line="601" severity="info" message="Variable $events was undeclared, but array fields are being added to it." source="PhanUndeclaredVariableDim"/> </file>
The variable is often set by the return value of factory functions like createRevisionCreateEvent which are itself declared to return arrays.
It is correct that EventBus::send needs an array of arrays or plain array?
It would be nice to declare the array before use or to set the return value as variable
$events[] = $eventBus->getFactory()->createRevisionCreateEvent( $stream, $revision->getRevisionRecord() ); DeferredUpdates::addCallableUpdate( function () use ( $eventBus, $events ) { $eventBus->send( $events ); } );