From 087505dce3251c96862b198e747e7b5672d03d11 Mon Sep 17 00:00:00 2001 From: Stefan Froemken Date: Fri, 31 Mar 2023 14:02:44 +0200 Subject: [PATCH] [TASK] Use static function where possible Relates: #3376 --- Build/Test/IntegrationTestsBootstrap.php | 2 +- Build/Test/UnitTestsBootstrap.php | 2 +- .../Facets/OptionBased/Hierarchy/HierarchyFacetParser.php | 2 +- .../Domain/Search/ResultSet/Facets/UrlFacetContainer.php | 8 ++++---- Classes/Domain/Search/ResultSet/Sorting/SortingHelper.php | 2 +- Classes/Domain/Site/SiteRepository.php | 2 +- Classes/FrontendEnvironment/Tsfe.php | 2 +- Classes/IndexQueue/Indexer.php | 2 +- Classes/Routing/RoutingService.php | 2 +- Classes/System/Configuration/ExtensionConfiguration.php | 4 ++-- Classes/System/UserFunctions/FlexFormUserFunctions.php | 2 +- ext_localconf.php | 2 +- ext_tables.php | 2 +- 13 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Build/Test/IntegrationTestsBootstrap.php b/Build/Test/IntegrationTestsBootstrap.php index 5889de5050..96bb86ff93 100644 --- a/Build/Test/IntegrationTestsBootstrap.php +++ b/Build/Test/IntegrationTestsBootstrap.php @@ -15,7 +15,7 @@ use TYPO3\TestingFramework\Core\Testbase; -call_user_func(function () { +call_user_func(static function () { $testbase = new Testbase(); $testbase->defineOriginalRootPath(); $testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/tests'); diff --git a/Build/Test/UnitTestsBootstrap.php b/Build/Test/UnitTestsBootstrap.php index 3b0646cb92..2c4a4717a6 100644 --- a/Build/Test/UnitTestsBootstrap.php +++ b/Build/Test/UnitTestsBootstrap.php @@ -27,7 +27,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Testbase; -call_user_func(function () { +call_user_func(static function () { $testbase = new Testbase(); // These if's are for core testing (package typo3/cms) only. cms-composer-installer does diff --git a/Classes/Domain/Search/ResultSet/Facets/OptionBased/Hierarchy/HierarchyFacetParser.php b/Classes/Domain/Search/ResultSet/Facets/OptionBased/Hierarchy/HierarchyFacetParser.php index 8235384cea..425bf108a2 100644 --- a/Classes/Domain/Search/ResultSet/Facets/OptionBased/Hierarchy/HierarchyFacetParser.php +++ b/Classes/Domain/Search/ResultSet/Facets/OptionBased/Hierarchy/HierarchyFacetParser.php @@ -132,7 +132,7 @@ protected function getPathAsArray(string $path): array $path = str_replace('\/', '@@@', $path); $path = rtrim($path, '/'); $segments = explode('/', $path); - return array_map(function ($item) { + return array_map(static function ($item) { return str_replace('@@@', '/', $item); }, $segments); } diff --git a/Classes/Domain/Search/ResultSet/Facets/UrlFacetContainer.php b/Classes/Domain/Search/ResultSet/Facets/UrlFacetContainer.php index 669cdd168a..d96bc85555 100644 --- a/Classes/Domain/Search/ResultSet/Facets/UrlFacetContainer.php +++ b/Classes/Domain/Search/ResultSet/Facets/UrlFacetContainer.php @@ -164,11 +164,11 @@ public function getActiveFacetNames(): array $facetNames = []; if ($this->parameterStyle === self::PARAMETER_STYLE_INDEX) { - array_map(function ($activeFacet) use (&$facetNames) { + array_map(static function ($activeFacet) use (&$facetNames) { $facetNames[] = substr($activeFacet, 0, strpos($activeFacet, ':')); }, $activeFacets); } else { - array_map(function ($activeFacet) use (&$facetNames) { + array_map(static function ($activeFacet) use (&$facetNames) { $facetNames[] = substr($activeFacet, 0, strpos($activeFacet, ':')); }, array_keys($activeFacets)); } @@ -188,7 +188,7 @@ public function getActiveFacetValuesByName(string $facetName): array if ($this->parameterStyle === self::PARAMETER_STYLE_ASSOC) { $activeFacets = array_keys($activeFacets); } - array_map(function ($activeFacet) use (&$values, $facetName) { + array_map(static function ($activeFacet) use (&$values, $facetName) { $parts = explode(':', $activeFacet, 2); if ($parts[0] === $facetName) { $values[] = $parts[1]; @@ -324,7 +324,7 @@ public function removeAllFacetValuesByName(string $facetName): UrlFacetContainer $filterOptions = ARRAY_FILTER_USE_KEY; } - $facetValues = array_filter($facetValues, function ($facetNameValue) use ($facetName) { + $facetValues = array_filter($facetValues, static function ($facetNameValue) use ($facetName) { $parts = explode(':', $facetNameValue, 2); return $parts[0] !== $facetName; }, $filterOptions); diff --git a/Classes/Domain/Search/ResultSet/Sorting/SortingHelper.php b/Classes/Domain/Search/ResultSet/Sorting/SortingHelper.php index 64935d3e3c..589e3507f4 100644 --- a/Classes/Domain/Search/ResultSet/Sorting/SortingHelper.php +++ b/Classes/Domain/Search/ResultSet/Sorting/SortingHelper.php @@ -55,7 +55,7 @@ public function getSortFieldFromUrlParameter(string $urlParameters): string $sortFields = []; $sortParameters = GeneralUtility::trimExplode(',', $urlParameters); - $removeTsKeyDot = function ($sortingKey) { return trim($sortingKey, '.'); }; + $removeTsKeyDot = static function ($sortingKey) { return trim($sortingKey, '.'); }; $configuredSortingName = array_map($removeTsKeyDot, array_keys($this->configuration)); foreach ($sortParameters as $sortParameter) { diff --git a/Classes/Domain/Site/SiteRepository.php b/Classes/Domain/Site/SiteRepository.php index f658020b93..4e633fdb21 100644 --- a/Classes/Domain/Site/SiteRepository.php +++ b/Classes/Domain/Site/SiteRepository.php @@ -273,7 +273,7 @@ protected function buildTypo3ManagedSite(array $rootPageRecord): ?Site $siteHash = $this->getSiteHashForDomain($domain); $defaultLanguage = $typo3Site->getDefaultLanguage()->getLanguageId(); $pageRepository = GeneralUtility::makeInstance(PagesRepository::class); - $availableLanguageIds = array_map(function ($language) { + $availableLanguageIds = array_map(static function ($language) { return $language->getLanguageId(); }, $typo3Site->getLanguages()); diff --git a/Classes/FrontendEnvironment/Tsfe.php b/Classes/FrontendEnvironment/Tsfe.php index 7e5568bcfc..47cdbe4fdf 100644 --- a/Classes/FrontendEnvironment/Tsfe.php +++ b/Classes/FrontendEnvironment/Tsfe.php @@ -272,7 +272,7 @@ public function getTsfeByPageIdIgnoringLanguage(int $pageId): ?TypoScriptFronten } catch (Throwable $e) { return null; } - $availableLanguageIds = array_map(function ($siteLanguage) { + $availableLanguageIds = array_map(static function ($siteLanguage) { return $siteLanguage->getLanguageId(); }, $typo3Site->getLanguages()); diff --git a/Classes/IndexQueue/Indexer.php b/Classes/IndexQueue/Indexer.php index 9d30283c4f..ff220088f3 100644 --- a/Classes/IndexQueue/Indexer.php +++ b/Classes/IndexQueue/Indexer.php @@ -380,7 +380,7 @@ protected function isRootPageIdPartOfRootLine(Item $item): bool $rootlineUtility = GeneralUtility::makeInstance(RootlineUtility::class, $buildRootlineWithPid); $rootline = $rootlineUtility->get(); - $pageInRootline = array_filter($rootline, function ($page) use ($rootPageId) { + $pageInRootline = array_filter($rootline, static function ($page) use ($rootPageId) { return (int)$page['uid'] === $rootPageId; }); return !empty($pageInRootline); diff --git a/Classes/Routing/RoutingService.php b/Classes/Routing/RoutingService.php index da91244721..978fde87f6 100644 --- a/Classes/Routing/RoutingService.php +++ b/Classes/Routing/RoutingService.php @@ -473,7 +473,7 @@ public function getQueryParameterMap(): array $self = $this; return array_filter( $this->settings['query']['map'], - function ($value) use ($self) { + static function ($value) use ($self) { return !$self->isCoreParameter($value); } ); diff --git a/Classes/System/Configuration/ExtensionConfiguration.php b/Classes/System/Configuration/ExtensionConfiguration.php index 9bb7761483..a7eaa84769 100644 --- a/Classes/System/Configuration/ExtensionConfiguration.php +++ b/Classes/System/Configuration/ExtensionConfiguration.php @@ -124,13 +124,13 @@ public function getAvailablePluginNamespaces(): array public function getCacheHashExcludedParameters(): array { $pluginNamespaces = array_map( - function ($pluginNamespace) { + static function ($pluginNamespace) { return '^' . $pluginNamespace . '['; }, $this->getAvailablePluginNamespaces() ); $enhancersRouteParts = array_map( - function ($pluginNamespace) { + static function ($pluginNamespace) { // __ \TYPO3\CMS\Core\Routing\Enhancer\VariableProcessor::LEVEL_DELIMITER return '^' . $pluginNamespace . '__'; }, diff --git a/Classes/System/UserFunctions/FlexFormUserFunctions.php b/Classes/System/UserFunctions/FlexFormUserFunctions.php index c968100f20..32eab0a16d 100644 --- a/Classes/System/UserFunctions/FlexFormUserFunctions.php +++ b/Classes/System/UserFunctions/FlexFormUserFunctions.php @@ -75,7 +75,7 @@ protected function getParsedSolrFieldsFromSchema(array $configuredFacets, array $value = $fieldName; $label = $fieldName; - $facetNameFilter = function ($facet) use ($fieldName) { + $facetNameFilter = static function ($facet) use ($fieldName) { return $facet['field'] === $fieldName; }; $configuredFacets = array_filter($configuredFacets, $facetNameFilter); diff --git a/ext_localconf.php b/ext_localconf.php index 64639b3fc6..4c97575633 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -4,7 +4,7 @@ // ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- # -(function () { +(static function () { // ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- # // registering Index Queue page indexer helpers $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['Indexer']['indexPageSubstitutePageDocument'][\ApacheSolrForTypo3\Solr\AdditionalFieldsIndexer::class] = \ApacheSolrForTypo3\Solr\AdditionalFieldsIndexer::class; diff --git a/ext_tables.php b/ext_tables.php index 43ec405d58..848af99996 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -6,7 +6,7 @@ defined('TYPO3') or die('Access denied.'); -(function () { +(static function () { if (($GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface && ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend() ) {