diff --git a/Business/Finance/FinanceFormulas.php b/Business/Finance/FinanceFormulas.php index 26e88cc3c..169b2cc74 100644 --- a/Business/Finance/FinanceFormulas.php +++ b/Business/Finance/FinanceFormulas.php @@ -1063,7 +1063,7 @@ class FinanceFormulas $npv = -$C[0]; - for ($i = 1; $i < $count; $i++) { + for ($i = 1; $i < $count; ++$i) { $npv += $C[$i] / pow(1 + $r, $i); } diff --git a/Business/Finance/Forecasting/ARIMA.php b/Business/Finance/Forecasting/ARIMA.php index 00de6c245..8eb077cfe 100644 --- a/Business/Finance/Forecasting/ARIMA.php +++ b/Business/Finance/Forecasting/ARIMA.php @@ -77,7 +77,7 @@ class ARIMA $remainder = []; $count = count($prelimSeasonalComponent); - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { // +1 since 3x3 MA $remainder[] = $centeredRatios[$i + 1] / $prelimSeasonalComponent[$i]; } @@ -103,7 +103,7 @@ class ARIMA $centeredRatio = []; $count = count($seasonal); - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { // +1 since 3x3 MA $centeredRatio[] = $remainder[$i + 1] * $seasonal[$i]; } @@ -134,7 +134,7 @@ class ARIMA $count = count($seasonal); $start = ClassicalDecomposition::getStartOfDecomposition(count($this->data), $count); - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { $adjusted[] = $this->data[$start + $i] / $seasonal[$i]; } @@ -156,7 +156,7 @@ class ARIMA $data = []; $count = count($trendCycleComponent); - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { $data[] = $trendCycleComponent[$i] * $seasonalAdjustedSeries[$i] * $remainder[$i]; } diff --git a/Business/Finance/Forecasting/ClassicalDecomposition.php b/Business/Finance/Forecasting/ClassicalDecomposition.php index 8a75a43f2..97db1918b 100644 --- a/Business/Finance/Forecasting/ClassicalDecomposition.php +++ b/Business/Finance/Forecasting/ClassicalDecomposition.php @@ -151,7 +151,7 @@ class ClassicalDecomposition $count = count($trendCycleComponent); $start = self::getStartOfDecomposition(count($data), $count); - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { $detrended[] = $mode === self::ADDITIVE ? $data[$start + $i] - $trendCycleComponent[$i] : $data[$start + $i] / $trendCycleComponent[$i]; } @@ -192,7 +192,7 @@ class ClassicalDecomposition $seasonalComponent = []; $count = count($detrendedSeries); - for ($i = 0; $i < $order; $i++) { + for ($i = 0; $i < $order; ++$i) { $temp = []; for ($j = $i; $j < $count; $j += $order) { @@ -225,7 +225,7 @@ class ClassicalDecomposition $start = self::getStartOfDecomposition($dataSize, $count); $seasons = count($seasonalComponent); - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { $remainderComponent[] = $mode === self::ADDITIVE ? $data[$start + $i] - $trendCycleComponent[$i] - $seasonalComponent[$i % $seasons] : $data[$start + $i] / ($trendCycleComponent[$i] * $seasonalComponent[$i % $seasons]); } diff --git a/Business/Sales/MarketShareEstimation.php b/Business/Sales/MarketShareEstimation.php index 6acf18dcf..324fa8ae0 100644 --- a/Business/Sales/MarketShareEstimation.php +++ b/Business/Sales/MarketShareEstimation.php @@ -43,7 +43,7 @@ class MarketShareEstimation public static function getRankFromMarketShare(int $participants, float $marketShare, float $modifier = 1.0) : int { $sum = 0.0; - for ($i = 0; $i < $participants; $i++) { + for ($i = 0; $i < $participants; ++$i) { $sum += 1 / pow($i + 1, $modifier); } @@ -66,7 +66,7 @@ class MarketShareEstimation public static function getMarketShareFromRank(int $participants, int $rank, float $modifier = 1.0) : float { $sum = 0.0; - for ($i = 0; $i < $participants; $i++) { + for ($i = 0; $i < $participants; ++$i) { $sum += 1 / pow($i + 1, $modifier); } diff --git a/Math/Functions/Fibunacci.php b/Math/Functions/Fibunacci.php index 068ddd060..5282a9e37 100644 --- a/Math/Functions/Fibunacci.php +++ b/Math/Functions/Fibunacci.php @@ -61,7 +61,7 @@ class Fibunacci $old2 = $start; $fib = 0; - for ($i = 2; $i < $n; $i++) { + for ($i = 2; $i < $n; ++$i) { $fib = $old1 + $old2; $old1 = $old2; $old2 = $fib; diff --git a/Math/Functions/Functions.php b/Math/Functions/Functions.php index 0ae2d8970..91dfdf330 100644 --- a/Math/Functions/Functions.php +++ b/Math/Functions/Functions.php @@ -56,7 +56,7 @@ class Functions { $fact = 1; - for ($i = $start; $i < $n + 1; $i++) { + for ($i = $start; $i < $n + 1; ++$i) { $fact *= $i; } @@ -85,7 +85,7 @@ class Functions $fact = 1; $range = array_reverse(range(1, $min)); - for ($i = $max + 1; $i < $n + 1; $i++) { + for ($i = $max + 1; $i < $n + 1; ++$i) { $div = 1; foreach ($range as $key => $d) { if ($i % $d === 0) { diff --git a/Math/Geometry/Shape/D2/Polygon.php b/Math/Geometry/Shape/D2/Polygon.php index aaa3696bc..64aaaa33f 100644 --- a/Math/Geometry/Shape/D2/Polygon.php +++ b/Math/Geometry/Shape/D2/Polygon.php @@ -103,7 +103,7 @@ class Polygon implements D2ShapeInterface $polygonCount = count($polygon); // todo: return based on highest possibility not by first match - for ($i = 1; $i < $polygonCount; $i++) { + for ($i = 1; $i < $polygonCount; ++$i) { $vertex1 = $polygon[$i - 1]; $vertex2 = $polygon[$i]; @@ -200,7 +200,7 @@ class Polygon implements D2ShapeInterface $count = count($this->coord); $surface = 0; - for ($i = 0; $i < $count - 1; $i++) { + for ($i = 0; $i < $count - 1; ++$i) { $surface += $this->coord[$i]['x'] * $this->coord[$i + 1]['y'] - $this->coord[$i + 1]['x'] * $this->coord[$i]['y']; } @@ -222,7 +222,7 @@ class Polygon implements D2ShapeInterface $count = count($this->coord); $perimeter = sqrt(($this->coord[0]['x'] - $this->coord[$count - 1]['x']) ** 2 + ($this->coord[0]['y'] - $this->coord[$count - 1]['y']) ** 2); - for ($i = 0; $i < $count - 1; $i++) { + for ($i = 0; $i < $count - 1; ++$i) { $perimeter += sqrt(($this->coord[$i + 1]['x'] - $this->coord[$i]['x']) ** 2 + ($this->coord[$i + 1]['y'] - $this->coord[$i]['y']) ** 2); } @@ -241,7 +241,7 @@ class Polygon implements D2ShapeInterface $barycenter = ['x' => 0, 'y' => 0]; $count = count($this->coord); - for ($i = 0; $i < $count - 1; $i++) { + for ($i = 0; $i < $count - 1; ++$i) { $mult = ($this->coord[$i]['x'] * $this->coord[$i + 1]['y'] - $this->coord[$i + 1]['x'] * $this->coord[$i]['y']); $barycenter['x'] += ($this->coord[$i]['x'] + $this->coord[$i + 1]['x']) * $mult; $barycenter['y'] += ($this->coord[$i]['y'] + $this->coord[$i + 1]['y']) * $mult; diff --git a/Math/Matrix/CholeskyDecomposition.php b/Math/Matrix/CholeskyDecomposition.php index 27cea1958..867906104 100644 --- a/Math/Matrix/CholeskyDecomposition.php +++ b/Math/Matrix/CholeskyDecomposition.php @@ -83,9 +83,9 @@ class CholeskyDecomposition $n = $B->getN(); // Solve L*Y = B; - for ($k = 0; $k < $this->m; $k++) { - for ($j = 0; $j < $n; $j++) { - for ($i = 0; $i < $k; $i++) { + for ($k = 0; $k < $this->m; ++$k) { + for ($j = 0; $j < $n; ++$j) { + for ($i = 0; $i < $k; ++$i) { $X[$k][$j] -= $X[$i][$j] * $this->L[$k][$i]; } @@ -95,8 +95,8 @@ class CholeskyDecomposition // Solve L'*X = Y; for ($k = $this->m - 1; $k >= 0; $k--) { - for ($j = 0; $j < $n; $j++) { - for ($i = $k + 1; $i < $this->m; $i++) { + for ($j = 0; $j < $n; ++$j) { + for ($i = $k + 1; $i < $this->m; ++$i) { $X[$k][$j] -= $X[$i][$j] * $this->L[$i][$k]; } diff --git a/Math/Matrix/IdentityMatrix.php b/Math/Matrix/IdentityMatrix.php index 94b557a1e..875155b34 100644 --- a/Math/Matrix/IdentityMatrix.php +++ b/Math/Matrix/IdentityMatrix.php @@ -35,7 +35,7 @@ class IdentityMatrix extends Matrix { parent::__construct($n, $n); - for ($i = 0; $i < $n; $i++) { + for ($i = 0; $i < $n; ++$i) { $this->matrix[$i][$i] = 1; } } diff --git a/Math/Matrix/Matrix.php b/Math/Matrix/Matrix.php index c680ace61..1fb6d1ba4 100644 --- a/Math/Matrix/Matrix.php +++ b/Math/Matrix/Matrix.php @@ -71,7 +71,7 @@ class Matrix implements \ArrayAccess, \Iterator $this->n = $n; $this->m = $m; - for ($i = 0; $i < $m; $i++) { + for ($i = 0; $i < $m; ++$i) { $this->matrix[$i] = array_fill(0, $n, 0); } } @@ -361,11 +361,11 @@ class Matrix implements \ArrayAccess, \Iterator $newMatrix = new Matrix($this->m, $nDim); $newMatrixArr = $newMatrix->getMatrix(); - for ($i = 0; $i < $this->m; $i++) { // Row of $this - for ($c = 0; $c < $nDim; $c++) { // Column of $matrix + for ($i = 0; $i < $this->m; ++$i) { // Row of $this + for ($c = 0; $c < $nDim; ++$c) { // Column of $matrix $temp = 0; - for ($j = 0; $j < $mDim; $j++) { // Row of $matrix + for ($j = 0; $j < $mDim; ++$j) { // Row of $matrix $temp += $this->matrix[$i][$j] * $matrixArr[$j][$c]; } @@ -437,10 +437,10 @@ class Matrix implements \ArrayAccess, \Iterator $n = count($arr); $sign = 1; - for ($i = 0; $i < $n; $i++) { + for ($i = 0; $i < $n; ++$i) { $max = 0; - for ($j = $i; $j < $n; $j++) { + for ($j = $i; $j < $n; ++$j) { if (abs($arr[$j][$i]) > abs($arr[$max][$i])) { $max = $j; } @@ -457,14 +457,14 @@ class Matrix implements \ArrayAccess, \Iterator return 0; } - for ($j = $i + 1; $j < $n; $j++) { + for ($j = $i + 1; $j < $n; ++$j) { $r = $arr[$j][$i] / $arr[$i][$i]; if (!$r) { continue; } - for ($c = $i; $c < $n; $c++) { + for ($c = $i; $c < $n; ++$c) { $arr[$j][$c] -= $arr[$i][$c] * $r; } } @@ -514,8 +514,8 @@ class Matrix implements \ArrayAccess, \Iterator $newMatrixArr = $this->matrix; // extending matrix by identity matrix - for ($i = 0; $i < $this->n; $i++) { - for ($j = $this->n; $j < $this->n * 2; $j++) { + for ($i = 0; $i < $this->n; ++$i) { + for ($j = $this->n; $j < $this->n * 2; ++$j) { if ($j === ($i + $this->n)) { $newMatrixArr[$i][$j] = 1; @@ -532,16 +532,16 @@ class Matrix implements \ArrayAccess, \Iterator $newMatrixArr = $this->diag($newMatrixArr); /* create unit matrix */ - for ($i = 0; $i < $mDim; $i++) { + for ($i = 0; $i < $mDim; ++$i) { $temp = $newMatrixArr[$i][$i]; - for ($j = 0; $j < $nDim; $j++) { + for ($j = 0; $j < $nDim; ++$j) { $newMatrixArr[$i][$j] = $newMatrixArr[$i][$j] / $temp; } } /* removing identity matrix */ - for ($i = 0; $i < $mDim; $i++) { + for ($i = 0; $i < $mDim; ++$i) { $newMatrixArr[$i] = array_slice($newMatrixArr[$i], $mDim); } @@ -575,7 +575,7 @@ class Matrix implements \ArrayAccess, \Iterator $j = $col; $max = $matrix[$j][$j]; - for ($i = $col + 1; $i < $mDim; $i++) { + for ($i = $col + 1; $i < $mDim; ++$i) { $temp = abs($matrix[$i][$col]); if ($temp > $max) { @@ -594,10 +594,10 @@ class Matrix implements \ArrayAccess, \Iterator $b[$j] = $temp; } - for ($i = $col + 1; $i < $mDim; $i++) { + for ($i = $col + 1; $i < $mDim; ++$i) { $temp = $matrix[$i][$col] / $matrix[$col][$col]; - for ($j = $col + 1; $j < $mDim; $j++) { + for ($j = $col + 1; $j < $mDim; ++$j) { $matrix[$i][$j] -= $temp * $matrix[$col][$j]; } @@ -638,7 +638,7 @@ class Matrix implements \ArrayAccess, \Iterator for ($i = $mDim - 1; $i > 0; $i--) { if ($arr[$i - 1][0] < $arr[$i][0]) { - for ($j = 0; $j < $nDim; $j++) { + for ($j = 0; $j < $nDim; ++$j) { $temp = $arr[$i][$j]; $arr[$i][$j] = $arr[$i - 1][$j]; $arr[$i - 1][$j] = $temp; @@ -647,12 +647,12 @@ class Matrix implements \ArrayAccess, \Iterator } /* create diagonal matrix */ - for ($i = 0; $i < $mDim; $i++) { - for ($j = 0; $j < $mDim; $j++) { + for ($i = 0; $i < $mDim; ++$i) { + for ($j = 0; $j < $mDim; ++$j) { if ($j !== $i) { $temp = $arr[$j][$i] / $arr[$i][$i]; - for ($c = 0; $c < $nDim; $c++) { + for ($c = 0; $c < $nDim; ++$c) { $arr[$j][$c] -= $arr[$i][$c] * $temp; } } diff --git a/Math/Number/Integer.php b/Math/Number/Integer.php index 1e0eb57b1..47d33c7b4 100644 --- a/Math/Number/Integer.php +++ b/Math/Number/Integer.php @@ -92,7 +92,7 @@ class Integer public static function pollardsRho(int $n, int $x = 2, int $factor = 1, int $cycleSize = 2, int $y = 2) : int { while ($factor === 1) { - for ($i = 1; $i < $cycleSize && $factor <= 1; $i++) { + for ($i = 1; $i < $cycleSize && $factor <= 1; ++$i) { $x = ($x * $x + 1) % $n; $factor = self::greatestCommonDivisor($x - $y, $n); } diff --git a/Math/Number/Numbers.php b/Math/Number/Numbers.php index ea8bdfc1b..bfb1fade2 100644 --- a/Math/Number/Numbers.php +++ b/Math/Number/Numbers.php @@ -37,7 +37,7 @@ class Numbers { $sum = 0; - for ($i = 1; $i < $n; $i++) { + for ($i = 1; $i < $n; ++$i) { if ($n % $i == 0) { $sum += $i; } diff --git a/Math/Number/Prime.php b/Math/Number/Prime.php index a138aaef7..4e54e3f60 100644 --- a/Math/Number/Prime.php +++ b/Math/Number/Prime.php @@ -82,7 +82,7 @@ class Prime $s++; } - for ($i = 0; $i < $k; $i++) { + for ($i = 0; $i < $k; ++$i) { $a = mt_rand(2, $n - 1); $x = bcpowmod((string) $a, (string) $d, (string) $n); @@ -91,7 +91,7 @@ class Prime continue; } - for ($j = 1; $j < $s; $j++) { + for ($j = 1; $j < $s; ++$j) { $x = bcmod(bcmul($x, $x), (string) $n); if ($x == 1) { diff --git a/Math/Optimization/TSP/BruteForce.php b/Math/Optimization/TSP/BruteForce.php index b5ad1c488..f4ece4ecf 100644 --- a/Math/Optimization/TSP/BruteForce.php +++ b/Math/Optimization/TSP/BruteForce.php @@ -95,7 +95,7 @@ class BruteForce } $count = count($cities); - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { $extended = clone $tour; $extended->addCity($cities[$i]); unset($cities[$i]); diff --git a/Math/Optimization/TSP/GA.php b/Math/Optimization/TSP/GA.php index d88668406..686890fab 100644 --- a/Math/Optimization/TSP/GA.php +++ b/Math/Optimization/TSP/GA.php @@ -84,7 +84,7 @@ class GA $newPopulation->add($population->getFittest()); - for ($i = $shift; $i < $count; $i++) { + for ($i = $shift; $i < $count; ++$i) { $parent1 = $this->tournamentSelection($population); $parent2 = $this->tournamentSelection($population); $child = $this->crossover($parent1, $parent2); @@ -94,7 +94,7 @@ class GA $count2 = $newPopulation->count(); - for ($i = $shift; $i < $count2; $i++) { + for ($i = $shift; $i < $count2; ++$i) { $this->mutate($newPopulation->get($i)); } @@ -115,7 +115,7 @@ class GA $tournament = new Population($this->cityPool, self::TOURNAMENT, false); $populationSize = $population->count() - 1; - for ($i = 0; $i < self::TOURNAMENT; $i++) { + for ($i = 0; $i < self::TOURNAMENT; ++$i) { $tournament->add($population->get(mt_rand(0, $populationSize))); } @@ -141,7 +141,7 @@ class GA $count = $child->count(); /* $tour1->count() ???!!!! */ - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { if ($start < $end && $i > $start && $i < $end) { $child->setCity($i, $tour1->getCity($i)); } elseif ($start > $end && !($i < $start && $i > $end)) { @@ -151,9 +151,9 @@ class GA $count = $tour2->count(); - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { if (!$child->hasCity($tour2->getCity($i))) { - for ($j = 0; $j < $child->count(); $j++) { + for ($j = 0; $j < $child->count(); ++$j) { if ($child->getCity($j) === null) { $child->setCity($j, $tour2->getCity($i)); break; diff --git a/Math/Optimization/TSP/Population.php b/Math/Optimization/TSP/Population.php index bfec067ff..725537d19 100644 --- a/Math/Optimization/TSP/Population.php +++ b/Math/Optimization/TSP/Population.php @@ -44,7 +44,7 @@ class Population implements \Countable public function __construct(CityPool $pool, int $size, bool $initialize = false) { if ($initialize) { - for ($i = 0; $i < $size; $i++) { + for ($i = 0; $i < $size; ++$i) { $this->tours[] = new Tour($pool, true); } } @@ -115,7 +115,7 @@ class Population implements \Countable $fittest = $this->tours[0]; $count = count($this->tours); - for ($i = 1; $i < $count; $i++) { + for ($i = 1; $i < $count; ++$i) { if ($fittest->getFitness() <= $this->tours[$i]->getFitness()) { $fittest = $this->tours[$i]; } @@ -136,7 +136,7 @@ class Population implements \Countable $unfittest = $this->tours[0]; $count = count($this->tours); - for ($i = 1; $i < $count; $i++) { + for ($i = 1; $i < $count; ++$i) { if ($unfittest->getFitness() >= $this->tours[$i]->getFitness()) { $unfittest = $this->tours[$i]; } diff --git a/Math/Optimization/TSP/Tour.php b/Math/Optimization/TSP/Tour.php index c5d3ac5a0..53f010a7b 100644 --- a/Math/Optimization/TSP/Tour.php +++ b/Math/Optimization/TSP/Tour.php @@ -118,7 +118,7 @@ class Tour implements \Countable $count = count($this->cities); - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { $dest = ($i + 1 < $count) ? $this->cities[$i + 1] : $this->cities[0]; $distance += $this->cities[$i]->getDistanceTo($dest); diff --git a/Math/Statistic/Average.php b/Math/Statistic/Average.php index 12efba65d..0b87a6bf2 100644 --- a/Math/Statistic/Average.php +++ b/Math/Statistic/Average.php @@ -77,7 +77,7 @@ class Average $count = count($x) - ($symmetric ? $periods : 0); $avg = []; - for ($i = $periods; $i < $count; $i++) { + for ($i = $periods; $i < $count; ++$i) { $avg[] = self::movingAverage($x, $i, $order, $weight, $symmetric); } @@ -141,7 +141,7 @@ class Average $avg = 0.0; - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { $avg += $values[$i] * $weight[$i]; } @@ -294,10 +294,11 @@ class Average */ public static function angleMean($angles, int $offset = 0) : float { - $y = $x = 0; + $y = 0; + $x = 0; $size = count($angles); - for ($i = 0; $i < $size; $i++) { + for ($i = 0; $i < $size; ++$i) { $x += cos(deg2rad($angles[$i])); $y += sin(deg2rad($angles[$i])); } diff --git a/Math/Statistic/Correlation.php b/Math/Statistic/Correlation.php index 041d73ac4..d9cdf3e7b 100644 --- a/Math/Statistic/Correlation.php +++ b/Math/Statistic/Correlation.php @@ -59,7 +59,7 @@ class Correlation $count = count($x); $sum = 0.0; - for ($i = $k + 1; $i < $count; $i++) { + for ($i = $k + 1; $i < $count; ++$i) { $sum += ($x[$i] - $mean) * ($x[$i - $k] - $mean); } @@ -79,7 +79,7 @@ class Correlation public static function boxPierceTest(array $autocorrelations, int $h) : float { $sum = 0; - for ($i = 0; $i < $h; $i++) { + for ($i = 0; $i < $h; ++$i) { $sum += $autocorrelations[$i] ** 2; } @@ -101,7 +101,7 @@ class Correlation $count = count($autocorrelations); $sum = 0; - for ($i = 0; $i < $h; $i++) { + for ($i = 0; $i < $h; ++$i) { $sum += 1 / ($count - $i) * $autocorrelations[$i] ** 2; } diff --git a/Math/Statistic/Forecast/Error.php b/Math/Statistic/Forecast/Error.php index 4f8589ebb..eb3e543b5 100644 --- a/Math/Statistic/Forecast/Error.php +++ b/Math/Statistic/Forecast/Error.php @@ -164,11 +164,11 @@ class Error $sum2 = 0; $meanY = Average::arithmeticMean($observed); - for ($i = 0; $i < $countF; $i++) { + for ($i = 0; $i < $countF; ++$i) { $sum1 += ($forecasted[$i] - $meanY) ** 2; } - for ($i = 0; $i < $countO; $i++) { + for ($i = 0; $i < $countO; ++$i) { $sum2 += ($observed[$i] - $meanY) ** 2; } @@ -444,7 +444,7 @@ class Error $sum = 0.0; $count = count($observed); - for ($i = 0 + $m; $i < $count; $i++) { + for ($i = 0 + $m; $i < $count; ++$i) { $sum += abs($observed[$i] - $observed[$i - $m]); } diff --git a/Math/Statistic/Forecast/Regression/LevelLogRegression.php b/Math/Statistic/Forecast/Regression/LevelLogRegression.php index 969553006..1394022bf 100644 --- a/Math/Statistic/Forecast/Regression/LevelLogRegression.php +++ b/Math/Statistic/Forecast/Regression/LevelLogRegression.php @@ -35,7 +35,7 @@ class LevelLogRegression extends RegressionAbstract throw new InvalidDimensionException($c . 'x' . count($y)); } - for ($i = 0; $i < $c; $i++) { + for ($i = 0; $i < $c; ++$i) { $x[$i] = log($x[$i]); } diff --git a/Math/Statistic/Forecast/Regression/LogLevelRegression.php b/Math/Statistic/Forecast/Regression/LogLevelRegression.php index eebd46c4b..30b92e24f 100644 --- a/Math/Statistic/Forecast/Regression/LogLevelRegression.php +++ b/Math/Statistic/Forecast/Regression/LogLevelRegression.php @@ -35,7 +35,7 @@ class LogLevelRegression extends RegressionAbstract throw new InvalidDimensionException($c . 'x' . count($y)); } - for ($i = 0; $i < $c; $i++) { + for ($i = 0; $i < $c; ++$i) { $y[$i] = log($y[$i]); } diff --git a/Math/Statistic/Forecast/Regression/LogLogRegression.php b/Math/Statistic/Forecast/Regression/LogLogRegression.php index 240abf9cb..fdc4b303f 100644 --- a/Math/Statistic/Forecast/Regression/LogLogRegression.php +++ b/Math/Statistic/Forecast/Regression/LogLogRegression.php @@ -35,7 +35,7 @@ class LogLogRegression extends RegressionAbstract throw new InvalidDimensionException($c . 'x' . count($y)); } - for ($i = 0; $i < $c; $i++) { + for ($i = 0; $i < $c; ++$i) { $x[$i] = log($x[$i]); $y[$i] = log($y[$i]); } diff --git a/Math/Statistic/Forecast/Regression/RegressionAbstract.php b/Math/Statistic/Forecast/Regression/RegressionAbstract.php index 9462f3784..19be45a92 100644 --- a/Math/Statistic/Forecast/Regression/RegressionAbstract.php +++ b/Math/Statistic/Forecast/Regression/RegressionAbstract.php @@ -71,7 +71,7 @@ abstract class RegressionAbstract $count = count($errors); $sum = 0.0; - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { $sum += $errors[$i] ** 2; } @@ -97,7 +97,7 @@ abstract class RegressionAbstract $meanX = Average::arithmeticMean($x); $sum = 0.0; - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { $sum += ($x[$i] - $meanX) ** 2; } @@ -127,7 +127,7 @@ abstract class RegressionAbstract $sum1 = 0; $sum2 = 0; - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { $sum1 += ($y[$i] - $meanY) * ($x[$i] - $meanX); $sum2 += ($x[$i] - $meanX) ** 2; } diff --git a/Math/Statistic/MeasureOfDispersion.php b/Math/Statistic/MeasureOfDispersion.php index 48d3584d7..3dd06c17b 100644 --- a/Math/Statistic/MeasureOfDispersion.php +++ b/Math/Statistic/MeasureOfDispersion.php @@ -174,7 +174,7 @@ class MeasureOfDispersion $sum = 0.0; - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { $sum += ($x[$i] - $xMean) * ($y[$i] - $yMean); } diff --git a/Math/Stochastic/Distribution/BinomialDistribution.php b/Math/Stochastic/Distribution/BinomialDistribution.php index aa2c8d980..1cb68bb11 100644 --- a/Math/Stochastic/Distribution/BinomialDistribution.php +++ b/Math/Stochastic/Distribution/BinomialDistribution.php @@ -128,7 +128,7 @@ class BinomialDistribution { $sum = 0.0; - for ($i = 0; $i < $x; $i++) { + for ($i = 0; $i < $x; ++$i) { $sum += self::getPmf($n, $i, $p); } diff --git a/Math/Stochastic/Distribution/ChiSquaredDistribution.php b/Math/Stochastic/Distribution/ChiSquaredDistribution.php index a970c10cd..228948346 100644 --- a/Math/Stochastic/Distribution/ChiSquaredDistribution.php +++ b/Math/Stochastic/Distribution/ChiSquaredDistribution.php @@ -95,7 +95,7 @@ class ChiSquaredDistribution $sum = 0.0; - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { $sum += ($dataset[$i] - $expected[$i]) * ($dataset[$i] - $expected[$i]) / $expected[$i]; } diff --git a/Math/Stochastic/Distribution/PoissonDistribution.php b/Math/Stochastic/Distribution/PoissonDistribution.php index fa40d2c69..b14d712ba 100644 --- a/Math/Stochastic/Distribution/PoissonDistribution.php +++ b/Math/Stochastic/Distribution/PoissonDistribution.php @@ -57,7 +57,7 @@ class PoissonDistribution { $sum = 0.0; - for ($i = 0; $i < $k + 1; $i++) { + for ($i = 0; $i < $k + 1; ++$i) { $sum += pow($lambda, $i) / Functions::fact($i); } diff --git a/Message/Http/Request.php b/Message/Http/Request.php index a0c18c21b..52de748ec 100644 --- a/Message/Http/Request.php +++ b/Message/Http/Request.php @@ -231,7 +231,7 @@ class Request extends RequestAbstract foreach ($pathArray as $key => $path) { $paths = []; - for ($i = $start; $i < $key + 1; $i++) { + for ($i = $start; $i < $key + 1; ++$i) { $paths[] = $pathArray[$i]; } diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index 3cca21cda..206b3a532 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -149,9 +149,9 @@ class ModuleManager $i = 1; $c = count($uriHash); - for ($k = 0; $k < $c; $k++) { + for ($k = 0; $k < $c; ++$k) { $uriPdo .= ':pid' . $i . ','; - $i++; + ++$i; } $uriPdo = rtrim($uriPdo, ','); @@ -169,7 +169,7 @@ class ModuleManager $i = 1; foreach ($uriHash as $hash) { $sth->bindValue(':pid' . $i, $hash, \PDO::PARAM_STR); - $i++; + ++$i; } $sth->execute(); @@ -229,7 +229,7 @@ class ModuleManager $files = glob('*', GLOB_ONLYDIR); $c = count($files); - for ($i = 0; $i < $c; $i++) { + for ($i = 0; $i < $c; ++$i) { $path = $this->modulePath . '/' . $files[$i] . '/info.json'; if (!file_exists($path)) { diff --git a/Stdlib/Base/SmartDateTime.php b/Stdlib/Base/SmartDateTime.php index 755f0179d..1474657e0 100644 --- a/Stdlib/Base/SmartDateTime.php +++ b/Stdlib/Base/SmartDateTime.php @@ -260,13 +260,13 @@ class SmartDateTime extends \DateTime $daysPreviousMonth = $previousMonth->getDaysOfMonth(); // add difference to $weekStartsWith counting backwards from days of previous month (reorder so that lowest value first) - for ($i = $daysPreviousMonth - $diffToWeekStart; $i < $daysPreviousMonth; $i++) { + for ($i = $daysPreviousMonth - $diffToWeekStart; $i < $daysPreviousMonth; ++$i) { $days[] = new \DateTime($previousMonth->format('Y') . '-' . $previousMonth->format('m') . '-' . ($i + 1)); } // add normal count of current days $daysMonth = $this->getDaysOfMonth(); - for ($i = 1; $i <= $daysMonth; $i++) { + for ($i = 1; $i <= $daysMonth; ++$i) { $days[] = new \DateTime($this->format('Y') . '-' . $this->format('m') . '-' . ($i)); } @@ -274,7 +274,7 @@ class SmartDateTime extends \DateTime $remainingDays = 42 - $diffToWeekStart - $daysMonth; $nextMonth = $this->createModify(0, 1); - for ($i = 1; $i <= $remainingDays; $i++) { + for ($i = 1; $i <= $remainingDays; ++$i) { $days[] = new \DateTime($nextMonth->format('Y') . '-' . $nextMonth->format('m') . '-' . ($i)); } diff --git a/Stdlib/Graph/Tree.php b/Stdlib/Graph/Tree.php index 17d76e9fa..b7592f0d5 100644 --- a/Stdlib/Graph/Tree.php +++ b/Stdlib/Graph/Tree.php @@ -131,7 +131,7 @@ class Tree extends Graph { $depth = $this->getMaxDepth(); - for ($i = 1; $i < $depth; $i++) { + for ($i = 1; $i < $depth; ++$i) { $nodes = $this->getLevel($i); callback($nodes); } diff --git a/Uri/UriFactory.php b/Uri/UriFactory.php index 6bb91431b..752573182 100644 --- a/Uri/UriFactory.php +++ b/Uri/UriFactory.php @@ -187,7 +187,7 @@ class UriFactory $comps = []; $length = count($pars); - for ($i = 0; $i < $length; $i++) { + for ($i = 0; $i < $length; ++$i) { $spl = explode('=', $pars[$i]); if (isset($spl[1])) { diff --git a/Utils/ArrayUtils.php b/Utils/ArrayUtils.php index ab93a4a6e..30d9463a0 100644 --- a/Utils/ArrayUtils.php +++ b/Utils/ArrayUtils.php @@ -345,7 +345,7 @@ class ArrayUtils $sum = 0; $array = array_values($array); - for ($i = $start; $i <= $count - 1; $i++) { + for ($i = $start; $i <= $count - 1; ++$i) { $sum += $array[$i]; } diff --git a/Utils/Barcode/C128Abstract.php b/Utils/Barcode/C128Abstract.php index c77afc5e4..55105d2bd 100644 --- a/Utils/Barcode/C128Abstract.php +++ b/Utils/Barcode/C128Abstract.php @@ -350,7 +350,7 @@ abstract class C128Abstract $codeLength = 0; $length = strlen($codeString); - for ($i = 1; $i <= $length; $i++) { + for ($i = 1; $i <= $length; ++$i) { $codeLength = $codeLength + (int) (substr($codeString, ($i - 1), 1)); } diff --git a/Utils/Compression/LZW.php b/Utils/Compression/LZW.php index 80e58b98f..a48757e32 100644 --- a/Utils/Compression/LZW.php +++ b/Utils/Compression/LZW.php @@ -40,7 +40,7 @@ class LZW implements CompressionInterface } $length = strlen($source); - for ($i = 0; $i < $length; $i++) { + for ($i = 0; $i < $length; ++$i) { $c = $source[$i]; $wc = $w . $c; @@ -70,7 +70,7 @@ class LZW implements CompressionInterface $entry = ''; $dictSize = 256; - for ($i = 0; $i < 256; $i++) { + for ($i = 0; $i < 256; ++$i) { $dictionary[$i] = chr($i); } @@ -78,7 +78,7 @@ class LZW implements CompressionInterface $result = $dictionary[$compressed[0]]; $count = count($compressed); - for ($i = 1; $i < $count; $i++) { + for ($i = 1; $i < $count; ++$i) { $k = $compressed[$i]; if ($dictionary[$k]) { diff --git a/Utils/Converter/Numeric.php b/Utils/Converter/Numeric.php index 20b206f54..39314c9a7 100644 --- a/Utils/Converter/Numeric.php +++ b/Utils/Converter/Numeric.php @@ -75,7 +75,7 @@ class Numeric if ($toBaseInput === '0123456789') { $newOutput = 0; - for ($i = 1; $i <= $numberLen; $i++) { + for ($i = 1; $i <= $numberLen; ++$i) { $newOutput = bcadd( (string) $newOutput, bcmul( @@ -168,7 +168,7 @@ class Numeric { $alpha = ''; - for ($i = 1; $number >= 0 && $i < 10; $i++) { + for ($i = 1; $number >= 0 && $i < 10; ++$i) { $alpha = chr(0x41 + ($number % pow(26, $i) / pow(26, $i - 1))) . $alpha; $number -= pow(26, $i); } @@ -190,7 +190,7 @@ class Numeric $numeric = 0; $length = strlen($alpha); - for ($i = 0; $i < $length; $i++) { + for ($i = 0; $i < $length; ++$i) { $numeric += pow(26, $i) * (ord($alpha[$length - $i - 1]) - 0x40); } diff --git a/Utils/Encoding/Caesar.php b/Utils/Encoding/Caesar.php index 52e995ac2..96ddd87b1 100644 --- a/Utils/Encoding/Caesar.php +++ b/Utils/Encoding/Caesar.php @@ -49,7 +49,7 @@ class Caesar $length = strlen($source); $keyLength = strlen($key) - 1; - for ($i = 0, $j = 0; $i < $length; $i++, $j++) { + for ($i = 0, $j = 0; $i < $length; ++$i, $j++) { if ($j > $keyLength) { $j = 0; } @@ -75,7 +75,7 @@ class Caesar $length = strlen($raw); $keyLength = strlen($key) - 1; - for ($i = 0, $j = 0; $i < $length; $i++, $j++) { + for ($i = 0, $j = 0; $i < $length; ++$i, $j++) { if ($j > $keyLength) { $j = 0; } diff --git a/Utils/Encoding/XorEncoding.php b/Utils/Encoding/XorEncoding.php index a9b80e173..a5ceec793 100644 --- a/Utils/Encoding/XorEncoding.php +++ b/Utils/Encoding/XorEncoding.php @@ -42,7 +42,7 @@ final class XorEncoding $length = strlen($source); $keyLength = strlen($key) - 1; - for ($i = 0, $j = 0; $i < $length; $i++, $j++) { + for ($i = 0, $j = 0; $i < $length; ++$i, $j++) { if ($j > $keyLength) { $j = 0; } diff --git a/Utils/Git/Repository.php b/Utils/Git/Repository.php index 49164a72c..b12f72e43 100644 --- a/Utils/Git/Repository.php +++ b/Utils/Git/Repository.php @@ -819,7 +819,7 @@ class Repository $count = count($lines); $commits = []; - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { $match = preg_match('/[0-9ABCDEFabcdef]{40}/', $lines[$i], $matches); if ($match !== false && $match !== 0) { @@ -875,7 +875,7 @@ class Repository $commit->setRepository($this); $commit->setBranch($this->branch); - for ($i = 4; $i < $count; $i++) { + for ($i = 4; $i < $count; ++$i) { $commit->addFile($lines[$i]); } diff --git a/Utils/RnG/Phone.php b/Utils/RnG/Phone.php index 945154b05..a62287ec5 100644 --- a/Utils/RnG/Phone.php +++ b/Utils/RnG/Phone.php @@ -54,7 +54,7 @@ class Phone $numberParts = substr_count($layout['struct'], '$'); - for ($i = ($isInt ? 2 : 1); $i < $numberParts; $i++) { + for ($i = ($isInt ? 2 : 1); $i < $numberParts; ++$i) { $numberString = str_replace( '$' . $i, StringUtils::generateString($layout['size'][$i - 1][0], $layout['size'][$i - 1][1], '0123456789'), $numberString diff --git a/Utils/RnG/StringUtils.php b/Utils/RnG/StringUtils.php index 225334a74..6accd9c49 100644 --- a/Utils/RnG/StringUtils.php +++ b/Utils/RnG/StringUtils.php @@ -44,7 +44,7 @@ class StringUtils $charactersLength = strlen($charset); $randomString = ''; - for ($i = 0; $i < $length; $i++) { + for ($i = 0; $i < $length; ++$i) { $randomString .= $charset[mt_rand(0, $charactersLength - 1)]; } diff --git a/Utils/RnG/Text.php b/Utils/RnG/Text.php index 072ff5939..f74461ee4 100644 --- a/Utils/RnG/Text.php +++ b/Utils/RnG/Text.php @@ -160,7 +160,7 @@ class Text $paid = 0; $wordCount = count($words); - for ($i = 0; $i < $length + 1; $i++) { + for ($i = 0; $i < $length + 1; ++$i) { $newSentence = false; $lastChar = substr($text, -1); @@ -318,7 +318,7 @@ class Text $formatting = []; - for ($i = 0; $i < $length; $i++) { + for ($i = 0; $i < $length; ++$i) { $isCursive = (rand(0, 1000) <= 1000 * $probCursive ? true : false); $isBold = (rand(0, 1000) <= 1000 * $probBold ? true : false); $isUline = (rand(0, 1000) <= 1000 * $probUline ? true : false); diff --git a/Utils/StringUtils.php b/Utils/StringUtils.php index 7ebff34fa..9fc3be020 100644 --- a/Utils/StringUtils.php +++ b/Utils/StringUtils.php @@ -336,7 +336,7 @@ class StringUtils $count = 0; $length = strlen($string); - for ($i = 0; $i < $length; $i++) { + for ($i = 0; $i < $length; ++$i) { if ($string[$i] !== $character) { break; } @@ -384,7 +384,7 @@ class StringUtils $l = mb_strlen($input, 'UTF-8'); $unique = []; - for ($i = 0; $i < $l; $i++) { + for ($i = 0; $i < $l; ++$i) { $char = mb_substr($input, $i, 1, 'UTF-8'); if (!array_key_exists($char, $unique)) { diff --git a/Validation/Finance/CreditCard.php b/Validation/Finance/CreditCard.php index d61bdc11b..91ef0af57 100644 --- a/Validation/Finance/CreditCard.php +++ b/Validation/Finance/CreditCard.php @@ -49,7 +49,7 @@ abstract class CreditCard extends ValidatorAbstract // Loop through each digit and do the maths $total = 0; - for ($i = 0; $i < $numberLength; $i++) { + for ($i = 0; $i < $numberLength; ++$i) { $digit = $value[$i]; // Multiply alternate digits by two if ($i % 2 == $parity) { diff --git a/tests/Business/Marketing/NetPromoterScoreTest.php b/tests/Business/Marketing/NetPromoterScoreTest.php index 9d631bcb5..d38d3ef21 100644 --- a/tests/Business/Marketing/NetPromoterScoreTest.php +++ b/tests/Business/Marketing/NetPromoterScoreTest.php @@ -28,15 +28,15 @@ class NetPromoterScoreTest extends \PHPUnit\Framework\TestCase { $nps = new NetPromoterScore(); - for ($i = 0; $i < 10; $i++) { + for ($i = 0; $i < 10; ++$i) { $nps->add(mt_rand(0, 6)); } - for ($i = 0; $i < 30; $i++) { + for ($i = 0; $i < 30; ++$i) { $nps->add(mt_rand(7, 8)); } - for ($i = 0; $i < 60; $i++) { + for ($i = 0; $i < 60; ++$i) { $nps->add(mt_rand(9, 10)); } diff --git a/tests/Math/Geometry/ConvexHull/MonotoneChainTest.php b/tests/Math/Geometry/ConvexHull/MonotoneChainTest.php index e0dad6058..67c69a468 100644 --- a/tests/Math/Geometry/ConvexHull/MonotoneChainTest.php +++ b/tests/Math/Geometry/ConvexHull/MonotoneChainTest.php @@ -22,8 +22,8 @@ class MonotoneChainTest extends \PHPUnit\Framework\TestCase self::assertEquals([['x' => 9, 'y' => 0]], MonotoneChain::createConvexHull([['x' => 9, 'y' => 0]])); $points = []; - for ($i = 0; $i < 10; $i++) { - for ($j = 0; $j < 10; $j++) { + for ($i = 0; $i < 10; ++$i) { + for ($j = 0; $j < 10; ++$j) { $points[] = ['x' => $i, 'y' => $j]; } } diff --git a/tests/Utils/Encoding/CaesarTest.php b/tests/Utils/Encoding/CaesarTest.php index 4c6c5a47b..5f852f8d1 100644 --- a/tests/Utils/Encoding/CaesarTest.php +++ b/tests/Utils/Encoding/CaesarTest.php @@ -20,7 +20,7 @@ class CaesarTest extends \PHPUnit\Framework\TestCase { public function testVolume() { - for ($i = 0; $i < 100; $i++) { + for ($i = 0; $i < 100; ++$i) { $raw = StringUtils::generateString(1, 100); $key = StringUtils::generateString(1, 100); diff --git a/tests/Utils/Encoding/GrayTest.php b/tests/Utils/Encoding/GrayTest.php index 0210eee5c..3338019a9 100644 --- a/tests/Utils/Encoding/GrayTest.php +++ b/tests/Utils/Encoding/GrayTest.php @@ -25,7 +25,7 @@ class GrayTest extends \PHPUnit\Framework\TestCase public function testVolume() { - for ($i = 0; $i < 100; $i++) { + for ($i = 0; $i < 100; ++$i) { $raw = mt_rand(0, 2040140512); self::assertEquals($raw, Gray::decode(Gray::encode($raw))); diff --git a/tests/Utils/Encoding/XorEncodingTest.php b/tests/Utils/Encoding/XorEncodingTest.php index 7ec46a892..6aff308b7 100644 --- a/tests/Utils/Encoding/XorEncodingTest.php +++ b/tests/Utils/Encoding/XorEncodingTest.php @@ -27,7 +27,7 @@ class XorEncodingTest extends \PHPUnit\Framework\TestCase public function testVolume() { - for ($i = 0; $i < 100; $i++) { + for ($i = 0; $i < 100; ++$i) { $raw = StringUtils::generateString(1, 100); $key = StringUtils::generateString(1, 100); diff --git a/tests/Utils/RnG/DateTimeTest.php b/tests/Utils/RnG/DateTimeTest.php index b29fe3249..03053367d 100644 --- a/tests/Utils/RnG/DateTimeTest.php +++ b/tests/Utils/RnG/DateTimeTest.php @@ -19,7 +19,7 @@ class DateTimeTest extends \PHPUnit\Framework\TestCase { public function testRnG() { - for ($i = 0; $i < 100; $i++) { + for ($i = 0; $i < 100; ++$i) { $dateMin = new \DateTime(); $dateMax = new \DateTime(); diff --git a/tests/Utils/RnG/StringUtilsTest.php b/tests/Utils/RnG/StringUtilsTest.php index e31dd02dc..73142c759 100644 --- a/tests/Utils/RnG/StringUtilsTest.php +++ b/tests/Utils/RnG/StringUtilsTest.php @@ -26,7 +26,7 @@ class StringUtilsTest extends \PHPUnit\Framework\TestCase $outOfBounds = false; $randomness = 0; - for ($i = 0; $i < 10000; $i++) { + for ($i = 0; $i < 10000; ++$i) { $random = StringUtils::generateString(5, 12, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_?><|;"'); if (strlen($random) > 12 || strlen($random) < 5) {