Improve increments

This commit is contained in:
Dennis Eichhorn 2018-02-10 21:52:20 +01:00
parent 1fe4b18266
commit e3b14015fc
52 changed files with 119 additions and 118 deletions

View File

@ -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);
}

View File

@ -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];
}

View File

@ -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]);
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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];
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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) {

View File

@ -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]);

View File

@ -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;

View File

@ -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];
}

View File

@ -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);

View File

@ -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]));
}

View File

@ -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;
}

View File

@ -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]);
}

View File

@ -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]);
}

View File

@ -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]);
}

View File

@ -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]);
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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];
}

View File

@ -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);
}

View File

@ -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];
}

View File

@ -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)) {

View File

@ -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));
}

View File

@ -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);
}

View File

@ -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])) {

View File

@ -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];
}

View File

@ -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));
}

View File

@ -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]) {

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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]);
}

View File

@ -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

View File

@ -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)];
}

View File

@ -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);

View File

@ -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)) {

View File

@ -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) {

View File

@ -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));
}

View File

@ -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];
}
}

View File

@ -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);

View File

@ -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)));

View File

@ -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);

View File

@ -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();

View File

@ -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) {