From c568946b081ac3493d21c3bb6b5da767164e8c08 Mon Sep 17 00:00:00 2001
From: Oliver Klee <typo3-coding@oliverklee.de>
Date: Sun, 12 Mar 2023 11:10:44 +0100
Subject: [PATCH] [TASK] Modernize array function callbacks in GeneralUtility

Function callbacks are declared using the new PHP 8.1 feature
"first class callable", which e.g. uses the named `trim(...)`
function symbol, instead of the string `'trim'`.

see https://www.php.net/manual/en/functions.first_class_callable_syntax.php

Resolves: #100144
Releases: main
Change-Id: I708f86e022e397f3fcf32596043336b430e9c9ef
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78097
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../sysext/core/Classes/Utility/GeneralUtility.php | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php
index 9c8196cb6458..24f6ea1228ea 100644
--- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php
+++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php
@@ -893,7 +893,7 @@ class GeneralUtility
             return [$string];
         }
         $explodedValues = explode($delimiter, strrev($string), $limit);
-        $explodedValues = array_map('strrev', $explodedValues);
+        $explodedValues = array_map(strrev(...), $explodedValues);
         return array_reverse($explodedValues);
     }
 
@@ -918,17 +918,17 @@ class GeneralUtility
         $result = explode($delim, (string)$string);
         if ($removeEmptyValues) {
             // Remove items that are just whitespace, but leave whitespace intact for the rest.
-            $result = array_values(array_filter($result, static fn ($item) => trim($item) !== ''));
+            $result = array_values(array_filter($result, static fn (string $item): bool => trim($item) !== ''));
         }
 
         if ($limit === 0) {
             // Return everything.
-            return array_map('trim', $result);
+            return array_map(trim(...), $result);
         }
 
         if ($limit < 0) {
             // Trim and return just the first $limit elements and ignore the rest.
-            return array_map('trim', array_slice($result, 0, $limit));
+            return array_map(trim(...), array_slice($result, 0, $limit));
         }
 
         // Fold the last length - $limit elements into a single trailing item, then trim and return the result.
@@ -937,7 +937,7 @@ class GeneralUtility
         if ($tail) {
             $result[] = implode($delim, $tail);
         }
-        return array_map('trim', $result);
+        return array_map(trim(...), $result);
     }
 
     /**
@@ -2426,7 +2426,7 @@ class GeneralUtility
                 // Use rawurldecode to reverse the result of self::encodeFileSystemPathComponentForUrlPath()
                 // which has been applied to getIndpEnv(SCRIPT_NAME) for web URI usage.
                 // We compare with a file system path (SCRIPT_FILENAME) in here and therefore need to undo the encoding.
-                $SN_A = array_map('rawurldecode', explode('/', strrev(self::getIndpEnv('SCRIPT_NAME'))));
+                $SN_A = array_map(rawurldecode(...), explode('/', strrev(self::getIndpEnv('SCRIPT_NAME'))));
                 $SFN_A = explode('/', strrev($SFN));
                 $acc = [];
                 foreach ($SN_A as $kk => $vv) {
@@ -2553,7 +2553,7 @@ class GeneralUtility
 
     protected static function encodeFileSystemPathComponentForUrlPath(string $path): string
     {
-        return implode('/', array_map('rawurlencode', explode('/', $path)));
+        return implode('/', array_map(rawurlencode(...), explode('/', $path)));
     }
 
     /*************************
-- 
GitLab