Example: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Echo/+/561589
$section = $this->event->getSection(); // Add listener to refresh notification count upon insert $notifMapper->attachListener( 'insert', 'refresh-notif-count', function () use ( $notifUser, $section ) { $notifUser->resetNotificationCount(); } );
$section is accessible from inside the closure but it's not used there.