[TASK] CGL-Fix: Generic.CodeAnalysis.ForLoopWithTestFunctionCall
authorAndy Grunwald <andygrunwald@gmail.com>
Sat, 22 Sep 2012 11:17:37 +0000 (13:17 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 22 Sep 2012 12:16:14 +0000 (14:16 +0200)
Change-Id: Iec697701e0db5418ac9b12692e5946b0ff11e628
Fixes: #41248
Releases: 6.0
Reviewed-on: http://review.typo3.org/14911
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
16 files changed:
t3lib/class.t3lib_install.php
typo3/sysext/backend/Classes/Controller/BackendLayoutWizardController.php
typo3/sysext/backend/Classes/Form/FormEngine.php
typo3/sysext/backend/Classes/Utility/IconUtility.php
typo3/sysext/core/Classes/Charset/CharsetConverter.php
typo3/sysext/core/Classes/Database/PreparedStatement.php
typo3/sysext/core/Classes/Database/QueryGenerator.php
typo3/sysext/core/Classes/Html/RteHtmlParser.php
typo3/sysext/core/Classes/Mail/Rfc822AddressesParser.php
typo3/sysext/core/Classes/TypoScript/ExtendedTemplateService.php
typo3/sysext/core/Classes/Utility/DiffUtility.php
typo3/sysext/core/Classes/Utility/VersionNumberUtility.php
typo3/sysext/css_styled_content/Classes/Controller/CssStyledContentController.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/indexed_search/Classes/Utility/DoubleMetaPhoneUtility.php

index 75451ce..d3ec080 100644 (file)
@@ -158,7 +158,8 @@ class t3lib_install {
                $lines = explode('
 ', var_export($variable, TRUE));
                $out = 'array(';
-               for ($i = 1; $i < count($lines); $i++) {
+               $lineCount = count($lines);
+               for ($i = 1; $i < $lineCount; $i++) {
                        $out .= '
 ';
                        // Make the space-indented declaration tab-indented instead
index 0af16dc..21d511c 100644 (file)
@@ -104,21 +104,24 @@ class BackendLayoutWizardController {
                                                        $cellData = array();
                                                        if (isset($column['colspan'])) {
                                                                $cellData[] = 'colspan:' . intval($column['colspan']);
+                                                               $columnColSpan = intval($column['colspan']);
                                                                if (isset($column['rowspan'])) {
-                                                                       for ($spanRow = 0; $spanRow < intval($column['rowspan']); $spanRow++) {
-                                                                               for ($spanColumn = 0; $spanColumn < intval($column['colspan']); $spanColumn++) {
+                                                                       $columnRowSpan = intval($column['rowspan']);
+                                                                       for ($spanRow = 0; $spanRow < $columnRowSpan; $spanRow++) {
+                                                                               for ($spanColumn = 0; $spanColumn < $columnColSpan; $spanColumn++) {
                                                                                        $spannedMatrix[$i + $spanRow][$j + $spanColumn] = 1;
                                                                                }
                                                                        }
                                                                } else {
-                                                                       for ($spanColumn = 0; $spanColumn < intval($column['colspan']); $spanColumn++) {
+                                                                       for ($spanColumn = 0; $spanColumn < $columnColSpan; $spanColumn++) {
                                                                                $spannedMatrix[$i][$j + $spanColumn] = 1;
                                                                        }
                                                                }
                                                        } else {
                                                                $cellData[] = 'colspan:1';
                                                                if (isset($column['rowspan'])) {
-                                                                       for ($spanRow = 0; $spanRow < intval($column['rowspan']); $spanRow++) {
+                                                                       $columnRowSpan = intval($column['rowspan']);
+                                                                       for ($spanRow = 0; $spanRow < $columnRowSpan; $spanRow++) {
                                                                                $spannedMatrix[$i + $spanRow][$j] = 1;
                                                                        }
                                                                }
index c3b147f..be003fe 100644 (file)
@@ -1516,9 +1516,10 @@ function ' . $evalData . '(value) {
                }
                $thisValue = intval($PA['itemFormElValue']);
                $cols = intval($config['cols']);
+               $selItemsCount = count($selItems);
                if ($cols > 1) {
                        $item .= '<table border="0" cellspacing="0" cellpadding="0" class="typo3-TCEforms-checkboxArray">';
-                       for ($c = 0; $c < count($selItems); $c++) {
+                       for ($c = 0; $c < $selItemsCount; $c++) {
                                $p = $selItems[$c];
                                if (!($c % $cols)) {
                                        $item .= '<tr>';
@@ -1542,7 +1543,7 @@ function ' . $evalData . '(value) {
                        }
                        $item .= '</table>';
                } else {
-                       for ($c = 0; $c < count($selItems); $c++) {
+                       for ($c = 0; $c < $selItemsCount; $c++) {
                                $p = $selItems[$c];
                                $cBP = $this->checkBoxParams($PA['itemFormElName'], $thisValue, $c, count($selItems), implode('', $PA['fieldChangeFunc']));
                                $cBName = $PA['itemFormElName'] . '_' . $c;
@@ -1580,7 +1581,8 @@ function ' . $evalData . '(value) {
                        $selItems = $this->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
                }
                // Traverse the items, making the form elements:
-               for ($c = 0; $c < count($selItems); $c++) {
+               $selItemsCount = count($selItems);
+               for ($c = 0; $c < $selItemsCount; $c++) {
                        $p = $selItems[$c];
                        $rID = $PA['itemFormElID'] . '_' . $c;
                        $rOnClick = implode('', $PA['fieldChangeFunc']);
index 3ffe52f..b66cf86 100644 (file)
@@ -397,7 +397,8 @@ class IconUtility {
                                        }
                                        // Converting to gray scale, dimming the icon:
                                        if ($mode == 'disabled' or $mode != 'futuretiming' && $mode != 'no_icon_found' && !(!$mode && $user)) {
-                                               for ($c = 0; $c < ImageColorsTotal($im); $c++) {
+                                               $totalImageColors = ImageColorsTotal($im);
+                                               for ($c = 0; $c < $totalImageColors; $c++) {
                                                        $cols = ImageColorsForIndex($im, $c);
                                                        $newcol = round(($cols['red'] + $cols['green'] + $cols['blue']) / 3);
                                                        $lighten = $mode == 'disabled' ? 2.5 : 2;
index 01f9d78..e7a1a11 100644 (file)
@@ -1485,10 +1485,14 @@ class CharsetConverter {
                        }
                }
                // Add the ASCII case table
-               for ($i = ord('a'); $i <= ord('z'); $i++) {
+               $start = ord('a');
+               $end = ord('z');
+               for ($i = $start; $i <= $end; $i++) {
                        $this->caseFolding[$charset]['toUpper'][chr($i)] = chr($i - 32);
                }
-               for ($i = ord('A'); $i <= ord('Z'); $i++) {
+               $start = ord('A');
+               $end = ord('Z');
+               for ($i = $start; $i <= $end; $i++) {
                        $this->caseFolding[$charset]['toLower'][chr($i)] = chr($i + 32);
                }
                if ($cacheFile) {
index b3928bb..5e31fc7 100644 (file)
@@ -468,7 +468,8 @@ class PreparedStatement {
                                        $query = implode('', $parts);
                                }
                        } else {
-                               for ($i = 1; $i < count($precompiledQueryParts['queryParts']); $i++) {
+                               $queryPartsCount = count($precompiledQueryParts['queryParts']);
+                               for ($i = 1; $i < $queryPartsCount; $i++) {
                                        if ($precompiledQueryParts['queryParts'][$i] === $key) {
                                                $precompiledQueryParts['queryParts'][$i] = $value;
                                        }
index 436dca4..eb805fe 100644 (file)
@@ -440,12 +440,14 @@ class QueryGenerator {
                        // Initialize array to work on, save special parameters
                        $ssArr = $this->getSubscript($POST['qG_del']);
                        $workArr =& $this->queryConfig;
-                       for ($i = 0; $i < sizeof($ssArr) - 1; $i++) {
+                       $ssArrSize = sizeof($ssArr) - 1;
+                       for ($i = 0; $i < $ssArrSize; $i++) {
                                $workArr =& $workArr[$ssArr[$i]];
                        }
                        // Delete the entry and move the other entries
                        unset($workArr[$ssArr[$i]]);
-                       for ($j = $ssArr[$i]; $j < sizeof($workArr); $j++) {
+                       $workArrSize = sizeof($workArr);
+                       for ($j = $ssArr[$i]; $j < $workArrSize; $j++) {
                                $workArr[$j] = $workArr[$j + 1];
                                unset($workArr[$j + 1]);
                        }
@@ -455,11 +457,13 @@ class QueryGenerator {
                        // Initialize array to work on, save special parameters
                        $ssArr = $this->getSubscript($POST['qG_ins']);
                        $workArr =& $this->queryConfig;
-                       for ($i = 0; $i < sizeof($ssArr) - 1; $i++) {
+                       $ssArrSize = sizeof($ssArr) - 1;
+                       for ($i = 0; $i < $ssArrSize; $i++) {
                                $workArr =& $workArr[$ssArr[$i]];
                        }
                        // Move all entries above position where new entry is to be inserted
-                       for ($j = sizeof($workArr); $j > $ssArr[$i]; $j--) {
+                       $workArrSize = sizeof($workArr);
+                       for ($j = $workArrSize; $j > $ssArr[$i]; $j--) {
                                $workArr[$j] = $workArr[$j - 1];
                        }
                        // Clear new entry position
@@ -471,7 +475,8 @@ class QueryGenerator {
                        // Initialize array to work on
                        $ssArr = $this->getSubscript($POST['qG_up']);
                        $workArr =& $this->queryConfig;
-                       for ($i = 0; $i < sizeof($ssArr) - 1; $i++) {
+                       $ssArrSize = sizeof($ssArr) - 1;
+                       for ($i = 0; $i < $ssArrSize; $i++) {
                                $workArr =& $workArr[$ssArr[$i]];
                        }
                        // Swap entries
@@ -484,7 +489,8 @@ class QueryGenerator {
                        // Initialize array to work on
                        $ssArr = $this->getSubscript($POST['qG_nl']);
                        $workArr =& $this->queryConfig;
-                       for ($i = 0; $i < sizeof($ssArr) - 1; $i++) {
+                       $ssArraySize = sizeof($ssArr) - 1;
+                       for ($i = 0; $i < $ssArraySize; $i++) {
                                $workArr =& $workArr[$ssArr[$i]];
                        }
                        // Do stuff:
@@ -504,7 +510,8 @@ class QueryGenerator {
                        // Initialize array to work on
                        $ssArr = $this->getSubscript($POST['qG_remnl']);
                        $workArr =& $this->queryConfig;
-                       for ($i = 0; $i < sizeof($ssArr) - 1; $i++) {
+                       $ssArrSize = sizeof($ssArr) - 1;
+                       for ($i = 0; $i < $ssArrSize; $i++) {
                                $workArr =& $workArr[$ssArr[$i]];
                        }
                        // Do stuff:
index eee922d..b6dbd90 100644 (file)
@@ -1625,7 +1625,8 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser {
                        $info['url'] = rawurldecode(substr($url, strpos($url, '?file:') + 1));
                } else {
                        $curURL = $this->siteUrl();
-                       for ($a = 0; $a < strlen($url); $a++) {
+                       $urlLength = strlen($url);
+                       for ($a = 0; $a < $urlLength; $a++) {
                                if ($url[$a] != $curURL[$a]) {
                                        break;
                                }
index de3be63..f08a620 100644 (file)
@@ -185,7 +185,7 @@ class Rfc822AddressesParser {
                $this->error = NULL;
                $this->index = NULL;
                // Unfold any long lines in $this->address.
-               $this->address = preg_replace('/\\r?\\n/', '\r
+               $this->address = preg_replace('/\\r?\\n/', '
 ', $this->address);
                $this->address = preg_replace('/\\r\\n(\\t| )+/', ' ', $this->address);
                while ($this->address = $this->_splitAddresses($this->address)) {
@@ -299,7 +299,8 @@ class Rfc822AddressesParser {
         */
        protected function _splitCheck($parts, $char) {
                $string = $parts[0];
-               for ($i = 0; $i < count($parts); $i++) {
+               $partsCounter = count($parts);
+               for ($i = 0; $i < $partsCounter; $i++) {
                        if ($this->_hasUnclosedQuotes($string) || $this->_hasUnclosedBrackets($string, '<>') || $this->_hasUnclosedBrackets($string, '[]') || $this->_hasUnclosedBrackets($string, '()') || substr($string, -1) == '\\') {
                                if (isset($parts[$i + 1])) {
                                        $string = $string . $char . $parts[($i + 1)];
@@ -377,7 +378,8 @@ class Rfc822AddressesParser {
         */
        protected function _hasUnclosedBracketsSub($string, &$num, $char) {
                $parts = explode($char, $string);
-               for ($i = 0; $i < count($parts); $i++) {
+               $partsCounter = count($parts);
+               for ($i = 0; $i < $partsCounter; $i++) {
                        if (substr($parts[$i], -1) == '\\' || $this->_hasUnclosedQuotes($parts[$i])) {
                                $num--;
                        }
@@ -436,7 +438,8 @@ class Rfc822AddressesParser {
                //                         geezer@domain.com
                //                         geezer
                // ... or any other format valid by RFC 822.
-               for ($i = 0; $i < count($addresses); $i++) {
+               $addressesCount = count($addresses);
+               for ($i = 0; $i < $addressesCount; $i++) {
                        if (!$this->validateMailbox($addresses[$i])) {
                                if (empty($this->error)) {
                                        $this->error = 'Validation failed for: ' . $addresses[$i];
index 6bde6d1..c508147 100644 (file)
@@ -1192,7 +1192,8 @@ class ExtendedTemplateService extends \TYPO3\CMS\Core\TypoScript\TemplateService
                                                $p_field = ($labels[0] ? $labels[0] : 'x') . ':<input type="text" name="' . $fN . '" value="' . $wArr[0] . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(4) . ' onChange="uFormUrl(' . $aname . ')" />';
                                                $p_field .= ' , ';
                                                $p_field .= ($labels[1] ? $labels[1] : 'y') . ':<input type="text" name="W' . $fN . '" value="' . $wArr[1] . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(4) . ' onChange="uFormUrl(' . $aname . ')" />';
-                                               for ($aa = 2; $aa < count($labels); $aa++) {
+                                               $labelsCount = count($labels);
+                                               for ($aa = 2; $aa < $labelsCount; $aa++) {
                                                        if ($labels[$aa]) {
                                                                $p_field .= ' , ' . $labels[$aa] . ':<input type="text" name="W' . $aa . $fN . '" value="' . $wArr[$aa] . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(4) . ' onChange="uFormUrl(' . $aname . ')" />';
                                                        } else {
index 9a155ce..50411f3 100644 (file)
@@ -107,7 +107,8 @@ class DiffUtility {
                        $this->differenceLgd = strlen($differenceStr);
                        $outString = '';
                        $clearBuffer = '';
-                       for ($a = -1; $a < count($str1Lines); $a++) {
+                       $str1LinesCount = count($str1Lines);
+                       for ($a = -1; $a < $str1LinesCount; $a++) {
                                if (is_array($diffResArray[$a + 1])) {
                                        // a=Add, c=change, d=delete: If a, then the content is Added after the entry and we must insert the line content as well.
                                        if (strstr($diffResArray[$a + 1]['changeInfo'], 'a')) {
index 515aec8..f81fee6 100644 (file)
@@ -130,9 +130,11 @@ class VersionNumberUtility {
         */
        static public function convertVersionsStringToVersionNumbers($versionsString) {
                $versions = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('-', $versionsString);
-               for ($i = 0; $i < count($versions); $i++) {
+               $versionsCount = count($versions);
+               for ($i = 0; $i < $versionsCount; $i++) {
                        $cleanedVersion = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('.', $versions[$i]);
-                       for ($j = 0; $j < count($cleanedVersion); $j++) {
+                       $cleanedVersionCount = count($cleanedVersion);
+                       for ($j = 0; $j < $cleanedVersionCount; $j++) {
                                $cleanedVersion[$j] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($cleanedVersion[$j], 0, 999);
                        }
                        $cleanedVersionString = implode('.', $cleanedVersion);
index fcce15d..8546078 100644 (file)
@@ -905,7 +905,8 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                                $thisImages = '';
                                $allRows = '';
                                $maxImageSpace = 0;
-                               for ($i = $c; $i < count($imgsTag); $i = $i + $imageWrapCols) {
+                               $imgsTagCount = count($imgsTag);
+                               for ($i = $c; $i < $imgsTagCount; $i = $i + $imageWrapCols) {
                                        $imgKey = $i + $imgStart;
                                        $colPos = $i % $colCount;
                                        if ($separateRows && $colPos == 0) {
@@ -1198,6 +1199,4 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
        }
 
 }
-
-
-?>
+?>
\ No newline at end of file
index a8c0d3a..227d20e 100644 (file)
@@ -4764,7 +4764,8 @@ class ContentObjectRenderer {
                } while ($pointer < $totalLen);
                // Parsing nonTypoTag content (all even keys):
                reset($contentAccum);
-               for ($a = 0; $a < count($contentAccum); $a++) {
+               $contentAccumCount = count($contentAccum);
+               for ($a = 0; $a < $contentAccumCount; $a++) {
                        if ($a % 2 != 1) {
                                // stdWrap
                                if (is_array($conf['nonTypoTagStdWrap.'])) {
index 89c6762..79ce64d 100644 (file)
@@ -3939,7 +3939,8 @@ if (version == "n3") {
        public function encryptEmail($string, $back = 0) {
                $out = '';
                if ($this->spamProtectEmailAddresses === 'ascii') {
-                       for ($a = 0; $a < strlen($string); $a++) {
+                       $stringLength = strlen($string);
+                       for ($a = 0; $a < $stringLength; $a++) {
                                $out .= '&#' . ord(substr($string, $a, 1)) . ';';
                        }
                } else {
index c76e554..cf01de5 100644 (file)
@@ -800,7 +800,8 @@ class DoubleMetaPhoneUtility {
                if ($start < 0 || $start >= strlen($string)) {
                        return 0;
                }
-               for ($i = 0; $i < count($list); $i++) {
+               $listCount = count($list);
+               for ($i = 0; $i < $listCount; $i++) {
                        if ($list[$i] == substr($string, $start, $length)) {
                                return 1;
                        }