[TASK] Merge str_replace calls when applied to a variable sequentially 46/57246/3
authorWouter Wolters <typo3@wouterwolters.nl>
Sun, 17 Jun 2018 14:44:59 +0000 (16:44 +0200)
committerBenni Mack <benni@typo3.org>
Mon, 18 Jun 2018 05:02:43 +0000 (07:02 +0200)
Resolves: #85291
Releases: master
Change-Id: Ia8db330043ccd2d123be8d6257189774969a951c
Reviewed-on: https://review.typo3.org/57246
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Stefan Bürk <stefan.buerk@pure-metal.de>
Tested-by: Stefan Bürk <stefan.buerk@pure-metal.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/backend/Classes/Controller/Wizard/TableController.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php
typo3/sysext/core/Classes/Utility/ArrayUtility.php
typo3/sysext/extbase/Classes/Property/TypeConverter/FloatConverter.php
typo3/sysext/fluid/Classes/ViewHelpers/Debug/RenderViewHelper.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/frontend/Tests/Functional/ContentObject/ContentObjectRendererTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
typo3/sysext/install/Classes/Service/LocalConfigurationValueService.php
typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php

index 33c639a..4febd5f 100644 (file)
@@ -734,9 +734,9 @@ class TableController extends AbstractWizardController
         foreach ($this->TABLECFG['c'] as $a => $value) {
             foreach ($this->TABLECFG['c'][$a] as $b => $value2) {
                 $this->TABLECFG['c'][$a][$b] = str_replace(
-                    LF,
-                    '<br />',
-                    str_replace(CR, '', $this->TABLECFG['c'][$a][$b])
+                    [CR, LF],
+                    ['', '<br />'],
+                    $this->TABLECFG['c'][$a][$b]
                 );
             }
         }
index d86b933..9068afb 100644 (file)
@@ -1202,7 +1202,7 @@ class TcaSelectItemsTest extends UnitTestCase
 
         $result = (new TcaSelectItems)->addData($input);
 
-        $result['processedTca']['columns']['aField']['config']['items'][0][2] = str_replace([CR, LF, TAB], ['', '', ''], $result['processedTca']['columns']['aField']['config']['items'][0][2]);
+        $result['processedTca']['columns']['aField']['config']['items'][0][2] = str_replace([CR, LF, TAB], '', $result['processedTca']['columns']['aField']['config']['items'][0][2]);
         $this->assertSame($expectedItems, $result['processedTca']['columns']['aField']['config']['items']);
     }
 
index a7dc068..9f23f82 100644 (file)
@@ -431,9 +431,8 @@ class ArrayUtility
                 $lines .= ',' . LF;
             } elseif (is_string($value)) {
                 // Quote \ to \\
-                $stringContent = str_replace('\\', '\\\\', $value);
                 // Quote ' to \'
-                $stringContent = str_replace('\'', '\\\'', $stringContent);
+                $stringContent = str_replace(['\\', '\''], ['\\\\', '\\\''], $value);
                 $lines .= '\'' . $stringContent . '\'' . ',' . LF;
             } else {
                 throw new \RuntimeException('Objects are not supported', 1342294987);
index b13be33..ef98559 100644 (file)
@@ -75,8 +75,7 @@ class FloatConverter extends \TYPO3\CMS\Extbase\Property\TypeConverter\AbstractT
         if (is_string($source) && $configuration !== null) {
             $thousandsSeparator = $configuration->getConfigurationValue(self::class, self::CONFIGURATION_THOUSANDS_SEPARATOR);
             $decimalPoint = $configuration->getConfigurationValue(self::class, self::CONFIGURATION_DECIMAL_POINT);
-            $source = str_replace($thousandsSeparator, '', $source);
-            $source = str_replace($decimalPoint, '.', $source);
+            $source = str_replace([$thousandsSeparator, $decimalPoint], ['', '.'], $source);
         }
 
         if (!is_numeric($source)) {
index 0c386e4..0fdbe40 100644 (file)
@@ -106,8 +106,7 @@ class RenderViewHelper extends AbstractViewHelper
         if (isset($this->arguments['partial'])) {
             $path = $this->renderingContext->getTemplatePaths()->getPartialPathAndFilename($partial);
             $path = PathUtility::stripPathSitePrefix($path);
-            $path = str_replace('typo3conf/ext/', 'EXT:', $path);
-            $path = str_replace('typo3/sysext/', 'EXT:', $path);
+            $path = str_replace(['typo3conf/ext/', 'typo3/sysext/'], 'EXT:', $path);
             $debugInfo['Partial'] = 'Partial: ' . $path;
         }
         if (isset($this->arguments['section'])) {
index 3f03d38..2787921 100644 (file)
@@ -3045,8 +3045,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface
                If this message does not disappear within ' . $seconds . ' seconds, please reload.';
             $message = $this->config['config']['message_page_is_being_generated'];
             if ((string)$message !== '') {
-                $message = str_replace('###TITLE###', $title, $message);
-                $message = str_replace('###REQUEST_URI###', $request_uri, $message);
+                $message = str_replace(['###TITLE###', '###REQUEST_URI###'], [$title, $request_uri], $message);
             } else {
                 $message = $stdMsg;
             }
index 88448d6..6fb0cc8 100644 (file)
@@ -189,8 +189,7 @@ class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Functional\
                 // Replace the MySQL backtick quote character with the actual quote character for the DBMS,
                 if ($field === 'SELECT') {
                     $quoteChar = $databasePlatform->getIdentifierQuoteCharacter();
-                    $value = str_replace('[', $quoteChar, $value);
-                    $value = str_replace(']', $quoteChar, $value);
+                    $value = str_replace(['[', ']'], [$quoteChar, $quoteChar], $value);
                 }
             }
             $this->assertEquals($value, $result[$field]);
index 74c8ef1..8906c2d 100644 (file)
@@ -1614,10 +1614,7 @@ class ContentObjectRendererTest extends UnitTestCase
 
         DebugUtility::useAnsiColor(false);
         $result = $this->subject->getData('debug:rootLine');
-        $cleanedResult = str_replace("\r", '', $result);
-        $cleanedResult = str_replace("\n", '', $cleanedResult);
-        $cleanedResult = str_replace("\t", '', $cleanedResult);
-        $cleanedResult = str_replace(' ', '', $cleanedResult);
+        $cleanedResult = str_replace(["\r", "\n", "\t", ' '], '', $result);
 
         $this->assertEquals($expectedResult, $cleanedResult);
     }
@@ -1639,10 +1636,7 @@ class ContentObjectRendererTest extends UnitTestCase
 
         DebugUtility::useAnsiColor(false);
         $result = $this->subject->getData('debug:fullRootLine');
-        $cleanedResult = str_replace("\r", '', $result);
-        $cleanedResult = str_replace("\n", '', $cleanedResult);
-        $cleanedResult = str_replace("\t", '', $cleanedResult);
-        $cleanedResult = str_replace(' ', '', $cleanedResult);
+        $cleanedResult = str_replace(["\r", "\n", "\t", ' '], '', $result);
 
         $this->assertEquals($expectedResult, $cleanedResult);
     }
@@ -1662,10 +1656,7 @@ class ContentObjectRendererTest extends UnitTestCase
 
         DebugUtility::useAnsiColor(false);
         $result = $this->subject->getData('debug:data');
-        $cleanedResult = str_replace("\r", '', $result);
-        $cleanedResult = str_replace("\n", '', $cleanedResult);
-        $cleanedResult = str_replace("\t", '', $cleanedResult);
-        $cleanedResult = str_replace(' ', '', $cleanedResult);
+        $cleanedResult = str_replace(["\r", "\n", "\t", ' '], '', $result);
 
         $this->assertEquals($expectedResult, $cleanedResult);
     }
@@ -1685,10 +1676,7 @@ class ContentObjectRendererTest extends UnitTestCase
 
         DebugUtility::useAnsiColor(false);
         $result = $this->subject->getData('debug:register');
-        $cleanedResult = str_replace("\r", '', $result);
-        $cleanedResult = str_replace("\n", '', $cleanedResult);
-        $cleanedResult = str_replace("\t", '', $cleanedResult);
-        $cleanedResult = str_replace(' ', '', $cleanedResult);
+        $cleanedResult = str_replace(["\r", "\n", "\t", ' '], '', $result);
 
         $this->assertEquals($expectedResult, $cleanedResult);
     }
@@ -1707,10 +1695,7 @@ class ContentObjectRendererTest extends UnitTestCase
 
         DebugUtility::useAnsiColor(false);
         $result = $this->subject->getData('debug:page');
-        $cleanedResult = str_replace("\r", '', $result);
-        $cleanedResult = str_replace("\n", '', $cleanedResult);
-        $cleanedResult = str_replace("\t", '', $cleanedResult);
-        $cleanedResult = str_replace(' ', '', $cleanedResult);
+        $cleanedResult = str_replace(["\r", "\n", "\t", ' '], '', $result);
 
         $this->assertEquals($expectedResult, $cleanedResult);
     }
index 756ae0b..d01e32e 100644 (file)
@@ -168,9 +168,8 @@ class LocalConfigurationValueService
 
             if ($dataType === 'multiline') {
                 // Force Unix line breaks in text areas
-                $value = str_replace(CR, '', $value);
                 // Preserve line breaks
-                $value = str_replace(LF, '\' . LF . \'', $value);
+                $value = str_replace([CR, LF], ['', '\' . LF . \''], $value);
             }
 
             if ($dataType === 'bool') {
index a241977..c51c9ac 100644 (file)
@@ -291,7 +291,7 @@ class BrowseLinksController extends AbstractLinkBrowserController
         } else {
             $label = $this->getLanguageService()->sL(trim($string));
         }
-        $label = str_replace('"', '\\"', str_replace('\\\'', '\'', $label));
+        $label = str_replace(['\\\'', '"'], ['\'', '\\"'], $label);
         return $JScharCode ? GeneralUtility::quoteJSvalue($label) : $label;
     }