diff --git a/app/code/Magento/Backend/Block/Dashboard/Graph.php b/app/code/Magento/Backend/Block/Dashboard/Graph.php index 8e238ccab44cb..83fc552ab0ed8 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Graph.php +++ b/app/code/Magento/Backend/Block/Dashboard/Graph.php @@ -331,7 +331,7 @@ public function getChartUrl($directUrl = true) $thisdataarray = $serie; if ($this->_encoding == "s") { // SIMPLE ENCODING - for ($j = 0; $j < sizeof($thisdataarray); $j++) { + for ($j = 0, $jMax = sizeof($thisdataarray); $j < $jMax; $j++) { $currentvalue = $thisdataarray[$j]; if (is_numeric($currentvalue)) { $ylocation = round( @@ -344,7 +344,7 @@ public function getChartUrl($directUrl = true) } } else { // EXTENDED ENCODING - for ($j = 0; $j < sizeof($thisdataarray); $j++) { + for ($j = 0, $jMax = sizeof($thisdataarray); $j < $jMax; $j++) { $currentvalue = $thisdataarray[$j]; if (is_numeric($currentvalue)) { if ($yrange) { diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/PriceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/PriceTest.php index 99151d1c8dd39..7939f1388b106 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/PriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/PriceTest.php @@ -200,7 +200,7 @@ public function testTierPrices($priceScope, $expectedWebsiteId) $this->assertTrue(is_array($tpArray)); $this->assertEquals(sizeof($tps), sizeof($tpArray)); - for ($i = 0; $i < sizeof($tps); $i++) { + for ($i = 0, $iMax = sizeof($tps); $i < $iMax; $i++) { $tpData = $tpArray[$i]; $this->assertEquals($expectedWebsiteId, $tpData['website_id'], 'Website Id does not match'); $this->assertEquals($tps[$i]->getValue(), $tpData['price'], 'Price/Value does not match'); @@ -231,7 +231,7 @@ public function testTierPrices($priceScope, $expectedWebsiteId) $this->assertEquals(50, $tpRest->getExtensionAttributes()->getPercentageValue()); } - for ($i = 0; $i < sizeof($tps); $i++) { + for ($i = 0, $iMax = sizeof($tps); $i < $iMax; $i++) { $this->assertEquals( $tps[$i]->getValue(), $tpRests[$i]->getValue(), diff --git a/app/code/Magento/Payment/Model/Method/Cc.php b/app/code/Magento/Payment/Model/Method/Cc.php index c23ad5b535dd8..16e3b9f8bc1cc 100644 --- a/app/code/Magento/Payment/Model/Method/Cc.php +++ b/app/code/Magento/Payment/Model/Method/Cc.php @@ -297,7 +297,7 @@ public function validateCcNum($ccNumber) $cardNumber = strrev($ccNumber); $numSum = 0; - for ($i = 0; $i < strlen($cardNumber); $i++) { + for ($i = 0, $iMax = strlen($cardNumber); $i < $iMax; $i++) { $currentNum = substr($cardNumber, $i, 1); /** diff --git a/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php b/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php index 401fdcd2b04ac..44ec4a9eb519b 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php @@ -184,7 +184,7 @@ public function widthForStringUsingFontSize($string, $font, $fontSize) ); $characters = []; - for ($i = 0; $i < strlen($drawingString); $i++) { + for ($i = 0, $iMax = strlen($drawingString); $i < $iMax; $i++) { $characters[] = ord($drawingString[$i++]) << 8 | ord($drawingString[$i]); } $glyphs = $font->glyphNumbersForCharacters($characters); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Language/DictionaryTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Language/DictionaryTest.php index 472fff4f4f287..f0a4c44cc3c98 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Language/DictionaryTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Language/DictionaryTest.php @@ -52,7 +52,7 @@ public function testDictionaryGetter() } $file = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\File\ReadInterface::class); - for ($i = 0; $i < count($data); $i++) { + for ($i = 0, $iMax = count($data); $i < $iMax; $i++) { $file->expects($this->at($i))->method('readCsv')->will($this->returnValue($data[$i])); } $file->expects($this->at($i))->method('readCsv')->will($this->returnValue(false)); diff --git a/lib/internal/Magento/Framework/Archive.php b/lib/internal/Magento/Framework/Archive.php index d43c976431b51..b5e24718ff524 100644 --- a/lib/internal/Magento/Framework/Archive.php +++ b/lib/internal/Magento/Framework/Archive.php @@ -96,7 +96,7 @@ public function pack($source, $destination = 'packed.tgz', $skipRoot = false) { $archivers = $this->_getArchivers($destination); $interimSource = ''; - for ($i = 0; $i < count($archivers); $i++) { + for ($i = 0, $iMax = count($archivers); $i < $iMax; $i++) { if ($i == count($archivers) - 1) { $packed = $destination; } else { diff --git a/lib/internal/Magento/Framework/Filesystem/Io/AbstractIo.php b/lib/internal/Magento/Framework/Filesystem/Io/AbstractIo.php index e30499523f3a3..f2cec25c846e7 100644 --- a/lib/internal/Magento/Framework/Filesystem/Io/AbstractIo.php +++ b/lib/internal/Magento/Framework/Filesystem/Io/AbstractIo.php @@ -80,7 +80,7 @@ public function getCleanPath($path) $pathParts = explode("/", $pathTokP); $realPathParts = []; - for ($i = 0, $realPathParts = []; $i < count($pathParts); $i++) { + for ($i = 0, $realPathParts = [], $iMax = count($pathParts); $i < $iMax; $i++) { if ($pathParts[$i] == '.') { continue; } elseif ($pathParts[$i] == '..') { diff --git a/lib/internal/Magento/Framework/Filter/Template.php b/lib/internal/Magento/Framework/Filter/Template.php index 10b6a17ea57dc..64e47be7f8bbd 100644 --- a/lib/internal/Magento/Framework/Filter/Template.php +++ b/lib/internal/Magento/Framework/Filter/Template.php @@ -374,7 +374,7 @@ protected function getVariable($value, $default = '{no_value_defined}') $stackVars = $tokenizer->tokenize(); $result = $default; $last = 0; - for ($i = 0; $i < count($stackVars); $i++) { + for ($i = 0, $iMax = count($stackVars); $i < $iMax; $i++) { if ($i == 0 && isset($this->templateVars[$stackVars[$i]['name']])) { // Getting of template value $stackVars[$i]['variable'] = & $this->templateVars[$stackVars[$i]['name']]; diff --git a/lib/internal/Magento/Framework/Profiler/Driver/Standard/Stat.php b/lib/internal/Magento/Framework/Profiler/Driver/Standard/Stat.php index 9774bef8cb513..0a8fb7a0d1c56 100644 --- a/lib/internal/Magento/Framework/Profiler/Driver/Standard/Stat.php +++ b/lib/internal/Magento/Framework/Profiler/Driver/Standard/Stat.php @@ -200,7 +200,7 @@ protected function _getOrderedTimerIds() $prevTimerId = $timerIds[0]; $result = [$prevTimerId]; - for ($i = 1; $i < count($timerIds); $i++) { + for ($i = 1, $iMax = count($timerIds); $i < $iMax; $i++) { $timerId = $timerIds[$i]; /* Skip already added timer */ if (!$timerId) { @@ -209,7 +209,7 @@ protected function _getOrderedTimerIds() /* Loop over all timers that need to be closed under previous timer */ while (strpos($timerId, $prevTimerId . Profiler::NESTING_SEPARATOR) !== 0) { /* Add to result all timers nested in the previous timer */ - for ($j = $i + 1; $j < count($timerIds); $j++) { + for ($j = $i + 1, $jMax = count($timerIds); $j < $jMax; $j++) { if (strpos($timerIds[$j], $prevTimerId . Profiler::NESTING_SEPARATOR) === 0) { $result[] = $timerIds[$j]; /* Mark timer as already added */ diff --git a/lib/internal/Magento/Framework/System/Ftp.php b/lib/internal/Magento/Framework/System/Ftp.php index 216026be8d72e..8d7d48a0e21ad 100644 --- a/lib/internal/Magento/Framework/System/Ftp.php +++ b/lib/internal/Magento/Framework/System/Ftp.php @@ -58,7 +58,7 @@ public function mkdirRecursive($path, $mode = 0777) $dir = explode("/", $path); $path = ""; $ret = true; - for ($i = 0; $i < count($dir); $i++) { + for ($i = 0, $iMax = count($dir); $i < $iMax; $i++) { $path .= "/" . $dir[$i]; if (!@ftp_chdir($this->_conn, $path)) { @ftp_chdir($this->_conn, "/"); diff --git a/setup/src/Magento/Setup/Module/I18n/Parser/Adapter/Html.php b/setup/src/Magento/Setup/Module/I18n/Parser/Adapter/Html.php index a4e3063abece4..d15adfedb64da 100644 --- a/setup/src/Magento/Setup/Module/I18n/Parser/Adapter/Html.php +++ b/setup/src/Magento/Setup/Module/I18n/Parser/Adapter/Html.php @@ -31,7 +31,7 @@ protected function _parse() $results = []; preg_match_all(Filter::CONSTRUCTION_PATTERN, $data, $results, PREG_SET_ORDER); - for ($i = 0; $i < count($results); $i++) { + for ($i = 0, $iMax = count($results); $i < $iMax; $i++) { if ($results[$i][1] === Filter::TRANS_DIRECTIVE_NAME) { $directive = []; if (preg_match(Filter::TRANS_DIRECTIVE_REGEX, $results[$i][2], $directive) !== 1) { @@ -43,7 +43,7 @@ protected function _parse() } preg_match_all(self::HTML_FILTER, $data, $results, PREG_SET_ORDER); - for ($i = 0; $i < count($results); $i++) { + for ($i = 0, $iMax = count($results); $i < $iMax; $i++) { if (!empty($results[$i]['value'])) { $this->_addPhrase($results[$i]['value']); } diff --git a/setup/src/Magento/Setup/Module/I18n/Parser/Adapter/Js.php b/setup/src/Magento/Setup/Module/I18n/Parser/Adapter/Js.php index 4095b12c9a6c6..1d7b5fd4b767a 100644 --- a/setup/src/Magento/Setup/Module/I18n/Parser/Adapter/Js.php +++ b/setup/src/Magento/Setup/Module/I18n/Parser/Adapter/Js.php @@ -22,7 +22,7 @@ protected function _parse() $fileRow = fgets($fileHandle, 4096); $results = []; preg_match_all('/mage\.__\(\s*([\'"])(.*?[^\\\])\1.*?[),]/', $fileRow, $results, PREG_SET_ORDER); - for ($i = 0; $i < count($results); $i++) { + for ($i = 0, $iMax = count($results); $i < $iMax; $i++) { if (isset($results[$i][2])) { $quote = $results[$i][1]; $this->_addPhrase($quote . $results[$i][2] . $quote, $lineNumber); @@ -30,7 +30,7 @@ protected function _parse() } preg_match_all('/\\$t\(\s*([\'"])(.*?[^\\\])\1.*?[),]/', $fileRow, $results, PREG_SET_ORDER); - for ($i = 0; $i < count($results); $i++) { + for ($i = 0, $iMax = count($results); $i < $iMax; $i++) { if (isset($results[$i][2])) { $quote = $results[$i][1]; $this->_addPhrase($quote . $results[$i][2] . $quote, $lineNumber);