Skip to content

Commit

Permalink
[TASK] Use static function where possible
Browse files Browse the repository at this point in the history
Relates: #3376
  • Loading branch information
froemken authored and dkd-kaehm committed May 15, 2023
1 parent 1aca300 commit 087505d
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Build/Test/IntegrationTestsBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion Build/Test/UnitTestsBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions Classes/Domain/Search/ResultSet/Facets/UrlFacetContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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];
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Search/ResultSet/Sorting/SortingHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Site/SiteRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
2 changes: 1 addition & 1 deletion Classes/FrontendEnvironment/Tsfe.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
2 changes: 1 addition & 1 deletion Classes/IndexQueue/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Routing/RoutingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
);
Expand Down
4 changes: 2 additions & 2 deletions Classes/System/Configuration/ExtensionConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 . '__';
},
Expand Down
2 changes: 1 addition & 1 deletion Classes/System/UserFunctions/FlexFormUserFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ext_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
) {
Expand Down

0 comments on commit 087505d

Please sign in to comment.