Skip to content

Commit 30e48d7

Browse files
authored
Merge pull request #186 from simonschaufi/static-functions
2 parents a46b7b7 + 0cd56b4 commit 30e48d7

13 files changed

Lines changed: 26 additions & 22 deletions

Classes/Aggregate/AbstractAggregate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected function removeHiddenContentElements()
7676

7777
$this->maskConfiguration['tt_content']['elements'] = array_filter(
7878
$this->maskConfiguration['tt_content']['elements'],
79-
function (array $element) {
79+
static function (array $element) {
8080
return empty($element['hidden']);
8181
}
8282
);
@@ -93,7 +93,7 @@ protected function removeCoreFields()
9393
}
9494
$this->maskConfiguration[$table]['tca'] = array_filter(
9595
$this->maskConfiguration[$table]['tca'],
96-
function ($field) {
96+
static function ($field) {
9797
return empty($field['coreField']);
9898
}
9999
);

Classes/Aggregate/ContentRenderingAggregate.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,12 @@ protected function addDatabaseQueryProcessorForField($table, $columnName, $index
245245
$overrideColumns = $GLOBALS['TCA'][$table]['columns'][$columnName]['config']['foreign_record_defaults'];
246246
} elseif (!empty($GLOBALS['TCA'][$table]['columns'][$columnName]['config']['overrideChildTca']['columns'])) {
247247
$overrideColumns = array_map(
248-
function ($value) {
248+
static function ($value) {
249249
return $value['config']['default'];
250250
},
251251
array_filter(
252252
$GLOBALS['TCA'][$table]['columns'][$columnName]['config']['overrideChildTca']['columns'],
253-
function ($item) {
253+
static function ($item) {
254254
return isset($item['config']['default']);
255255
}
256256
)
@@ -267,7 +267,7 @@ function ($item) {
267267
if (!empty($this->maskConfiguration[$table]['tca'][$columnName]['cTypes'])) {
268268
$types = array_combine(
269269
array_map(
270-
function ($value) {
270+
static function ($value) {
271271
return 'CType' . $value;
272272
},
273273
range(1, count($this->maskConfiguration[$table]['tca'][$columnName]['cTypes']))
@@ -285,7 +285,7 @@ function ($value) {
285285

286286
uksort($markerArray, 'strnatcasecmp');
287287
$markers = implode("\n ", array_map(
288-
function ($key, $value) {
288+
static function ($key, $value) {
289289
return 'markers.' . $key . (strpos($key, '.') === false ? '.value' : '') . ' = ' . $value;
290290
},
291291
array_keys($markerArray),

Classes/Aggregate/InlineContentCTypeAggregate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function addData(array \$result)
111111
112112
\$result['processedTca']['columns']['CType']['config']['items'] = array_filter(
113113
\$result['processedTca']['columns']['CType']['config']['items'],
114-
function (\$item) use (\$cTypes) {
114+
static function (\$item) use (\$cTypes) {
115115
return in_array(\$item[1], \$cTypes);
116116
}
117117
);

Classes/Aggregate/InlineContentColPosAggregate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected function process()
6363
);
6464

6565
$flattenedInlineFields = [];
66-
array_walk_recursive($inlineFields, function ($field) use (&$flattenedInlineFields) {
66+
array_walk_recursive($inlineFields, static function ($field) use (&$flattenedInlineFields) {
6767
$flattenedInlineFields[] = $field . '_parent';
6868
});
6969
sort($flattenedInlineFields);

Classes/Aggregate/TtContentOverridesAggregate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected function addTableTypes(array $tableConfiguration)
5555
$newTypeFields = array_intersect_key(
5656
$tableConfiguration['types'],
5757
array_combine(
58-
array_map(function ($value) {
58+
array_map(static function ($value) {
5959
return 'mask_' . $value;
6060
}, $types),
6161
$types

Classes/Controller/ExportController.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ protected function prepareConfiguration(string $vendorName, string $extensionNam
348348
// Find all used fields in elements and foreign tables
349349
$columns = [];
350350
$closure = null;
351-
$closure = function ($value) use ($aggregatedConfiguration, &$columns, &$closure) {
351+
$closure = static function ($value) use ($aggregatedConfiguration, &$columns, &$closure) {
352352
foreach (($value['columns'] ?? []) as $field) {
353353
$columns[] = $field;
354354
if (!empty($aggregatedConfiguration[$field]['tca'])) {
@@ -510,17 +510,21 @@ protected function replaceExtensionKey($vendorName, $extensionKey, $string)
510510
*/
511511
protected function sortFiles(array $files)
512512
{
513-
uksort($files, function ($a, $b) {
513+
uksort($files, static function ($a, $b) {
514514
if (substr_count($a, '/') === 0 && substr_count($b, '/') > 0) {
515515
return -1;
516-
} elseif (substr_count($a, '/') > 0 && substr_count($b, '/') === 0) {
516+
}
517+
518+
if (substr_count($a, '/') > 0 && substr_count($b, '/') === 0) {
517519
return 1;
518520
}
519521

520522
if (strpos($b, dirname($a)) === 0 || strpos($a, dirname($b)) === 0) {
521523
if (substr_count($a, '/') > substr_count($b, '/')) {
522524
return 1;
523-
} elseif (substr_count($a, '/') < substr_count($b, '/')) {
525+
}
526+
527+
if (substr_count($a, '/') < substr_count($b, '/')) {
524528
return -1;
525529
}
526530
}

Classes/FileCollection/SqlFileCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected function processAggregateCollection()
7575
unset($aggregatedFields['KEY ' . $index]);
7676
}
7777

78-
array_walk($aggregatedFields, function (&$definition, $field) {
78+
array_walk($aggregatedFields, static function (&$definition, $field) {
7979
$definition = sprintf(' %s %s', $field, $definition);
8080
});
8181
$fieldDefinitions = implode(',' . PHP_EOL, $aggregatedFields);

Classes/FlagResolver/AbstractFlagResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(DependencyOrderingService $dependencyOrderingService
4343
public function resolveFlags(array $fileInformation)
4444
{
4545
$files = array_map(
46-
function ($information) {
46+
static function ($information) {
4747
return $information['content'];
4848
},
4949
$fileInformation

Classes/FlagResolver/PhpFileFlag/ClosureFunctionFlag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function isEnabled($flags)
3434
public function execute($content)
3535
{
3636
return <<<EOS
37-
call_user_func(function () {
37+
call_user_func(static function () {
3838
3939
{$content}
4040
});

Tests/Functional/Controller/BackendPreview/ExportControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function validateProcessedRowDataFromPageLayoutViewDrawItem()
111111
$subject->preProcess($pageLayoutView, $drawItem, $headerContent, $itemContent, $row);
112112

113113
// Get variable container
114-
$closure = \Closure::bind(function () use ($viewMock) {
114+
$closure = \Closure::bind(static function () use ($viewMock) {
115115
return $viewMock->baseRenderingContext;
116116
}, null, StandaloneView::class);
117117
$renderingContext = $closure();

0 commit comments

Comments
 (0)