This can be simplified to:
/**
* Add new theme from filesystem and update existing
*
* @return void
*/
public function beforeDispatch() {
try {
if ($this->appState->getMode() != AppState::MODE_PRODUCTION) {
$this->themeRegistration->register();
$this->updateThemeData();
}
} catch (LocalizedException $e) {
$this->logger->critical($e);
}
}
A trick: a «before» plugin can avoid declaration of unused last arguments if it needs not modify any argument