Skip to content

Commit

Permalink
[BUGFIX] Fix TYPO3 coding standards
Browse files Browse the repository at this point in the history
Relates: #3995
  • Loading branch information
dkd-kaehm committed May 16, 2024
1 parent 76e645e commit ef0d460
Show file tree
Hide file tree
Showing 56 changed files with 100 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public function saveStopWordsAction(string $stopWords, bool $replaceStopwords =
protected function exportFile(string $content, string $type = 'synonyms', string $fileExtension = 'txt'): ResponseInterface
{
$coreAdmin = $this->selectedSolrCoreConnection->getAdminService();
return $this->responseFactory->createResponse()
return $this->responseFactory->createResponse()
->withHeader('Content-Type', 'text/plain; charset=utf-8')
->withHeader('Cache-control', 'public')
->withHeader('Content-Description', 'File transfer')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function handlePageMovement(int $uid, ?int $previousParentId = null): voi
$subPageIds = $this->getSubPageIds($uid);
array_walk(
$subPageIds,
fn(int $subPageId) => $this->collectGarbage('pages', $subPageId)
fn (int $subPageId) => $this->collectGarbage('pages', $subPageId)
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Search/ApacheSolrDocument/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ protected function initializeSearch(int $pageId, int $languageId = 0): void
*/
protected function getSearch(SolrConnection $solrConnection): Search
{
return GeneralUtility::makeInstance(Search::class, $solrConnection);
return GeneralUtility::makeInstance(Search::class, $solrConnection);
}
}
6 changes: 3 additions & 3 deletions Classes/Domain/Search/Query/AbstractQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public function useFilter(string $filterString, string $filterName = ''): self
public function removeFilterByFieldName(string $fieldName): self
{
return $this->removeFilterByFunction(
function ($key, $query) use ($fieldName) {
function($key, $query) use ($fieldName) {
$queryString = $query->getQuery();
$storedFieldName = substr($queryString, 0, strpos($queryString, ':'));
return $storedFieldName == $fieldName;
Expand All @@ -292,7 +292,7 @@ function ($key, $query) use ($fieldName) {
public function removeFilterByName(string $name): self
{
return $this->removeFilterByFunction(
function ($key, $query) use ($name) {
function($key, $query) use ($name) {
return $query->getKey() === $name;
}
);
Expand All @@ -304,7 +304,7 @@ function ($key, $query) use ($name) {
public function removeFilterByValue(string $value): self
{
return $this->removeFilterByFunction(
function ($key, $query) use ($value) {
function($key, $query) use ($value) {
$query = $query->getQuery();
return $query == $value;
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Search/Query/ParameterBuilder/Slops.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ protected static function getPhraseSlopFromConfiguration(array $searchConfigurat
{
$phraseEnabled = !(empty($searchConfiguration['query.']['phrase']) || $searchConfiguration['query.']['phrase'] !== 1);
$phraseSlopConfigured = !empty($searchConfiguration['query.']['phrase.']['slop']);
return ($phraseEnabled && $phraseSlopConfigured) ? $searchConfiguration['query.']['phrase.']['slop'] : self::NO_SLOP;
return ($phraseEnabled && $phraseSlopConfigured) ? $searchConfiguration['query.']['phrase.']['slop'] : self::NO_SLOP;
}

protected static function getQuerySlopFromConfiguration(array $searchConfiguration): ?int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getCount(): int
*/
public function getSelected(): AbstractCollection
{
return $this->getFilteredCopy(function (AbstractFacetItem $item) {
return $this->getFilteredCopy(function(AbstractFacetItem $item) {
return $item->getSelected();
});
}
Expand Down
8 changes: 4 additions & 4 deletions Classes/Domain/Search/ResultSet/Facets/FacetCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function addFacet(AbstractFacet $facet): void
public function getUsed(): AbstractCollection
{
return $this->getFilteredCopy(
function (AbstractFacet $facet) {
function(AbstractFacet $facet) {
return $facet->getIsUsed() && $facet->getIncludeInUsedFacets();
}
);
Expand All @@ -41,7 +41,7 @@ function (AbstractFacet $facet) {
public function getAvailable(): AbstractCollection
{
return $this->getFilteredCopy(
function (AbstractFacet $facet) {
function(AbstractFacet $facet) {
return $facet->getIsAvailable() && $facet->getIncludeInAvailableFacets() && $facet->getAllRequirementsMet();
}
);
Expand All @@ -50,7 +50,7 @@ function (AbstractFacet $facet) {
public function getByGroupName(string $requiredGroup = 'all'): AbstractCollection
{
return $this->getFilteredCopy(
function (AbstractFacet $facet) use ($requiredGroup) {
function(AbstractFacet $facet) use ($requiredGroup) {
return $facet->getGroupName() == $requiredGroup;
}
);
Expand All @@ -59,7 +59,7 @@ function (AbstractFacet $facet) use ($requiredGroup) {
public function getByName(string $requiredName): AbstractCollection
{
return $this->getFilteredCopy(
function (AbstractFacet $facet) use ($requiredName) {
function(AbstractFacet $facet) use ($requiredName) {
return $facet->getName() == $requiredName;
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ protected function getPathAsArray(string $path): array
$path = str_replace('\/', '@@@', $path);
$path = rtrim($path, '/');
$segments = explode('/', $path);
return array_map(static function ($item) {
return array_map(static function($item) {
return str_replace('@@@', '/', $item);
}, $segments);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class HierarchyTool
*/
public static function substituteSlashes(string $pathWithContentSlashes): string
{
return (string)str_replace('\/', '@@@slash@@@', $pathWithContentSlashes);
return (string)str_replace('\/', '@@@slash@@@', $pathWithContentSlashes);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function getLowercaseLabelPrefixes(int $length = 1): array
*/
public function getByLowercaseLabelPrefix(string $filteredPrefix): AbstractCollection|AbstractFacetItemCollection|OptionCollection
{
return $this->getFilteredCopy(function (Option $option) use ($filteredPrefix) {
return $this->getFilteredCopy(function(Option $option) use ($filteredPrefix) {
$filteredPrefixLength = mb_strlen($filteredPrefix);
$currentPrefix = mb_substr(mb_strtolower($option->getLabel()), 0, $filteredPrefixLength);

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 @@ -136,11 +136,11 @@ public function getActiveFacetNames(): array
$facetNames = [];

if ($this->parameterStyle === self::PARAMETER_STYLE_INDEX) {
array_map(static function ($activeFacet) use (&$facetNames) {
array_map(static function($activeFacet) use (&$facetNames) {
$facetNames[] = substr($activeFacet, 0, strpos($activeFacet, ':'));
}, $activeFacets);
} else {
array_map(static function ($activeFacet) use (&$facetNames) {
array_map(static function($activeFacet) use (&$facetNames) {
$facetNames[] = substr($activeFacet, 0, strpos($activeFacet, ':'));
}, array_keys($activeFacets));
}
Expand All @@ -158,7 +158,7 @@ public function getActiveFacetValuesByName(string $facetName): array
if ($this->parameterStyle === self::PARAMETER_STYLE_ASSOC) {
$activeFacets = array_keys($activeFacets);
}
array_map(static 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 @@ -270,7 +270,7 @@ public function removeAllFacetValuesByName(string $facetName): UrlFacetContainer
$filterOptions = ARRAY_FILTER_USE_KEY;
}

$facetValues = array_filter($facetValues, static 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 @@ -52,7 +52,7 @@ public function getSortFieldFromUrlParameter(string $urlParameters): string
$sortFields = [];
$sortParameters = GeneralUtility::trimExplode(',', $urlParameters);

$removeTsKeyDot = static 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
6 changes: 3 additions & 3 deletions Classes/Domain/Search/Uri/SearchUriBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,10 @@ protected function buildLinkWithInMemoryCache(?int $pageUid, array $arguments):
}
}

$keys = array_map(static function ($value) {
$keys = array_map(static function($value) {
return urlencode((string)$value);
}, array_keys($values));
$values = array_map(static function ($value) {
$values = array_map(static function($value) {
return urlencode((string)$value);
}, $values);

Expand Down Expand Up @@ -336,7 +336,7 @@ protected function buildLinkWithInMemoryCache(?int $pageUid, array $arguments):

$values = $variableEvent->getVariableValues();
// Take care that everything is urlencoded!
$keys = array_map(static function ($value) {
$keys = array_map(static function($value) {
if (!str_contains($value, '###')) {
return $value;
}
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 @@ -229,7 +229,7 @@ protected function buildTypo3ManagedSite(array $rootPageRecord): ?Site
$siteHash = $this->getSiteHashForDomain($domain);
$defaultLanguage = $typo3Site->getDefaultLanguage()->getLanguageId();
$pageRepository = GeneralUtility::makeInstance(PagesRepository::class);
$availableLanguageIds = array_map(static 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 @@ -254,7 +254,7 @@ public function getTsfeByPageIdIgnoringLanguage(int $pageId): ?TypoScriptFronten
} catch (Throwable $e) {
return null;
}
$availableLanguageIds = array_map(static function ($siteLanguage) {
$availableLanguageIds = array_map(static function($siteLanguage) {
return $siteLanguage->getLanguageId();
}, $typo3Site->getLanguages());

Expand Down
2 changes: 1 addition & 1 deletion Classes/IndexQueue/FrontendHelper/UserGroupDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ protected function getFrontendGroups(): array
$frontendGroups = array_unique($frontendGroups);
$frontendGroups = array_filter(
array_values($frontendGroups),
static fn(int $val): bool => ($val !== -1)
static fn (int $val): bool => ($val !== -1)
);

if (empty($frontendGroups)) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/IndexQueue/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ protected function isRootPageIdPartOfRootLine(Item $item): bool
$rootlineUtility = GeneralUtility::makeInstance(RootlineUtility::class, $buildRootlineWithPid);
$rootline = $rootlineUtility->get();

$pageInRootline = array_filter($rootline, static 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 @@ -415,7 +415,7 @@ public function getQueryParameterMap(): array
$self = $this;
return array_filter(
$this->settings['query']['map'],
static 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 @@ -111,13 +111,13 @@ public function getAvailablePluginNamespaces(): array
public function getCacheHashExcludedParameters(): array
{
$pluginNamespaces = array_map(
static function ($pluginNamespace) {
static function($pluginNamespace) {
return '^' . $pluginNamespace . '[';
},
$this->getAvailablePluginNamespaces()
);
$enhancersRouteParts = array_map(
static function ($pluginNamespace) {
static function($pluginNamespace) {
// __ \TYPO3\CMS\Core\Routing\Enhancer\VariableProcessor::LEVEL_DELIMITER
return '^' . $pluginNamespace . '__';
},
Expand Down
4 changes: 2 additions & 2 deletions Classes/System/Solr/Service/AbstractSolrService.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function __toString()
return $endpoint->getCoreBaseUri();
} catch (Throwable) {
}
return $endpoint->getScheme() . '://' . $endpoint->getHost() . ':' . $endpoint->getPort() . $endpoint->getPath() . '/' . $endpoint->getCore() . '/';
return $endpoint->getScheme() . '://' . $endpoint->getHost() . ':' . $endpoint->getPort() . $endpoint->getPath() . '/' . $endpoint->getCore() . '/';
}

public function getPrimaryEndpoint(): Endpoint
Expand Down Expand Up @@ -119,7 +119,7 @@ protected function _sendRawPost(
string $rawPost,
string $contentType = 'text/xml; charset=UTF-8'
): ResponseAdapter {
$initializeRequest = function (Request $request) use ($rawPost, $contentType) {
$initializeRequest = function(Request $request) use ($rawPost, $contentType) {
$request->setRawData($rawPost);
$request->addHeader('Content-Type: ' . $contentType);
return $request;
Expand Down
4 changes: 2 additions & 2 deletions Classes/System/UserFunctions/FlexFormUserFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ protected function getParsedSolrFieldsFromSchema(array $configuredFacets, array
{
$newItems = [];

array_map(function ($fieldName) use (&$newItems, $configuredFacets) {
array_map(function($fieldName) use (&$newItems, $configuredFacets) {
$value = $fieldName;
$label = $fieldName;

$facetNameFilter = static 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 Classes/Task/EventQueueWorkerTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function getLimit(): int
*/
protected function getSolrLogManager(): SolrLogManager
{
return GeneralUtility::makeInstance(SolrLogManager::class, __CLASS__);
return GeneralUtility::makeInstance(SolrLogManager::class, __CLASS__);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function canFindItemsAndModifyViaEventListener(): void
self::assertSame(2, count($items));
self::assertSame('pages', $firstItem->getType(), 'First item has unexpected type');

$eventDispatcher->addListener(function (AfterRecordsForIndexQueueItemsHaveBeenRetrievedEvent $event): void {
$eventDispatcher->addListener(function(AfterRecordsForIndexQueueItemsHaveBeenRetrievedEvent $event): void {
if ($event->getTable() === 'pages') {
$event->setRecords([]);
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/Integration/IndexQueue/PageIndexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ public function canIndexPageWithAccessProtectedContentIntoSolr(
$this->cleanUpSolrServerAndAssertEmpty($core);
$this->importCSVDataSet(__DIR__ . '/Fixtures/' . $fixture . '.csv');

$createPageIndexerMock = function (): PageIndexerRequest {
$createPageIndexerMock = function(): PageIndexerRequest {
$requestMock = $this->getMockBuilder(PageIndexerRequest::class)
->onlyMethods(['send'])
->getMock();
$sendCallback = function ($indexRequestUrl) use ($requestMock): PageIndexerResponse {
$sendCallback = function($indexRequestUrl) use ($requestMock): PageIndexerResponse {
return $this->sendPageIndexerRequest($indexRequestUrl, $requestMock);
};
$requestMock->method('send')->willReturnCallback($sendCallback);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Integration/IntegrationTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ private function importRootPagesAndTemplatesForConfiguredSites(): void
protected function failWhenSolrDeprecationIsCreated(): ?callable
{
error_reporting(error_reporting() & ~E_USER_DEPRECATED);
return set_error_handler(function (int $id, string $msg, string $file, int $line): bool {
return set_error_handler(function(int $id, string $msg, string $file, int $line): bool {
if ($id === E_USER_DEPRECATED && str_starts_with($msg, 'solr:deprecation: ')) {
$this->fail('Executed deprecated EXT:solr code: ' . $msg);
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Integration/Report/SolrVersionStatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function canGetAGreenSolrConfigStatusAgainstTestServer(): void
self::assertEmpty(
array_filter(
$results,
static fn(Status $status): bool => $status->getSeverity() !== ContextualFeedbackSeverity::OK
static fn (Status $status): bool => $status->getSeverity() !== ContextualFeedbackSeverity::OK
),
'We expect to get no violations against the test Solr server '
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function requeueDocumentActionIsTriggeringReIndexOnIndexQueue(): void
#[Test]
public function hookIsTriggeredWhenRegistered(): void
{
$this->eventDispatcher->addListener(function (AfterIndexQueueItemHasBeenMarkedForReindexingEvent $event) {
$this->eventDispatcher->addListener(function(AfterIndexQueueItemHasBeenMarkedForReindexingEvent $event) {
$event->setUpdateCount(5);
});

Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/Domain/Index/IndexServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function testServerHostIsRestoredInCaseOfAnException(): void
->disableOriginalConstructor()
->onlyMethods(['index'])
->getMock();
$indexerMock->expects(self::exactly(2))->method('index')->willReturnCallback(function () {
$indexerMock->expects(self::exactly(2))->method('index')->willReturnCallback(function() {
throw new Exception('unknown error occurred');
});
$indexService->expects(self::exactly(2))->method('getIndexerByItem')->willReturn($indexerMock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function allIndexConfigurationsAreUsedWhenWildcardIsPassed(): void
$service
->expects($matcher)
->method('executeInitializer')
->willReturnCallback(static function () use ($siteMock, $fakeTs, $matcher): bool {
->willReturnCallback(static function() use ($siteMock, $fakeTs, $matcher): bool {
match ($matcher->numberOfInvocations()) {
1 => self::assertEquals(
func_get_args(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public function handlePageUpdateTriggersRecursivePageProcessing(): void
$this->indexQueueMock
->expects($matcher)
->method('updateItem')
->willReturnCallback(static function (string $type, int $uid) use ($dummyPageRecord, $matcher): int {
->willReturnCallback(static function(string $type, int $uid) use ($dummyPageRecord, $matcher): int {
match ($matcher->numberOfInvocations()) {
1 => self::assertEquals(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function canHandleEvents(): void
$this->eventDispatcherMock
->expects(self::once())
->method('dispatch')
->willReturnCallback(function () use (&$dispatchedEvent) {
->willReturnCallback(function() use (&$dispatchedEvent) {
$dispatchedEvent = func_get_arg(0);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected function checkEventHandling(
$this->eventDispatcherMock
->expects(self::once())
->method('dispatch')
->willReturnCallback(function () use (&$dispatchedEvent) {
->willReturnCallback(function() use (&$dispatchedEvent) {
$dispatchedEvent = func_get_arg(0);
});
} else {
Expand Down
Loading

0 comments on commit ef0d460

Please sign in to comment.