From 79268f9bd92bb032223042feaf617b4d635aeea9 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Mon, 19 Aug 2024 15:05:01 -0400 Subject: [PATCH] chore: ECS code cleanup --- src/Retour.php | 38 ++++++++++++------------- src/controllers/FileController.php | 3 +- src/controllers/RedirectsController.php | 3 +- src/translations/en/retour.php | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Retour.php b/src/Retour.php index 8f353850..37add022 100644 --- a/src/Retour.php +++ b/src/Retour.php @@ -285,7 +285,7 @@ protected function installEventListeners() Event::on( ClearCaches::class, ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, - function (RegisterCacheOptionsEvent $event) { + function(RegisterCacheOptionsEvent $event) { Craft::debug( 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', __METHOD__ @@ -301,7 +301,7 @@ function (RegisterCacheOptionsEvent $event) { Event::on( Plugins::class, Plugins::EVENT_AFTER_INSTALL_PLUGIN, - function (PluginEvent $event) { + function(PluginEvent $event) { if ($event->plugin === $this) { // Invalidate our caches after we've been installed $this->clearAllCaches(); @@ -328,7 +328,7 @@ protected function installGlobalEventListeners() Event::on( CraftVariable::class, CraftVariable::EVENT_INIT, - function (Event $event) { + function(Event $event) { /** @var CraftVariable $variable */ $variable = $event->sender; $variable->set('retour', [ @@ -338,7 +338,7 @@ function (Event $event) { } ); - $prepareRedirectOnElementChange = function (ElementEvent $event) { + $prepareRedirectOnElementChange = function(ElementEvent $event) { /** @var Element $element */ $element = $event->element; if ($element !== null && !$element->propagating && !$event->isNew && $element->getUrl() !== null) { @@ -361,7 +361,7 @@ function (Event $event) { } }; - $insertRedirectOnElementChange = function (ElementEvent $event) { + $insertRedirectOnElementChange = function(ElementEvent $event) { /** @var Element $element */ $element = $event->element; if ($element !== null && !$event->isNew && $element->getUrl() !== null) { @@ -379,7 +379,7 @@ function (Event $event) { Event::on( Elements::class, Elements::EVENT_BEFORE_SAVE_ELEMENT, - function (ElementEvent $event) use ($prepareRedirectOnElementChange) { + function(ElementEvent $event) use ($prepareRedirectOnElementChange) { Craft::debug( 'Elements::EVENT_BEFORE_SAVE_ELEMENT', __METHOD__ @@ -391,7 +391,7 @@ function (ElementEvent $event) use ($prepareRedirectOnElementChange) { Event::on( Elements::class, Elements::EVENT_AFTER_SAVE_ELEMENT, - function (ElementEvent $event) use ($insertRedirectOnElementChange) { + function(ElementEvent $event) use ($insertRedirectOnElementChange) { Craft::debug( 'Elements::EVENT_AFTER_SAVE_ELEMENT', __METHOD__ @@ -403,7 +403,7 @@ function (ElementEvent $event) use ($insertRedirectOnElementChange) { Event::on( Elements::class, Elements::EVENT_BEFORE_UPDATE_SLUG_AND_URI, - function (ElementEvent $event) use ($prepareRedirectOnElementChange) { + function(ElementEvent $event) use ($prepareRedirectOnElementChange) { Craft::debug( 'Elements::EVENT_BEFORE_UPDATE_SLUG_AND_URI', __METHOD__ @@ -415,7 +415,7 @@ function (ElementEvent $event) use ($prepareRedirectOnElementChange) { Event::on( Elements::class, Elements::EVENT_AFTER_UPDATE_SLUG_AND_URI, - function (ElementEvent $event) use ($insertRedirectOnElementChange) { + function(ElementEvent $event) use ($insertRedirectOnElementChange) { Craft::debug( 'Elements::EVENT_AFTER_UPDATE_SLUG_AND_URI', __METHOD__ @@ -428,7 +428,7 @@ function (ElementEvent $event) use ($insertRedirectOnElementChange) { Event::on( Plugins::class, Plugins::EVENT_AFTER_LOAD_PLUGINS, - function () { + function() { // Install these only after all other plugins have loaded $request = Craft::$app->getRequest(); // Only respond to non-console site requests @@ -445,7 +445,7 @@ function () { Event::on( Fields::class, Fields::EVENT_REGISTER_FIELD_TYPES, - function (RegisterComponentTypesEvent $event) { + function(RegisterComponentTypesEvent $event) { $event->types[] = ShortLinkField::class; } ); @@ -454,7 +454,7 @@ function (RegisterComponentTypesEvent $event) { Event::on( Gql::class, Gql::EVENT_REGISTER_GQL_TYPES, - function (RegisterGqlTypesEvent $event) { + function(RegisterGqlTypesEvent $event) { Craft::debug( 'Gql::EVENT_REGISTER_GQL_TYPES', __METHOD__ @@ -466,7 +466,7 @@ function (RegisterGqlTypesEvent $event) { Event::on( Gql::class, Gql::EVENT_REGISTER_GQL_QUERIES, - function (RegisterGqlQueriesEvent $event) { + function(RegisterGqlQueriesEvent $event) { Craft::debug( 'Gql::EVENT_REGISTER_GQL_QUERIES', __METHOD__ @@ -482,7 +482,7 @@ function (RegisterGqlQueriesEvent $event) { Event::on( Gql::class, Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS, - function (RegisterGqlSchemaComponentsEvent $event) { + function(RegisterGqlSchemaComponentsEvent $event) { Craft::debug( 'Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS', __METHOD__ @@ -512,7 +512,7 @@ protected function installSiteEventListeners() Event::on( UrlManager::class, UrlManager::EVENT_REGISTER_SITE_URL_RULES, - function (RegisterUrlRulesEvent $event) { + function(RegisterUrlRulesEvent $event) { Craft::debug( 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', __METHOD__ @@ -535,7 +535,7 @@ protected function installCpEventListeners() Event::on( Dashboard::class, Dashboard::EVENT_REGISTER_WIDGET_TYPES, - function (RegisterComponentTypesEvent $event) { + function(RegisterComponentTypesEvent $event) { /** @var User $user */ $user = Craft::$app->getUser(); if ($currentUser = $user->getIdentity()) { @@ -549,7 +549,7 @@ function (RegisterComponentTypesEvent $event) { Event::on( UrlManager::class, UrlManager::EVENT_REGISTER_CP_URL_RULES, - function (RegisterUrlRulesEvent $event) { + function(RegisterUrlRulesEvent $event) { Craft::debug( 'UrlManager::EVENT_REGISTER_CP_URL_RULES', __METHOD__ @@ -565,7 +565,7 @@ function (RegisterUrlRulesEvent $event) { Event::on( UserPermissions::class, UserPermissions::EVENT_REGISTER_PERMISSIONS, - function (RegisterUserPermissionsEvent $event) { + function(RegisterUserPermissionsEvent $event) { Craft::debug( 'UserPermissions::EVENT_REGISTER_PERMISSIONS', __METHOD__ @@ -587,7 +587,7 @@ protected function handleSiteRequest() Event::on( ErrorHandler::class, ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, - function (ExceptionEvent $event) { + function(ExceptionEvent $event) { Craft::debug( 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', __METHOD__ diff --git a/src/controllers/FileController.php b/src/controllers/FileController.php index 104ae486..ea08c6e2 100644 --- a/src/controllers/FileController.php +++ b/src/controllers/FileController.php @@ -138,6 +138,7 @@ public function actionImportCsvColumns() } $hasErrors = false; // If we have headers, then we have a file, so parse it + /** @phpstan-ignore-next-line */ if ($csv && $headers) { switch (VersionHelper::getLeagueCsvVersion()) { case 8: @@ -372,7 +373,7 @@ protected function importCsvApi8(AbstractCsv $csv, array $columns, array $header $columns = ArrayHelper::filterEmptyStringsFromArray($columns); $rowIndex = 1; /** @phpstan-ignore-next-line */ - $csv->each(function ($row) use ($headers, $columns, &$rowIndex, &$hasErrors) { + $csv->each(function($row) use ($headers, $columns, &$rowIndex, &$hasErrors) { $redirectConfig = [ 'id' => 0, ]; diff --git a/src/controllers/RedirectsController.php b/src/controllers/RedirectsController.php index 240fcf47..db366c7f 100644 --- a/src/controllers/RedirectsController.php +++ b/src/controllers/RedirectsController.php @@ -120,8 +120,7 @@ public function actionEditRedirect( string $defaultUrl = '', int $siteId = 0, StaticRedirectsModel $redirect = null - ): Response - { + ): Response { $variables = []; PermissionHelper::controllerPermissionCheck('retour:redirects'); diff --git a/src/translations/en/retour.php b/src/translations/en/retour.php index 36885d26..8e67897f 100644 --- a/src/translations/en/retour.php +++ b/src/translations/en/retour.php @@ -171,5 +171,5 @@ 'Some errors occured .' => 'Some errors occured .', 'Some errors occured importing the CSV file.' => 'Some errors occured importing the CSV file.', 'Select the priority that will determine the order of mathching the redirect.' => 'Select the priority that will determine the order of mathching the redirect.', - 'Excluded URI: {uri} due to match of pattern: {pattern}' => 'Excluded URI: {uri} due to match of pattern: {pattern}' + 'Excluded URI: {uri} due to match of pattern: {pattern}' => 'Excluded URI: {uri} due to match of pattern: {pattern}', ];