use global namespace

This commit is contained in:
Dennis Eichhorn 2018-08-24 13:06:04 +02:00
parent feb652a026
commit 8a2bed5877
219 changed files with 699 additions and 699 deletions

View File

@ -320,7 +320,7 @@ class Account implements ArrayableInterface, \JsonSerializable
*/ */
public function hasPermission(int $permission, int $unit = null, string $app = null, string $module = null, int $type = null, int $element = null, int $component = null) : bool public function hasPermission(int $permission, int $unit = null, string $app = null, string $module = null, int $type = null, int $element = null, int $component = null) : bool
{ {
$app = $app !== null ? strtolower($app) : $app; $app = $app !== null ? \strtolower($app) : $app;
foreach ($this->permissions as $p) { foreach ($this->permissions as $p) {
if (($p->getUnit() === $unit || $p->getUnit() === null || $unit === null) if (($p->getUnit() === $unit || $p->getUnit() === null || $unit === null)

View File

@ -131,6 +131,6 @@ final class AccountManager implements \Countable
*/ */
public function count() : int public function count() : int
{ {
return count($this->accounts); return \count($this->accounts);
} }
} }

View File

@ -111,6 +111,6 @@ final class AssetManager implements \Countable
*/ */
public function count() : int public function count() : int
{ {
return count($this->assets); return \count($this->assets);
} }
} }

View File

@ -176,7 +176,7 @@ final class Depreciation
*/ */
public static function getGeometicProgressivDepreciationRate(float $start, float $residual, int $duration) : float public static function getGeometicProgressivDepreciationRate(float $start, float $residual, int $duration) : float
{ {
return (1 - pow($residual / $start, 1 / $duration)); return (1 - \pow($residual / $start, 1 / $duration));
} }
/** /**
@ -234,7 +234,7 @@ final class Depreciation
*/ */
public static function getGeometicDegressivDepreciationRate(float $start, float $residual, int $duration) : float public static function getGeometicDegressivDepreciationRate(float $start, float $residual, int $duration) : float
{ {
return (1 - pow($residual / $start, 1 / $duration)); return (1 - \pow($residual / $start, 1 / $duration));
} }
/** /**

View File

@ -48,7 +48,7 @@ final class FinanceFormulas
*/ */
public static function getAnnualPercentageYield(float $r, int $n) : float public static function getAnnualPercentageYield(float $r, int $n) : float
{ {
return pow(1 + $r / $n, $n) - 1; return \pow(1 + $r / $n, $n) - 1;
} }
/** /**
@ -65,7 +65,7 @@ final class FinanceFormulas
*/ */
public static function getStateAnnualInterestRateOfAPY(float $apy, int $n) : float public static function getStateAnnualInterestRateOfAPY(float $apy, int $n) : float
{ {
return (pow($apy + 1, 1 / $n) - 1) * $n; return (\pow($apy + 1, 1 / $n) - 1) * $n;
} }
/** /**
@ -81,7 +81,7 @@ final class FinanceFormulas
*/ */
public static function getFutureValueOfAnnuity(float $P, float $r, int $n) : float public static function getFutureValueOfAnnuity(float $P, float $r, int $n) : float
{ {
return $P * (pow(1 + $r, $n) - 1) / $r; return $P * (\pow(1 + $r, $n) - 1) / $r;
} }
/** /**
@ -97,7 +97,7 @@ final class FinanceFormulas
*/ */
public static function getNumberOfPeriodsOfFVA(float $fva, float $P, float $r) : int public static function getNumberOfPeriodsOfFVA(float $fva, float $P, float $r) : int
{ {
return (int) round(log($fva / $P * $r + 1) / log(1 + $r)); return (int) \round(\log($fva / $P * $r + 1) / \log(1 + $r));
} }
/** /**
@ -113,7 +113,7 @@ final class FinanceFormulas
*/ */
public static function getPeriodicPaymentOfFVA(float $fva, float $r, int $n) : float public static function getPeriodicPaymentOfFVA(float $fva, float $r, int $n) : float
{ {
return $fva / ((pow(1 + $r, $n) - 1) / $r); return $fva / ((\pow(1 + $r, $n) - 1) / $r);
} }
/** /**
@ -129,7 +129,7 @@ final class FinanceFormulas
*/ */
public static function getFutureValueOfAnnuityConinuousCompounding(float $cf, float $r, int $t) : float public static function getFutureValueOfAnnuityConinuousCompounding(float $cf, float $r, int $t) : float
{ {
return $cf * (exp($r * $t) - 1) / (exp($r) - 1); return $cf * (\exp($r * $t) - 1) / (\exp($r) - 1);
} }
/** /**
@ -145,7 +145,7 @@ final class FinanceFormulas
*/ */
public static function getCashFlowOfFVACC(float $fvacc, float $r, int $t) : float public static function getCashFlowOfFVACC(float $fvacc, float $r, int $t) : float
{ {
return $fvacc / ((exp($r * $t) - 1) / (exp($r) - 1)); return $fvacc / ((\exp($r * $t) - 1) / (\exp($r) - 1));
} }
/** /**
@ -161,7 +161,7 @@ final class FinanceFormulas
*/ */
public static function getTimeOfFVACC(float $fvacc, float $cf, float $r) : int public static function getTimeOfFVACC(float $fvacc, float $cf, float $r) : int
{ {
return (int) round(log($fvacc / $cf * (exp($r) - 1) + 1) / $r); return (int) \round(\log($fvacc / $cf * (\exp($r) - 1) + 1) / $r);
} }
/** /**
@ -177,7 +177,7 @@ final class FinanceFormulas
*/ */
public static function getAnnuityPaymentPV(float $pv, float $r, int $n) : float public static function getAnnuityPaymentPV(float $pv, float $r, int $n) : float
{ {
return $r * $pv / (1 - pow(1 + $r, -$n)); return $r * $pv / (1 - \pow(1 + $r, -$n));
} }
/** /**
@ -193,7 +193,7 @@ final class FinanceFormulas
*/ */
public static function getNumberOfAPPV(float $p, float $pv, float $r) : int public static function getNumberOfAPPV(float $p, float $pv, float $r) : int
{ {
return (int) round(-log(-($r * $pv / $p - 1)) / log(1 + $r)); return (int) \round(-log(-($r * $pv / $p - 1)) / \log(1 + $r));
} }
/** /**
@ -209,7 +209,7 @@ final class FinanceFormulas
*/ */
public static function getPresentValueOfAPPV(float $p, float $r, int $n) : float public static function getPresentValueOfAPPV(float $p, float $r, int $n) : float
{ {
return $p / $r * (1 - pow(1 + $r, -$n)); return $p / $r * (1 - \pow(1 + $r, -$n));
} }
/** /**
@ -225,7 +225,7 @@ final class FinanceFormulas
*/ */
public static function getAnnuityPaymentFV(float $fv, float $r, int $n) : float public static function getAnnuityPaymentFV(float $fv, float $r, int $n) : float
{ {
return $r * $fv / (pow(1 + $r, $n) - 1); return $r * $fv / (\pow(1 + $r, $n) - 1);
} }
/** /**
@ -241,7 +241,7 @@ final class FinanceFormulas
*/ */
public static function getNumberOfAPFV(float $p, float $fv, float $r) : int public static function getNumberOfAPFV(float $p, float $fv, float $r) : int
{ {
return (int) round(log($fv * $r / $p + 1) / log(1 + $r)); return (int) \round(\log($fv * $r / $p + 1) / \log(1 + $r));
} }
/** /**
@ -257,7 +257,7 @@ final class FinanceFormulas
*/ */
public static function getFutureValueOfAPFV(float $p, float $r, int $n) : float public static function getFutureValueOfAPFV(float $p, float $r, int $n) : float
{ {
return $p / $r * (pow(1 + $r, $n) - 1); return $p / $r * (\pow(1 + $r, $n) - 1);
} }
/** /**
@ -272,7 +272,7 @@ final class FinanceFormulas
*/ */
public static function getAnnutiyPaymentFactorPV(float $r, int $n) : float public static function getAnnutiyPaymentFactorPV(float $r, int $n) : float
{ {
return $r / (1 - pow(1 + $r, -$n)); return $r / (1 - \pow(1 + $r, -$n));
} }
/** /**
@ -287,7 +287,7 @@ final class FinanceFormulas
*/ */
public static function getNumberOfAPFPV(float $p, float $r) : int public static function getNumberOfAPFPV(float $p, float $r) : int
{ {
return (int) round(-log(-($r / $p - 1)) / log(1 + $r)); return (int) \round(-log(-($r / $p - 1)) / \log(1 + $r));
} }
/** /**
@ -303,7 +303,7 @@ final class FinanceFormulas
*/ */
public static function getPresentValueOfAnnuity(float $P, float $r, int $n) : float public static function getPresentValueOfAnnuity(float $P, float $r, int $n) : float
{ {
return $P * (1 - pow(1 + $r, -$n)) / $r; return $P * (1 - \pow(1 + $r, -$n)) / $r;
} }
/** /**
@ -319,7 +319,7 @@ final class FinanceFormulas
*/ */
public static function getNumberOfPeriodsOfPVA(float $pva, float $P, float $r) : int public static function getNumberOfPeriodsOfPVA(float $pva, float $P, float $r) : int
{ {
return (int) round(-log(-($pva / $P * $r - 1)) / log(1 + $r)); return (int) \round(-log(-($pva / $P * $r - 1)) / \log(1 + $r));
} }
/** /**
@ -335,7 +335,7 @@ final class FinanceFormulas
*/ */
public static function getPeriodicPaymentOfPVA(float $pva, float $r, int $n) : float public static function getPeriodicPaymentOfPVA(float $pva, float $r, int $n) : float
{ {
return $pva / ((1 - pow(1 + $r, -$n)) / $r); return $pva / ((1 - \pow(1 + $r, -$n)) / $r);
} }
/** /**
@ -350,7 +350,7 @@ final class FinanceFormulas
*/ */
public static function getPresentValueAnnuityFactor(float $r, int $n) : float public static function getPresentValueAnnuityFactor(float $r, int $n) : float
{ {
return (1 - pow(1 + $r, -$n)) / $r; return (1 - \pow(1 + $r, -$n)) / $r;
} }
/** /**
@ -365,7 +365,7 @@ final class FinanceFormulas
*/ */
public static function getPeriodsOfPVAF(float $p, float $r) : int public static function getPeriodsOfPVAF(float $p, float $r) : int
{ {
return (int) round(-log(-($p * $r - 1)) / log(1 + $r)); return (int) \round(-log(-($p * $r - 1)) / \log(1 + $r));
} }
/** /**
@ -381,7 +381,7 @@ final class FinanceFormulas
*/ */
public static function getPresentValueOfAnnuityDue(float $P, float $r, int $n) : float public static function getPresentValueOfAnnuityDue(float $P, float $r, int $n) : float
{ {
return $P + $P * ((1 - pow(1 + $r, -($n - 1))) / $r); return $P + $P * ((1 - \pow(1 + $r, -($n - 1))) / $r);
} }
/** /**
@ -399,7 +399,7 @@ final class FinanceFormulas
*/ */
public static function getPeriodicPaymentOfPVAD(float $PV, float $r, int $n) : float public static function getPeriodicPaymentOfPVAD(float $PV, float $r, int $n) : float
{ {
return $PV * $r / (1 - pow(1 + $r, -$n)) * 1 / (1 + $r); return $PV * $r / (1 - \pow(1 + $r, -$n)) * 1 / (1 + $r);
} }
/** /**
@ -415,7 +415,7 @@ final class FinanceFormulas
*/ */
public static function getPeriodsOfPVAD(float $PV, float $P, float $r) : int public static function getPeriodsOfPVAD(float $PV, float $P, float $r) : int
{ {
return (int) round(-(log(-($PV - $P) / $P * $r + 1) / log(1 + $r) - 1)); return (int) \round(-(\log(-($PV - $P) / $P * $r + 1) / \log(1 + $r) - 1));
} }
/** /**
@ -431,7 +431,7 @@ final class FinanceFormulas
*/ */
public static function getFutureValueOfAnnuityDue(float $P, float $r, int $n) : float public static function getFutureValueOfAnnuityDue(float $P, float $r, int $n) : float
{ {
return (1 + $r) * $P * (pow(1 + $r, $n) - 1) / $r; return (1 + $r) * $P * (\pow(1 + $r, $n) - 1) / $r;
} }
/** /**
@ -447,7 +447,7 @@ final class FinanceFormulas
*/ */
public static function getPeriodicPaymentOfFVAD(float $FV, float $r, int $n) : float public static function getPeriodicPaymentOfFVAD(float $FV, float $r, int $n) : float
{ {
return $FV / ((1 + $r) * ((pow(1 + $r, $n) - 1) / $r)); return $FV / ((1 + $r) * ((\pow(1 + $r, $n) - 1) / $r));
} }
/** /**
@ -463,7 +463,7 @@ final class FinanceFormulas
*/ */
public static function getPeriodsOfFVAD(float $FV, float $P, float $r) : int public static function getPeriodsOfFVAD(float $FV, float $P, float $r) : int
{ {
return (int) round(log($FV / (1 + $r) / $P * $r + 1) / log(1 + $r)); return (int) \round(\log($FV / (1 + $r) / $P * $r + 1) / \log(1 + $r));
} }
/** /**
@ -539,7 +539,7 @@ final class FinanceFormulas
*/ */
public static function getCompoundInterest(float $P, float $r, int $n) : float public static function getCompoundInterest(float $P, float $r, int $n) : float
{ {
return $P * (pow(1 + $r, $n) - 1); return $P * (\pow(1 + $r, $n) - 1);
} }
/** /**
@ -555,7 +555,7 @@ final class FinanceFormulas
*/ */
public static function getPrincipalOfCompundInterest(float $C, float $r, int $n) : float public static function getPrincipalOfCompundInterest(float $C, float $r, int $n) : float
{ {
return $C / (pow(1 + $r, $n) - 1); return $C / (\pow(1 + $r, $n) - 1);
} }
/** /**
@ -571,7 +571,7 @@ final class FinanceFormulas
*/ */
public static function getPeriodsOfCompundInterest(float $P, float $C, float $r) : float public static function getPeriodsOfCompundInterest(float $P, float $C, float $r) : float
{ {
return log($C / $P + 1) / log(1 + $r); return \log($C / $P + 1) / \log(1 + $r);
} }
/** /**
@ -587,7 +587,7 @@ final class FinanceFormulas
*/ */
public static function getContinuousCompounding(float $P, float $r, int $t) : float public static function getContinuousCompounding(float $P, float $r, int $t) : float
{ {
return $P * exp($r * $t); return $P * \exp($r * $t);
} }
/** /**
@ -603,7 +603,7 @@ final class FinanceFormulas
*/ */
public static function getPrincipalOfContinuousCompounding(float $C, float $r, int $t) : float public static function getPrincipalOfContinuousCompounding(float $C, float $r, int $t) : float
{ {
return $C / exp($r * $t); return $C / \exp($r * $t);
} }
/** /**
@ -619,7 +619,7 @@ final class FinanceFormulas
*/ */
public static function getPeriodsOfContinuousCompounding(float $P, float $C, float $r) : float public static function getPeriodsOfContinuousCompounding(float $P, float $C, float $r) : float
{ {
return log($C / $P) / $r; return \log($C / $P) / $r;
} }
/** /**
@ -635,7 +635,7 @@ final class FinanceFormulas
*/ */
public static function getRateOfContinuousCompounding(float $P, float $C, float $t) : float public static function getRateOfContinuousCompounding(float $P, float $C, float $t) : float
{ {
return log($C / $P) / $t; return \log($C / $P) / $t;
} }
/** /**
@ -740,7 +740,7 @@ final class FinanceFormulas
*/ */
public static function getDiscountedPaybackPeriod(float $CF, float $O1, float $r) : float public static function getDiscountedPaybackPeriod(float $CF, float $O1, float $r) : float
{ {
return log(1 / (1 - $O1 * $r / $CF)) / log(1 + $r); return \log(1 / (1 - $O1 * $r / $CF)) / \log(1 + $r);
} }
/** /**
@ -754,7 +754,7 @@ final class FinanceFormulas
*/ */
public static function getDoublingTime(float $r) : float public static function getDoublingTime(float $r) : float
{ {
return log(2) / log(1 + $r); return \log(2) / \log(1 + $r);
} }
/** /**
@ -768,7 +768,7 @@ final class FinanceFormulas
*/ */
public static function getDoublingRate(float $t) : float public static function getDoublingRate(float $t) : float
{ {
return exp(log(2) / $t) - 1; return \exp(\log(2) / $t) - 1;
} }
/** /**
@ -782,7 +782,7 @@ final class FinanceFormulas
*/ */
public static function getDoublingTimeContinuousCompounding(float $r) : float public static function getDoublingTimeContinuousCompounding(float $r) : float
{ {
return log(2) / $r; return \log(2) / $r;
} }
/** /**
@ -798,7 +798,7 @@ final class FinanceFormulas
*/ */
public static function getEquivalentAnnualAnnuity(float $NPV, float $r, int $n) : float public static function getEquivalentAnnualAnnuity(float $NPV, float $r, int $n) : float
{ {
return $r * $NPV / (1 - pow(1 + $r, -$n)); return $r * $NPV / (1 - \pow(1 + $r, -$n));
} }
/** /**
@ -814,7 +814,7 @@ final class FinanceFormulas
*/ */
public static function getPeriodsOfEAA(float $C, float $NPV, float $r) : int public static function getPeriodsOfEAA(float $C, float $NPV, float $r) : int
{ {
return (int) round(-log(1 - $r * $NPV / $C) / log(1 + $r)); return (int) \round(-log(1 - $r * $NPV / $C) / \log(1 + $r));
} }
/** /**
@ -830,7 +830,7 @@ final class FinanceFormulas
*/ */
public static function getNetPresentValueOfEAA(float $C, float $r, int $n) : float public static function getNetPresentValueOfEAA(float $C, float $r, int $n) : float
{ {
return $C * (1 - pow(1 + $r, -$n)) / $r; return $C * (1 - \pow(1 + $r, -$n)) / $r;
} }
/** /**
@ -886,7 +886,7 @@ final class FinanceFormulas
*/ */
public static function getFutureValue(float $C, float $r, int $n) : float public static function getFutureValue(float $C, float $r, int $n) : float
{ {
return $C * pow(1 + $r, $n); return $C * \pow(1 + $r, $n);
} }
/** /**
@ -902,7 +902,7 @@ final class FinanceFormulas
*/ */
public static function getFutureValueContinuousCompounding(float $PV, float $r, int $t) : float public static function getFutureValueContinuousCompounding(float $PV, float $r, int $t) : float
{ {
return $PV * exp($r * $t); return $PV * \exp($r * $t);
} }
/** /**
@ -922,7 +922,7 @@ final class FinanceFormulas
*/ */
public static function getFutureValueFactor(float $r, int $n) : float public static function getFutureValueFactor(float $r, int $n) : float
{ {
return pow(1 + $r, $n); return \pow(1 + $r, $n);
} }
/** /**
@ -953,7 +953,7 @@ final class FinanceFormulas
*/ */
public static function getGrowingAnnuityFV(float $P, float $r, float $g, int $n) : float public static function getGrowingAnnuityFV(float $P, float $r, float $g, int $n) : float
{ {
return $P * (pow(1 + $r, $n) - pow(1 + $g, $n)) / ($r - $g); return $P * (\pow(1 + $r, $n) - \pow(1 + $g, $n)) / ($r - $g);
} }
/** /**
@ -970,7 +970,7 @@ final class FinanceFormulas
*/ */
public static function getGrowingAnnuityPaymentPV(float $PV, float $r, float $g, int $n) : float public static function getGrowingAnnuityPaymentPV(float $PV, float $r, float $g, int $n) : float
{ {
return $PV * ($r - $g) / (1 - pow((1 + $g) / (1 + $r), $n)); return $PV * ($r - $g) / (1 - \pow((1 + $g) / (1 + $r), $n));
} }
/** /**
@ -987,7 +987,7 @@ final class FinanceFormulas
*/ */
public static function getGrowingAnnuityPaymentFV(float $FV, float $r, float $g, int $n) : float public static function getGrowingAnnuityPaymentFV(float $FV, float $r, float $g, int $n) : float
{ {
return $FV * ($r - $g) / (pow(1 + $r, $n) - pow(1 + $g, $n)); return $FV * ($r - $g) / (\pow(1 + $r, $n) - \pow(1 + $g, $n));
} }
/** /**
@ -1004,7 +1004,7 @@ final class FinanceFormulas
*/ */
public static function getGrowingAnnuityPV(float $P, float $r, float $g, int $n) : float public static function getGrowingAnnuityPV(float $P, float $r, float $g, int $n) : float
{ {
return $P / ($r - $g) * (1 - pow((1 + $g) / (1 + $r), $n)); return $P / ($r - $g) * (1 - \pow((1 + $g) / (1 + $r), $n));
} }
/** /**
@ -1067,7 +1067,7 @@ final class FinanceFormulas
*/ */
public static function getNetPresentValue(array $C, float $r) : float public static function getNetPresentValue(array $C, float $r) : float
{ {
$count = count($C); $count = \count($C);
if ($count === 0) { if ($count === 0) {
throw new \UnexpectedValueException((string) $count); throw new \UnexpectedValueException((string) $count);
@ -1076,7 +1076,7 @@ final class FinanceFormulas
$npv = -$C[0]; $npv = -$C[0];
for ($i = 1; $i < $count; ++$i) { for ($i = 1; $i < $count; ++$i) {
$npv += $C[$i] / pow(1 + $r, $i); $npv += $C[$i] / \pow(1 + $r, $i);
} }
return $npv; return $npv;
@ -1125,7 +1125,7 @@ final class FinanceFormulas
*/ */
public static function getNumberOfPeriodsPVFV(float $FV, float $PV, float $r) : float public static function getNumberOfPeriodsPVFV(float $FV, float $PV, float $r) : float
{ {
return log($FV / $PV) / log(1 + $r); return \log($FV / $PV) / \log(1 + $r);
} }
/** /**
@ -1171,7 +1171,7 @@ final class FinanceFormulas
*/ */
public static function getPresentValue(float $C, float $r, int $n) : float public static function getPresentValue(float $C, float $r, int $n) : float
{ {
return $C / pow(1 + $r, $n); return $C / \pow(1 + $r, $n);
} }
/** /**
@ -1187,7 +1187,7 @@ final class FinanceFormulas
*/ */
public static function getPresentValueContinuousCompounding(float $C, float $r, int $t) : float public static function getPresentValueContinuousCompounding(float $C, float $r, int $t) : float
{ {
return $C / exp($r * $t); return $C / \exp($r * $t);
} }
/** /**
@ -1202,7 +1202,7 @@ final class FinanceFormulas
*/ */
public static function getPresentValueFactor(float $r, int $n) : float public static function getPresentValueFactor(float $r, int $n) : float
{ {
return 1 / pow(1 + $r, $n); return 1 / \pow(1 + $r, $n);
} }
/** /**
@ -1386,7 +1386,7 @@ final class FinanceFormulas
*/ */
public static function getSimpleInterestTime(float $I, float $P, float $r) : int public static function getSimpleInterestTime(float $I, float $P, float $r) : int
{ {
return (int) round($I / ($P * $r)); return (int) \round($I / ($P * $r));
} }
/** /**

View File

@ -110,7 +110,7 @@ class ARIMA
private function getPrelimRemainder(array $centeredRatios, array $prelimSeasonalComponent) : array private function getPrelimRemainder(array $centeredRatios, array $prelimSeasonalComponent) : array
{ {
$remainder = []; $remainder = [];
$count = count($prelimSeasonalComponent); $count = \count($prelimSeasonalComponent);
for ($i = 0; $i < $count; ++$i) { for ($i = 0; $i < $count; ++$i) {
// +1 since 3x3 MA // +1 since 3x3 MA
@ -136,7 +136,7 @@ class ARIMA
private function getModifiedCenteredRatios(array $seasonal, array $remainder) : array private function getModifiedCenteredRatios(array $seasonal, array $remainder) : array
{ {
$centeredRatio = []; $centeredRatio = [];
$count = count($seasonal); $count = \count($seasonal);
for ($i = 0; $i < $count; ++$i) { for ($i = 0; $i < $count; ++$i) {
// +1 since 3x3 MA // +1 since 3x3 MA
@ -148,7 +148,7 @@ class ARIMA
private function getTrendCycleEstimation(array $seasonal) : array private function getTrendCycleEstimation(array $seasonal) : array
{ {
$count = count($seasonal); $count = \count($seasonal);
if ($count >= 12) { if ($count >= 12) {
$weight = Average::MAH23; $weight = Average::MAH23;
@ -166,8 +166,8 @@ class ARIMA
private function getSeasonalAdjustedSeries(array $seasonal) : array private function getSeasonalAdjustedSeries(array $seasonal) : array
{ {
$adjusted = []; $adjusted = [];
$count = count($seasonal); $count = \count($seasonal);
$start = ClassicalDecomposition::getStartOfDecomposition(count($this->data), $count); $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]; $adjusted[] = $this->data[$start + $i] / $seasonal[$i];
@ -189,7 +189,7 @@ class ARIMA
private function getModifiedData(array $trendCycleComponent, array $seasonalAdjustedSeries, array $remainder) : array private function getModifiedData(array $trendCycleComponent, array $seasonalAdjustedSeries, array $remainder) : array
{ {
$data = []; $data = [];
$count = count($trendCycleComponent); $count = \count($trendCycleComponent);
for ($i = 0; $i < $count; ++$i) { for ($i = 0; $i < $count; ++$i) {
$data[] = $trendCycleComponent[$i] * $seasonalAdjustedSeries[$i] * $remainder[$i]; $data[] = $trendCycleComponent[$i] * $seasonalAdjustedSeries[$i] * $remainder[$i];

View File

@ -92,7 +92,7 @@ class ClassicalDecomposition
$this->data = $data; $this->data = $data;
$this->order = $order; $this->order = $order;
$this->dataSize = count($data); $this->dataSize = \count($data);
} }
/** /**
@ -148,8 +148,8 @@ class ClassicalDecomposition
public static function computeDetrendedSeries(array $data, array $trendCycleComponent, int $mode) : array public static function computeDetrendedSeries(array $data, array $trendCycleComponent, int $mode) : array
{ {
$detrended = []; $detrended = [];
$count = count($trendCycleComponent); $count = \count($trendCycleComponent);
$start = self::getStartOfDecomposition(count($data), $count); $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]; $detrended[] = $mode === self::ADDITIVE ? $data[$start + $i] - $trendCycleComponent[$i] : $data[$start + $i] / $trendCycleComponent[$i];
@ -190,7 +190,7 @@ class ClassicalDecomposition
private function computeSeasonalComponent(array $detrendedSeries, int $order) : array private function computeSeasonalComponent(array $detrendedSeries, int $order) : array
{ {
$seasonalComponent = []; $seasonalComponent = [];
$count = count($detrendedSeries); $count = \count($detrendedSeries);
for ($i = 0; $i < $order; ++$i) { for ($i = 0; $i < $order; ++$i) {
$temp = []; $temp = [];
@ -219,11 +219,11 @@ class ClassicalDecomposition
*/ */
public static function computeRemainderComponent(array $data, array $trendCycleComponent, array $seasonalComponent, int $mode = self::ADDITIVE) : array public static function computeRemainderComponent(array $data, array $trendCycleComponent, array $seasonalComponent, int $mode = self::ADDITIVE) : array
{ {
$dataSize = count($data); $dataSize = \count($data);
$remainderComponent = []; $remainderComponent = [];
$count = count($trendCycleComponent); $count = \count($trendCycleComponent);
$start = self::getStartOfDecomposition($dataSize, $count); $start = self::getStartOfDecomposition($dataSize, $count);
$seasons = count($seasonalComponent); $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]); $remainderComponent[] = $mode === self::ADDITIVE ? $data[$start + $i] - $trendCycleComponent[$i] - $seasonalComponent[$i % $seasons] : $data[$start + $i] / ($trendCycleComponent[$i] * $seasonalComponent[$i % $seasons]);

View File

@ -41,7 +41,7 @@ final class Loan
*/ */
public static function getPaymentsOnBalloonLoan(float $PV, float $r, int $n, float $balloon = 0) : float public static function getPaymentsOnBalloonLoan(float $PV, float $r, int $n, float $balloon = 0) : float
{ {
return ($PV - $balloon / pow(1 + $r, $n)) * $r / (1 - pow(1 + $r, -$n)); return ($PV - $balloon / \pow(1 + $r, $n)) * $r / (1 - \pow(1 + $r, -$n));
} }
/** /**
@ -58,7 +58,7 @@ final class Loan
*/ */
public static function getBalloonBalanceOfLoan(float $PV, float $P, float $r, int $n) : float public static function getBalloonBalanceOfLoan(float $PV, float $P, float $r, int $n) : float
{ {
return $PV * pow(1 + $r, $n) - $P * (pow(1 + $r, $n) - 1) / $r; return $PV * \pow(1 + $r, $n) - $P * (\pow(1 + $r, $n) - 1) / $r;
} }
/** /**
@ -74,7 +74,7 @@ final class Loan
*/ */
public static function getLoanPayment(float $PV, float $r, int $n) : float public static function getLoanPayment(float $PV, float $r, int $n) : float
{ {
return $r * $PV / (1 - pow(1 + $r, -$n)); return $r * $PV / (1 - \pow(1 + $r, -$n));
} }
/** /**
@ -91,7 +91,7 @@ final class Loan
*/ */
public static function getRemainingBalanceLoan(float $PV, float $P, float $r, int $n) : float public static function getRemainingBalanceLoan(float $PV, float $P, float $r, int $n) : float
{ {
return $PV * pow(1 + $r, $n) - $P * (pow(1 + $r, $n) - 1) / $r; return $PV * \pow(1 + $r, $n) - $P * (\pow(1 + $r, $n) - 1) / $r;
} }
/** /**

View File

@ -38,7 +38,7 @@ final class Lorenzkurve
$sum1 = 0; $sum1 = 0;
$sum2 = 0; $sum2 = 0;
$i = 1; $i = 1;
$n = count($data); $n = \count($data);
sort($data); sort($data);

View File

@ -353,7 +353,7 @@ final class StockBonds
*/ */
public static function getZeroCouponBondValue(float $F, float $r, int $t) : float public static function getZeroCouponBondValue(float $F, float $r, int $t) : float
{ {
return $F / pow(1 + $r, $t); return $F / \pow(1 + $r, $t);
} }
/** /**
@ -369,6 +369,6 @@ final class StockBonds
*/ */
public static function getZeroCouponBondEffectiveYield(float $F, float $PV, int $n) : float public static function getZeroCouponBondEffectiveYield(float $F, float $PV, int $n) : float
{ {
return pow($F / $PV, 1 / $n) - 1; return \pow($F / $PV, 1 / $n) - 1;
} }
} }

View File

@ -41,7 +41,7 @@ final class Metrics
*/ */
public static function abcScore(int $a, int $b, int $c) : int public static function abcScore(int $a, int $b, int $c) : int
{ {
return (int) sqrt($a * $a + $b * $b + $c * $c); return (int) \sqrt($a * $a + $b * $b + $c * $c);
} }
/** /**

View File

@ -44,10 +44,10 @@ final class MarketShareEstimation
{ {
$sum = 0.0; $sum = 0.0;
for ($i = 0; $i < $participants; ++$i) { for ($i = 0; $i < $participants; ++$i) {
$sum += 1 / pow($i + 1, $modifier); $sum += 1 / \pow($i + 1, $modifier);
} }
return (int) round(pow(1 / ($marketShare * $sum), 1 / $modifier)); return (int) \round(\pow(1 / ($marketShare * $sum), 1 / $modifier));
} }
/** /**
@ -67,9 +67,9 @@ final class MarketShareEstimation
{ {
$sum = 0.0; $sum = 0.0;
for ($i = 0; $i < $participants; ++$i) { for ($i = 0; $i < $participants; ++$i) {
$sum += 1 / pow($i + 1, $modifier); $sum += 1 / \pow($i + 1, $modifier);
} }
return (1 / pow($rank, $modifier)) / $sum; return (1 / \pow($rank, $modifier)) / $sum;
} }
} }

View File

@ -114,7 +114,7 @@ abstract class SettingsAbstract implements OptionsInterface
break; break;
} }
return count($options) > 1 ? $options : reset($options); return \count($options) > 1 ? $options : \reset($options);
} catch (\PDOException $e) { } catch (\PDOException $e) {
$exception = DatabaseExceptionFactory::createException($e); $exception = DatabaseExceptionFactory::createException($e);
$message = DatabaseExceptionFactory::createExceptionMessage($e); $message = DatabaseExceptionFactory::createExceptionMessage($e);

View File

@ -106,7 +106,7 @@ final class CachePool implements DataStoragePoolInterface
} }
if (empty($key)) { if (empty($key)) {
return reset($this->pool); return \reset($this->pool);
} }
return $this->pool[$key]; return $this->pool[$key];

View File

@ -1494,7 +1494,7 @@ class DataMapperAbstract implements DataMapperInterface
if (empty($result)) { if (empty($result)) {
$parts = \explode('\\', $class); $parts = \explode('\\', $class);
$name = $parts[$c = (count($parts) - 1)]; $name = $parts[$c = (\count($parts) - 1)];
$parts[$c] = 'Null' . $name; $parts[$c] = 'Null' . $name;
$class = \implode('\\', $parts); $class = \implode('\\', $parts);
} }
@ -1914,7 +1914,7 @@ class DataMapperAbstract implements DataMapperInterface
$primaryKey = (array) $primaryKey; $primaryKey = (array) $primaryKey;
$fill = (array) $fill; $fill = (array) $fill;
$obj = []; $obj = [];
$fCount = count($fill); $fCount = \count($fill);
$toFill = null; $toFill = null;
foreach ($primaryKey as $key => $value) { foreach ($primaryKey as $key => $value) {
@ -1924,8 +1924,8 @@ class DataMapperAbstract implements DataMapperInterface
} }
if ($fCount > 0) { if ($fCount > 0) {
$toFill = current($fill); $toFill = \current($fill);
next($fill); \next($fill);
} }
$obj[$value] = self::populate(self::getRaw($value), $toFill); $obj[$value] = self::populate(self::getRaw($value), $toFill);
@ -1940,12 +1940,12 @@ class DataMapperAbstract implements DataMapperInterface
self::fillRelations($obj, $relations, --$depth); self::fillRelations($obj, $relations, --$depth);
self::clear(); self::clear();
$countResulsts = count($obj); $countResulsts = \count($obj);
if ($countResulsts === 0) { if ($countResulsts === 0) {
return self::getNullModelObj(); return self::getNullModelObj();
} elseif ($countResulsts === 1) { } elseif ($countResulsts === 1) {
return reset($obj); return \reset($obj);
} }
return $obj; return $obj;
@ -1963,7 +1963,7 @@ class DataMapperAbstract implements DataMapperInterface
$class = static::class; $class = static::class;
$class = \str_replace('Mapper', '', $class); $class = \str_replace('Mapper', '', $class);
$parts = \explode('\\', $class); $parts = \explode('\\', $class);
$name = $parts[$c = (count($parts) - 1)]; $name = $parts[$c = (\count($parts) - 1)];
$parts[$c] = 'Null' . $name; $parts[$c] = 'Null' . $name;
$class = \implode('\\', $parts); $class = \implode('\\', $parts);
@ -2010,7 +2010,7 @@ class DataMapperAbstract implements DataMapperInterface
self::fillRelationsArray($obj, $relations, --$depth); self::fillRelationsArray($obj, $relations, --$depth);
self::clear(); self::clear();
return count($obj) === 1 ? reset($obj) : $obj; return \count($obj) === 1 ? \reset($obj) : $obj;
} }
/** /**
@ -2053,12 +2053,12 @@ class DataMapperAbstract implements DataMapperInterface
$obj[$value] = self::get($toLoad, $relations, $fill, --$depth); $obj[$value] = self::get($toLoad, $relations, $fill, --$depth);
} }
$countResulsts = count($obj); $countResulsts = \count($obj);
if ($countResulsts === 0) { if ($countResulsts === 0) {
return self::getNullModelObj(); return self::getNullModelObj();
} elseif ($countResulsts === 1) { } elseif ($countResulsts === 1) {
return reset($obj); return \reset($obj);
} }
return $obj; return $obj;
@ -2099,7 +2099,7 @@ class DataMapperAbstract implements DataMapperInterface
$obj[$value] = self::get($toLoad, $relations, $fill); $obj[$value] = self::get($toLoad, $relations, $fill);
} }
return count($obj) === 1 ? reset($obj) : $obj; return \count($obj) === 1 ? \reset($obj) : $obj;
} }
/** /**
@ -2591,7 +2591,7 @@ class DataMapperAbstract implements DataMapperInterface
if ($request->getData('id') !== null) { if ($request->getData('id') !== null) {
$result = static::get((int) $request->getData('id')); $result = static::get((int) $request->getData('id'));
} elseif (($filter = ((string) $request->getData('filter'))) !== null) { } elseif (($filter = ((string) $request->getData('filter'))) !== null) {
$filter = strtolower($filter); $filter = \strtolower($filter);
if ($filter === 'all') { if ($filter === 'all') {
$result = static::getAll(); $result = static::getAll();
@ -2709,7 +2709,7 @@ class DataMapperAbstract implements DataMapperInterface
$results = $sth->fetchAll(\PDO::FETCH_ASSOC); $results = $sth->fetchAll(\PDO::FETCH_ASSOC);
return $results && count($results) === 0; return $results && \count($results) === 0;
} }
/** /**

View File

@ -86,7 +86,7 @@ final class DatabasePool implements DataStoragePoolInterface
} }
if (empty($key)) { if (empty($key)) {
return reset($this->pool); return \reset($this->pool);
} }
return $this->pool[$key]; return $this->pool[$key];

View File

@ -93,8 +93,8 @@ abstract class GrammarAbstract
*/ */
public function compileQuery(BuilderAbstract $query) : string public function compileQuery(BuilderAbstract $query) : string
{ {
return trim( return \trim(
implode(' ', \implode(' ',
\array_filter( \array_filter(
$this->compileComponents($query), $this->compileComponents($query),
function ($value) { function ($value) {
@ -186,7 +186,7 @@ abstract class GrammarAbstract
} }
} }
return rtrim($expression, ', '); return \rtrim($expression, ', ');
} }
/** /**
@ -217,7 +217,7 @@ abstract class GrammarAbstract
} }
} }
return rtrim($expression, ', '); return \rtrim($expression, ', ');
} }
/** /**
@ -234,7 +234,7 @@ abstract class GrammarAbstract
*/ */
protected function compileSystem(string $system, string $prefix = '') : string protected function compileSystem(string $system, string $prefix = '') : string
{ {
// todo: this is a bad way to handle select count(*) which doesn't need a prefix. Maybe remove prefixes in total? // todo: this is a bad way to handle select \count(*) which doesn't need a prefix. Maybe remove prefixes in total?
$identifier = $this->systemIdentifier; $identifier = $this->systemIdentifier;
foreach ($this->specialKeywords as $keyword) { foreach ($this->specialKeywords as $keyword) {
@ -245,7 +245,7 @@ abstract class GrammarAbstract
} }
// todo: move remaining * test also here not just if .* but also if * (should be done in else?) // todo: move remaining * test also here not just if .* but also if * (should be done in else?)
if (count($split = \explode('.', $system)) === 2) { if (\count($split = \explode('.', $system)) === 2) {
$system = $split[1] === '*' ? $split[1] : $this->compileSystem($split[1]); $system = $split[1] === '*' ? $split[1] : $this->compileSystem($split[1]);
return $this->compileSystem($prefix . $split[0]) . '.' . $system; return $this->compileSystem($prefix . $split[0]) . '.' . $system;

View File

@ -819,7 +819,7 @@ final class Builder extends BuilderAbstract
*/ */
public function count(string $table = '*') : Builder public function count(string $table = '*') : Builder
{ {
// todo: don't do this as string, create new object new Count(); this can get handled by the grammar parser WAY better // todo: don't do this as string, create new object new \count(); this can get handled by the grammar parser WAY better
return $this->select('COUNT(' . $table . ')'); return $this->select('COUNT(' . $table . ')');
} }
@ -949,10 +949,10 @@ final class Builder extends BuilderAbstract
*/ */
public function value($value, string $type = 'string') : Builder public function value($value, string $type = 'string') : Builder
{ {
end($this->values); \end($this->values);
$key = key($this->values); $key = \key($this->values);
$this->values[$key][] = $value; $this->values[$key][] = $value;
reset($this->values); \reset($this->values);
return $this; return $this;
} }
@ -985,7 +985,7 @@ final class Builder extends BuilderAbstract
*/ */
public function set($set, string $type = 'string') : Builder public function set($set, string $type = 'string') : Builder
{ {
$this->sets[key($set)] = current($set); $this->sets[key($set)] = \current($set);
return $this; return $this;
} }

View File

@ -122,7 +122,7 @@ class Grammar extends GrammarAbstract
/* Loop all possible query components and if they exist compile them. */ /* Loop all possible query components and if they exist compile them. */
foreach ($components as $component) { foreach ($components as $component) {
if (isset($query->{$component}) && !empty($query->{$component})) { if (isset($query->{$component}) && !empty($query->{$component})) {
$sql[$component] = $this->{'compile' . ucfirst($component)}($query, $query->{$component}); $sql[$component] = $this->{'compile' . \ucfirst($component)}($query, $query->{$component});
} }
} }
@ -286,7 +286,7 @@ class Grammar extends GrammarAbstract
if (\is_string($element['column'])) { if (\is_string($element['column'])) {
// handle bug when no table is specified in the where column // handle bug when no table is specified in the where column
if (count($query->from) === 1 && \stripos($element['column'], '.') === false) { if (\count($query->from) === 1 && \stripos($element['column'], '.') === false) {
$element['column'] = $query->from[0] . '.' . $element['column']; $element['column'] = $query->from[0] . '.' . $element['column'];
} }
@ -359,7 +359,7 @@ class Grammar extends GrammarAbstract
} elseif ($value instanceof Column) { } elseif ($value instanceof Column) {
return $this->compileSystem($value->getColumn(), $prefix); return $this->compileSystem($value->getColumn(), $prefix);
} else { } else {
throw new \InvalidArgumentException(gettype($value)); throw new \InvalidArgumentException(\gettype($value));
} }
} }

View File

@ -53,6 +53,6 @@ class MysqlGrammar extends Grammar
$expression = '*'; $expression = '*';
} }
return 'SELECT ' . $expression . ' ' . $this->compileFrom($query, $query->from) . ' ORDER BY RAND() ' . $this->compileLimit($query, $query->limit); return 'SELECT ' . $expression . ' ' . $this->compileFrom($query, $query->from) . ' ORDER BY \rand() ' . $this->compileLimit($query, $query->limit);
} }
} }

View File

@ -73,7 +73,7 @@ class Grammar extends GrammarAbstract
/* Loop all possible query components and if they exist compile them. */ /* Loop all possible query components and if they exist compile them. */
foreach ($components as $component) { foreach ($components as $component) {
if (isset($query->{$component}) && !empty($query->{$component})) { if (isset($query->{$component}) && !empty($query->{$component})) {
$sql[$component] = $this->{'compile' . ucfirst($component)}($query, $query->{$component}); $sql[$component] = $this->{'compile' . \ucfirst($component)}($query, $query->{$component});
} }
} }

View File

@ -66,9 +66,9 @@ class Builder
private function createTable($node) : array private function createTable($node) : array
{ {
if (strtolower($node->tagName) === 'table') { if (\strtolower($node->tagName) === 'table') {
return $this->createTableFromTable(); return $this->createTableFromTable();
} elseif (strtolower($node->tagName) === 'li') { } elseif (\strtolower($node->tagName) === 'li') {
return $this->createTableFromList(); return $this->createTableFromList();
} else { } else {
return $this->createTableFromContent(); return $this->createTableFromContent();

View File

@ -109,7 +109,7 @@ final class Dispatcher
throw new PathException($path); throw new PathException($path);
} }
if (($c = count($dispatch)) === 3) { if (($c = \count($dispatch)) === 3) {
/* Handling static functions */ /* Handling static functions */
$function = $dispatch[0] . '::' . $dispatch[2]; $function = $dispatch[0] . '::' . $dispatch[2];
@ -183,7 +183,7 @@ final class Dispatcher
{ {
if (!isset($this->controllers[$controller])) { if (!isset($this->controllers[$controller])) {
// If module controller use module manager for initialization // If module controller use module manager for initialization
if (strpos('\Modules\Controller', $controller) === 0) { if (\strpos('\Modules\Controller', $controller) === 0) {
$split = \explode('\\', $controller); $split = \explode('\\', $controller);
$this->controllers[$controller] = $this->app->moduleManager->get($split[2]); $this->controllers[$controller] = $this->app->moduleManager->get($split[2]);
} else { } else {

View File

@ -234,6 +234,6 @@ final class EventManager
*/ */
public function count() : int public function count() : int
{ {
return count($this->callbacks); return \count($this->callbacks);
} }
} }

View File

@ -116,7 +116,7 @@ final class Money implements \Serializable
$left = \str_replace($thousands, '', $left); $left = \str_replace($thousands, '', $left);
$right = ''; $right = '';
if (count($split) > 1) { if (\count($split) > 1) {
$right = $split[1]; $right = $split[1];
} }
@ -191,7 +191,7 @@ final class Money implements \Serializable
*/ */
public function getAmount(int $decimals = 2) : string public function getAmount(int $decimals = 2) : string
{ {
$value = (string) round($this->value, -self::MAX_DECIMALS + $decimals); $value = (string) \round($this->value, -self::MAX_DECIMALS + $decimals);
$left = \substr($value, 0, -self::MAX_DECIMALS); $left = \substr($value, 0, -self::MAX_DECIMALS);
$right = \substr($value, -self::MAX_DECIMALS); $right = \substr($value, -self::MAX_DECIMALS);

View File

@ -396,7 +396,7 @@ final class FileLogger implements LoggerInterface
$line = \fgetcsv($this->fp, 0, ';'); $line = \fgetcsv($this->fp, 0, ';');
while ($line !== false && $line !== null) { while ($line !== false && $line !== null) {
if (count($line) < 2) { if (\count($line) < 2) {
continue; continue;
} }
@ -443,7 +443,7 @@ final class FileLogger implements LoggerInterface
$line = \fgetcsv($this->fp, 0, ';'); $line = \fgetcsv($this->fp, 0, ';');
while ($line !== false && $line !== null) { while ($line !== false && $line !== null) {
if (count($line) < 3) { if (\count($line) < 3) {
continue; continue;
} }
@ -501,7 +501,7 @@ final class FileLogger implements LoggerInterface
} }
if ($limit <= 0) { if ($limit <= 0) {
reset($logs); \reset($logs);
unset($logs[key($logs)]); unset($logs[key($logs)]);
} }

View File

@ -91,6 +91,6 @@ final class Fibunacci
*/ */
public static function binet(int $n) : int public static function binet(int $n) : int
{ {
return (int) (((1 + sqrt(5)) ** $n - (1 - sqrt(5)) ** $n) / (2 ** $n * sqrt(5))); return (int) (((1 + \sqrt(5)) ** $n - (1 - \sqrt(5)) ** $n) / (2 ** $n * \sqrt(5)));
} }
} }

View File

@ -74,11 +74,11 @@ final class Functions
*/ */
public static function binomialCoefficient(int $n, int $k) : int public static function binomialCoefficient(int $n, int $k) : int
{ {
$max = max([$k, $n - $k]); $max = \max([$k, $n - $k]);
$min = min([$k, $n - $k]); $min = \min([$k, $n - $k]);
$fact = 1; $fact = 1;
$range = array_reverse(range(1, $min)); $range = array_reverse(\range(1, $min));
for ($i = $max + 1; $i < $n + 1; ++$i) { for ($i = $max + 1; $i < $n + 1; ++$i) {
$div = 1; $div = 1;
@ -138,7 +138,7 @@ final class Functions
$abs = []; $abs = [];
foreach ($values as $value) { foreach ($values as $value) {
$abs[] = abs($value); $abs[] = \abs($value);
} }
return $abs; return $abs;
@ -293,7 +293,7 @@ final class Functions
$squared = []; $squared = [];
foreach ($values as $value) { foreach ($values as $value) {
$squared[] = sqrt($value); $squared[] = \sqrt($value);
} }
return $squared; return $squared;
@ -315,6 +315,6 @@ final class Functions
*/ */
public static function getRelativeDegree(int $value, int $length, int $start = 0) : int public static function getRelativeDegree(int $value, int $length, int $start = 0) : int
{ {
return abs(self::mod($value - $start, $length)); return \abs(self::mod($value - $start, $length));
} }
} }

View File

@ -58,7 +58,7 @@ final class Gamma
public static function lanczosApproximationReal($z) : float public static function lanczosApproximationReal($z) : float
{ {
if ($z < 0.5) { if ($z < 0.5) {
return M_PI / (sin(M_PI * $z) * self::lanczosApproximationReal(1 - $z)); return M_PI / (\sin(M_PI * $z) * self::lanczosApproximationReal(1 - $z));
} }
$z -= 1; $z -= 1;
@ -69,7 +69,7 @@ final class Gamma
$a += self::LANCZOSAPPROXIMATION[$i] / ($z + $i); $a += self::LANCZOSAPPROXIMATION[$i] / ($z + $i);
} }
return sqrt(2 * M_PI) * pow($t, $z + 0.5) * exp(-$t) * $a; return \sqrt(2 * M_PI) * \pow($t, $z + 0.5) * \exp(-$t) * $a;
} }
/** /**
@ -83,7 +83,7 @@ final class Gamma
*/ */
public static function stirlingApproximation($x) : float public static function stirlingApproximation($x) : float
{ {
return sqrt(2.0 * M_PI / $x) * pow($x / M_E, $x); return \sqrt(2.0 * M_PI / $x) * \pow($x / M_E, $x);
} }
/** /**
@ -101,7 +101,7 @@ final class Gamma
$c = [sqrt(2.0 * M_PI)]; $c = [sqrt(2.0 * M_PI)];
for ($k = 1; $k < 12; ++$k) { for ($k = 1; $k < 12; ++$k) {
$c[$k] = exp(12 - $k) * pow(12 - $k, $k - 0.5) / $k1_fact; $c[$k] = \exp(12 - $k) * \pow(12 - $k, $k - 0.5) / $k1_fact;
$k1_fact *= -$k; $k1_fact *= -$k;
} }
@ -110,7 +110,7 @@ final class Gamma
$accm += $c[$k] / ($z + $k); $accm += $c[$k] / ($z + $k);
} }
$accm *= exp(-$z - 12) * pow($z + 12, $z + 0.5); $accm *= \exp(-$z - 12) * \pow($z + 12, $z + 0.5);
return $accm / $z; return $accm / $z;
} }

View File

@ -46,7 +46,7 @@ final class MonotoneChain
*/ */
public static function createConvexHull(array $points) : array public static function createConvexHull(array $points) : array
{ {
if (($n = count($points)) > 1) { if (($n = \count($points)) > 1) {
uasort($points, [self::class, 'sort']); uasort($points, [self::class, 'sort']);
$k = 0; $k = 0;

View File

@ -64,7 +64,7 @@ final class Circle implements D2ShapeInterface
*/ */
public static function getRadiusBySurface(float $surface) : float public static function getRadiusBySurface(float $surface) : float
{ {
return sqrt($surface / pi()); return \sqrt($surface / pi());
} }
/** /**

View File

@ -62,6 +62,6 @@ final class Ellipse implements D2ShapeInterface
*/ */
public static function getPerimeter(float $a, float $b) : float public static function getPerimeter(float $a, float $b) : float
{ {
return pi() * ($a + $b) * (3 * ($a - $b) ** 2 / (($a + $b) ** 2 * (sqrt(-3 * ($a - $b) ** 2 / (($a + $b) ** 2) + 4) + 10)) + 1); return pi() * ($a + $b) * (3 * ($a - $b) ** 2 / (($a + $b) ** 2 * (\sqrt(-3 * ($a - $b) ** 2 / (($a + $b) ** 2) + 4) + 10)) + 1);
} }
} }

View File

@ -86,7 +86,7 @@ final class Polygon implements D2ShapeInterface
*/ */
public static function isPointInPolygon(array $point, array $polygon) : int public static function isPointInPolygon(array $point, array $polygon) : int
{ {
$length = count($polygon); $length = \count($polygon);
// Polygon has to start and end with same point // Polygon has to start and end with same point
if ($polygon[0]['x'] !== $polygon[$length - 1]['x'] || $polygon[0]['y'] !== $polygon[$length - 1]['y']) { if ($polygon[0]['x'] !== $polygon[$length - 1]['x'] || $polygon[0]['y'] !== $polygon[$length - 1]['y']) {
@ -100,32 +100,32 @@ final class Polygon implements D2ShapeInterface
// Inside or ontop? // Inside or ontop?
$countIntersect = 0; $countIntersect = 0;
$polygonCount = count($polygon); $polygonCount = \count($polygon);
for ($i = 1; $i < $polygonCount; ++$i) { for ($i = 1; $i < $polygonCount; ++$i) {
$vertex1 = $polygon[$i - 1]; $vertex1 = $polygon[$i - 1];
$vertex2 = $polygon[$i]; $vertex2 = $polygon[$i];
if (abs($vertex1['y'] - $vertex2['y']) < self::EPSILON if (\abs($vertex1['y'] - $vertex2['y']) < self::EPSILON
&& abs($vertex1['y'] - $point['y']) < self::EPSILON && \abs($vertex1['y'] - $point['y']) < self::EPSILON
&& $point['x'] > min($vertex1['x'], $vertex2['x']) && $point['x'] > \min($vertex1['x'], $vertex2['x'])
&& $point['x'] < max($vertex1['x'], $vertex2['x']) && $point['x'] < \max($vertex1['x'], $vertex2['x'])
) { ) {
return 0; // boundary return 0; // boundary
} }
if ($point['y'] > min($vertex1['y'], $vertex2['y']) if ($point['y'] > \min($vertex1['y'], $vertex2['y'])
&& $point['y'] <= max($vertex1['y'], $vertex2['y']) && $point['y'] <= \max($vertex1['y'], $vertex2['y'])
&& $point['x'] <= max($vertex1['x'], $vertex2['x']) && $point['x'] <= \max($vertex1['x'], $vertex2['x'])
&& abs($vertex1['y'] - $vertex2['y']) >= self::EPSILON && \abs($vertex1['y'] - $vertex2['y']) >= self::EPSILON
) { ) {
$xinters = ($point['y'] - $vertex1['y']) * ($vertex2['x'] - $vertex1['x']) / ($vertex2['y'] - $vertex1['y']) + $vertex1['x']; $xinters = ($point['y'] - $vertex1['y']) * ($vertex2['x'] - $vertex1['x']) / ($vertex2['y'] - $vertex1['y']) + $vertex1['x'];
if (abs($xinters - $point['x']) < self::EPSILON) { if (\abs($xinters - $point['x']) < self::EPSILON) {
return 0; // boundary return 0; // boundary
} }
if (abs($vertex1['x'] - $vertex2['x']) < self::EPSILON || $point['x'] < $xinters) { if (\abs($vertex1['x'] - $vertex2['x']) < self::EPSILON || $point['x'] < $xinters) {
$countIntersect++; $countIntersect++;
} }
} }
@ -151,7 +151,7 @@ final class Polygon implements D2ShapeInterface
private static function isOnVertex(array $point, array $polygon) : bool private static function isOnVertex(array $point, array $polygon) : bool
{ {
foreach ($polygon as $vertex) { foreach ($polygon as $vertex) {
if (abs($point['x'] - $vertex['x']) < self::EPSILON && abs($point['y'] - $vertex['y']) < self::EPSILON) { if (\abs($point['x'] - $vertex['x']) < self::EPSILON && \abs($point['y'] - $vertex['y']) < self::EPSILON) {
return true; return true;
} }
} }
@ -168,7 +168,7 @@ final class Polygon implements D2ShapeInterface
*/ */
public function getInteriorAngleSum() : int public function getInteriorAngleSum() : int
{ {
return (count($this->coord) - 2) * 180; return (\count($this->coord) - 2) * 180;
} }
/** /**
@ -192,7 +192,7 @@ final class Polygon implements D2ShapeInterface
*/ */
public function getSurface() : float public function getSurface() : float
{ {
return abs($this->getSignedSurface()); return \abs($this->getSignedSurface());
} }
/** /**
@ -204,7 +204,7 @@ final class Polygon implements D2ShapeInterface
*/ */
private function getSignedSurface() : float private function getSignedSurface() : float
{ {
$count = count($this->coord); $count = \count($this->coord);
$surface = 0; $surface = 0;
for ($i = 0; $i < $count - 1; ++$i) { for ($i = 0; $i < $count - 1; ++$i) {
@ -226,11 +226,11 @@ final class Polygon implements D2ShapeInterface
*/ */
public function getPerimeter() : float public function getPerimeter() : float
{ {
$count = count($this->coord); $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); $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); $perimeter += \sqrt(($this->coord[$i + 1]['x'] - $this->coord[$i]['x']) ** 2 + ($this->coord[$i + 1]['y'] - $this->coord[$i]['y']) ** 2);
} }
return $perimeter; return $perimeter;
@ -246,7 +246,7 @@ final class Polygon implements D2ShapeInterface
public function getBarycenter() : array public function getBarycenter() : array
{ {
$barycenter = ['x' => 0, 'y' => 0]; $barycenter = ['x' => 0, 'y' => 0];
$count = count($this->coord); $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']); $mult = ($this->coord[$i]['x'] * $this->coord[$i + 1]['y'] - $this->coord[$i + 1]['x'] * $this->coord[$i]['y']);

View File

@ -67,6 +67,6 @@ final class Rectangle implements D2ShapeInterface
*/ */
public static function getDiagonal(float $a, float $b) : float public static function getDiagonal(float $a, float $b) : float
{ {
return sqrt($a * $a + $b * $b); return \sqrt($a * $a + $b * $b);
} }
} }

View File

@ -52,7 +52,7 @@ final class Cone implements D3ShapeInterface
*/ */
public static function getSurface(float $r, float $h) : float public static function getSurface(float $r, float $h) : float
{ {
return pi() * $r * ($r + sqrt($h ** 2 + $r ** 2)); return pi() * $r * ($r + \sqrt($h ** 2 + $r ** 2));
} }
/** /**
@ -67,7 +67,7 @@ final class Cone implements D3ShapeInterface
*/ */
public static function getSlantHeight(float $r, float $h) : float public static function getSlantHeight(float $r, float $h) : float
{ {
return sqrt($h ** 2 + $r ** 2); return \sqrt($h ** 2 + $r ** 2);
} }
/** /**

View File

@ -54,7 +54,7 @@ final class RectangularPyramid implements D3ShapeInterface
*/ */
public static function getSurface(float $a, float $b, float $h) : float public static function getSurface(float $a, float $b, float $h) : float
{ {
return $a * $b + $a * sqrt(($b / 2) ** 2 + $h ** 2) + $b * sqrt(($a / 2) ** 2 + $h ** 2); return $a * $b + $a * \sqrt(($b / 2) ** 2 + $h ** 2) + $b * \sqrt(($a / 2) ** 2 + $h ** 2);
} }
/** /**
@ -70,6 +70,6 @@ final class RectangularPyramid implements D3ShapeInterface
*/ */
public static function getLateralSurface(float $a, float $b, float $h) : float public static function getLateralSurface(float $a, float $b, float $h) : float
{ {
return $a * sqrt(($b / 2) ** 2 + $h ** 2) + $b * sqrt(($a / 2) ** 2 + $h ** 2); return $a * \sqrt(($b / 2) ** 2 + $h ** 2) + $b * \sqrt(($a / 2) ** 2 + $h ** 2);
} }
} }

View File

@ -67,12 +67,12 @@ final class Sphere implements D3ShapeInterface
//$latDelta = $latTo - $latFrom; //$latDelta = $latTo - $latFrom;
$lonDelta = $lonTo - $lonFrom; $lonDelta = $lonTo - $lonFrom;
$a = pow(cos($latTo) * sin($lonDelta), 2) + pow(cos($latFrom) * sin($latTo) - sin($latFrom) * cos($latTo) * cos($lonDelta), 2); $a = \pow(\cos($latTo) * \sin($lonDelta), 2) + \pow(\cos($latFrom) * \sin($latTo) - \sin($latFrom) * \cos($latTo) * \cos($lonDelta), 2);
$b = sin($latFrom) * sin($latTo) + cos($latFrom) * cos($latTo) * cos($lonDelta); $b = \sin($latFrom) * \sin($latTo) + \cos($latFrom) * \cos($latTo) * \cos($lonDelta);
$angle = atan2(sqrt($a), $b); $angle = atan2(\sqrt($a), $b);
// Approximation (very good for short distances) // Approximation (very good for short distances)
// $angle = 2 * asin(sqrt(pow(sin($latDelta / 2), 2) + cos($latFrom) * cos($latTo) * pow(sin($lonDelta / 2), 2))); // $angle = 2 * asin(\sqrt(\pow(\sin($latDelta / 2), 2) + \cos($latFrom) * \cos($latTo) * \pow(\sin($lonDelta / 2), 2)));
return $angle * $radius; return $angle * $radius;
} }
@ -116,7 +116,7 @@ final class Sphere implements D3ShapeInterface
*/ */
public static function getRadiusByVolume(float $v) : float public static function getRadiusByVolume(float $v) : float
{ {
return pow($v * 3 / (4 * pi()), 1 / 3); return \pow($v * 3 / (4 * pi()), 1 / 3);
} }
/** /**
@ -147,7 +147,7 @@ final class Sphere implements D3ShapeInterface
*/ */
public static function getRadiusBySurface(float $S) : float public static function getRadiusBySurface(float $S) : float
{ {
return sqrt($S / (4 * pi())); return \sqrt($S / (4 * pi()));
} }
/** /**

View File

@ -36,7 +36,7 @@ final class Tetrahedron implements D3ShapeInterface
*/ */
public static function getVolume(float $a) : float public static function getVolume(float $a) : float
{ {
return $a ** 3 / (6 * sqrt(2)); return $a ** 3 / (6 * \sqrt(2));
} }
/** /**
@ -50,7 +50,7 @@ final class Tetrahedron implements D3ShapeInterface
*/ */
public static function getSurface(float $a) : float public static function getSurface(float $a) : float
{ {
return sqrt(3) * $a ** 2; return \sqrt(3) * $a ** 2;
} }
/** /**
@ -64,6 +64,6 @@ final class Tetrahedron implements D3ShapeInterface
*/ */
public static function getFaceArea(float $a) : float public static function getFaceArea(float $a) : float
{ {
return sqrt(3) / 4 * $a ** 2; return \sqrt(3) / 4 * $a ** 2;
} }
} }

View File

@ -72,7 +72,7 @@ final class CholeskyDecomposition
if ($i === $j) { if ($i === $j) {
if ($sum >= 0) { if ($sum >= 0) {
$this->L[$i][$i] = sqrt($sum); $this->L[$i][$i] = \sqrt($sum);
} else { } else {
$this->isSpd = false; $this->isSpd = false;
} }

View File

@ -401,7 +401,7 @@ final class EigenvalueDecomposition
$h += $this->ort[$i] * $this->ort[$i]; $h += $this->ort[$i] * $this->ort[$i];
} }
$g = $this->ort[$m] > 0 ? -sqrt($h) : sqrt($h); $g = $this->ort[$m] > 0 ? -sqrt($h) : \sqrt($h);
$h -= $this->ort[$m] * $g; $h -= $this->ort[$m] * $g;
$this->ort[$m] -= $g; $this->ort[$m] -= $g;
@ -466,7 +466,7 @@ final class EigenvalueDecomposition
$r = 0.0; $r = 0.0;
$d = 0.0; $d = 0.0;
if (abs($yr) > \abs($yi)) { if (\abs($yr) > \abs($yi)) {
$r = $yi / $yr; $r = $yi / $yr;
$d = $yr + $r * $yi; $d = $yr + $r * $yi;
@ -506,7 +506,7 @@ final class EigenvalueDecomposition
$this->E[$i] = 0.0; $this->E[$i] = 0.0;
} }
for ($j = max($i - 1, 0); $j < $nn; ++$j) { for ($j = \max($i - 1, 0); $j < $nn; ++$j) {
$norm += \abs($this->H[$i][$j]); $norm += \abs($this->H[$i][$j]);
} }
} }
@ -520,7 +520,7 @@ final class EigenvalueDecomposition
$s = $norm; $s = $norm;
} }
if (abs($this->H[$l][$l - 1]) < $eps * $s) { if (\abs($this->H[$l][$l - 1]) < $eps * $s) {
break; break;
} }
@ -538,7 +538,7 @@ final class EigenvalueDecomposition
$w = $this->H[$n][$n - 1] * $this->H[$n - 1][$n]; $w = $this->H[$n][$n - 1] * $this->H[$n - 1][$n];
$p = ($this->H[$n - 1][$n - 1] - $this->H[$n][$n]) / 2.0; $p = ($this->H[$n - 1][$n - 1] - $this->H[$n][$n]) / 2.0;
$q = $p * $p + $w; $q = $p * $p + $w;
$z = sqrt(abs($q)); $z = \sqrt(\abs($q));
$this->H[$n][$n] += $exshift; $this->H[$n][$n] += $exshift;
$this->H[$n - 1][$n - 1] += $exshift; $this->H[$n - 1][$n - 1] += $exshift;
@ -556,7 +556,7 @@ final class EigenvalueDecomposition
$s = \abs($x) + \abs($z); $s = \abs($x) + \abs($z);
$p = $x / $s; $p = $x / $s;
$q = $z / $s; $q = $z / $s;
$r = sqrt($p * $p + $q * $q); $r = \sqrt($p * $p + $q * $q);
$p = $p / $r; $p = $p / $r;
$q = $q / $r; $q = $q / $r;

View File

@ -95,7 +95,7 @@ final class LUDecomposition
for ($i = 0; $i < $this->m; ++$i) { for ($i = 0; $i < $this->m; ++$i) {
$LUrowi = $this->LU[$i]; $LUrowi = $this->LU[$i];
$kmax = min($i, $j); $kmax = \min($i, $j);
$s = 0.0; $s = 0.0;
for ($k = 0; $k < $kmax; ++$k) { for ($k = 0; $k < $kmax; ++$k) {
@ -106,7 +106,7 @@ final class LUDecomposition
$p = $j; $p = $j;
for ($i = $j + 1; $i < $this->m; ++$i) { for ($i = $j + 1; $i < $this->m; ++$i) {
if (abs($LUcolj[$i]) > abs($LUcolj[$p])) { if (\abs($LUcolj[$i]) > \abs($LUcolj[$p])) {
$p = $i; $p = $i;
} }
} }

View File

@ -186,8 +186,8 @@ class Matrix implements \ArrayAccess, \Iterator
public function getSubMatrixByColumnsRows(array $rows, array $cols) : Matrix public function getSubMatrixByColumnsRows(array $rows, array $cols) : Matrix
{ {
$X = [[]]; $X = [[]];
$rlength = count($rows); $rlength = \count($rows);
$clength = count($cols); $clength = \count($cols);
for ($i = 0; $i <= $rlength; ++$i) { for ($i = 0; $i <= $rlength; ++$i) {
for ($j = 0; $j <= $clength; ++$j) { for ($j = 0; $j <= $clength; ++$j) {
@ -215,7 +215,7 @@ class Matrix implements \ArrayAccess, \Iterator
public function getSubMatrixByColumns(int $iRow, int $lRow, array $cols) : Matrix public function getSubMatrixByColumns(int $iRow, int $lRow, array $cols) : Matrix
{ {
$X = [[]]; $X = [[]];
$length = count($cols); $length = \count($cols);
for ($i = $iRow; $i <= $lRow; ++$i) { for ($i = $iRow; $i <= $lRow; ++$i) {
for ($j = 0; $j <= $length; ++$j) { for ($j = 0; $j <= $length; ++$j) {
@ -243,7 +243,7 @@ class Matrix implements \ArrayAccess, \Iterator
public function getSubMatrixByRows(array $rows, int $iCol, int $lCol) : Matrix public function getSubMatrixByRows(array $rows, int $iCol, int $lCol) : Matrix
{ {
$X = [[]]; $X = [[]];
$length = count($rows); $length = \count($rows);
for ($i = 0; $i < $length; ++$i) { for ($i = 0; $i < $length; ++$i) {
for ($j = $iCol; $j <= $lCol; ++$j) { for ($j = $iCol; $j <= $lCol; ++$j) {
@ -380,8 +380,8 @@ class Matrix implements \ArrayAccess, \Iterator
*/ */
public function setMatrix(array $matrix) : Matrix public function setMatrix(array $matrix) : Matrix
{ {
$this->m = count($matrix); $this->m = \count($matrix);
$this->n = count($matrix[0] ?? 1); $this->n = \count($matrix[0] ?? 1);
$this->matrix = $matrix; $this->matrix = $matrix;
return $this; return $this;
@ -640,7 +640,7 @@ class Matrix implements \ArrayAccess, \Iterator
$max = 0; $max = 0;
for ($j = $i; $j < $n; ++$j) { for ($j = $i; $j < $n; ++$j) {
if (abs($arr[$j][$i]) > abs($arr[$max][$i])) { if (\abs($arr[$j][$i]) > \abs($arr[$max][$i])) {
$max = $j; $max = $j;
} }
} }

View File

@ -117,8 +117,8 @@ final class Complex
public function sqrt() : Complex public function sqrt() : Complex
{ {
return new self( return new self(
sqrt(($this->re + sqrt($this->re ** 2 + $this->im ** 2)) / 2), \sqrt(($this->re + \sqrt($this->re ** 2 + $this->im ** 2)) / 2),
($this->im <=> 0) * sqrt((-$this->re + sqrt($this->re ** 2 + $this->im ** 2)) / 2) ($this->im <=> 0) * \sqrt((-$this->re + \sqrt($this->re ** 2 + $this->im ** 2)) / 2)
); );
} }
@ -131,7 +131,7 @@ final class Complex
*/ */
public function abs() public function abs()
{ {
return sqrt($this->re ** 2 + $this->im ** 2); return \sqrt($this->re ** 2 + $this->im ** 2);
} }
/** /**
@ -411,7 +411,7 @@ final class Complex
. ($this->im < 0 && $this->re !== 0 ? ' -' : '') . ($this->im < 0 && $this->re !== 0 ? ' -' : '')
. ($this->im !== 0 ? ( . ($this->im !== 0 ? (
($this->re !== 0 ? ' ' : '') . number_format( ($this->re !== 0 ? ' ' : '') . number_format(
($this->im < 0 && $this->re === 0 ? $this->im : abs($this->im)), $precision ($this->im < 0 && $this->re === 0 ? $this->im : \abs($this->im)), $precision
) . 'i' ) . 'i'
) : ''); ) : '');
} }

View File

@ -127,8 +127,8 @@ final class Integer
*/ */
public static function greatestCommonDivisor(int $n, int $m) : int public static function greatestCommonDivisor(int $n, int $m) : int
{ {
$n = abs($n); $n = \abs($n);
$m = abs($m); $m = \abs($m);
while ($n !== $m) { while ($n !== $m) {
if ($n > $m) { if ($n > $m) {
@ -159,7 +159,7 @@ final class Integer
throw new \Exception('Only odd integers are allowed'); throw new \Exception('Only odd integers are allowed');
} }
$a = (int) ceil(sqrt($value)); $a = (int) ceil(\sqrt($value));
$b2 = ($a * $a - $value); $b2 = ($a * $a - $value);
$i = 1; $i = 1;
@ -169,6 +169,6 @@ final class Integer
$b2 = ($a * $a - $value); $b2 = ($a * $a - $value);
} }
return [(int) round($a - sqrt($b2)), (int) round($a + sqrt($b2))]; return [(int) \round($a - \sqrt($b2)), (int) \round($a + \sqrt($b2))];
} }
} }

View File

@ -95,7 +95,7 @@ final class Numbers
*/ */
public static function isSquare(int $n) : bool public static function isSquare(int $n) : bool
{ {
return abs(((int) sqrt($n)) * ((int) sqrt($n)) - $n) < 0.001; return \abs(((int) \sqrt($n)) * ((int) \sqrt($n)) - $n) < 0.001;
} }
/** /**

View File

@ -77,7 +77,7 @@ interface OperationInterface
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function pow($p); public function \pow($p);
/** /**
* Abs of value. * Abs of value.
@ -86,5 +86,5 @@ interface OperationInterface
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function abs(); public function \abs();
} }

View File

@ -46,7 +46,7 @@ final class Prime
*/ */
public static function isMersenne(int $n) : bool public static function isMersenne(int $n) : bool
{ {
$mersenne = log($n + 1, 2); $mersenne = \log($n + 1, 2);
return $mersenne - (int) $mersenne < 0.00001; return $mersenne - (int) $mersenne < 0.00001;
} }
@ -96,14 +96,14 @@ final class Prime
for ($i = 0; $i < $k; ++$i) { for ($i = 0; $i < $k; ++$i) {
$a = mt_rand(2, $n - 1); $a = mt_rand(2, $n - 1);
$x = bcpowmod((string) $a, (string) $d, (string) $n); $x = \bcpowmod((string) $a, (string) $d, (string) $n);
if ($x == 1 || $x == $n - 1) { if ($x == 1 || $x == $n - 1) {
continue; continue;
} }
for ($j = 1; $j < $s; ++$j) { for ($j = 1; $j < $s; ++$j) {
$x = bcmod(bcmul($x, $x), (string) $n); $x = \bcmod(\bcmul($x, $x), (string) $n);
if ($x == 1) { if ($x == 1) {
return false; return false;
@ -132,7 +132,7 @@ final class Prime
public static function sieveOfEratosthenes(int $n) : array public static function sieveOfEratosthenes(int $n) : array
{ {
$number = 2; $number = 2;
$range = range(2, $n); $range = \range(2, $n);
$primes = array_combine($range, $range); $primes = array_combine($range, $range);
while ($number * $number < $n) { while ($number * $number < $n) {
@ -144,7 +144,7 @@ final class Prime
unset($primes[$i]); unset($primes[$i]);
} }
$number = next($primes); $number = \next($primes);
} }
return array_values($primes); return array_values($primes);
@ -167,7 +167,7 @@ final class Prime
return true; return true;
} }
$sqrtN = sqrt($n); $sqrtN = \sqrt($n);
while ($i <= $sqrtN) { while ($i <= $sqrtN) {
if ($n % $i === 0) { if ($n % $i === 0) {
return false; return false;

View File

@ -121,21 +121,21 @@ class Evaluator
$output[] = $token; $output[] = $token;
} elseif (\strpbrk($token, '^*/+-') !== false) { } elseif (\strpbrk($token, '^*/+-') !== false) {
$o1 = $token; $o1 = $token;
$o2 = end($stack); $o2 = \end($stack);
while ($o2 !== false && \strpbrk($o2, '^*/+-') !== false while ($o2 !== false && \strpbrk($o2, '^*/+-') !== false
&& (($operators[$o1]['order'] === -1 && $operators[$o1]['precedence'] <= $operators[$o2]['precedence']) && (($operators[$o1]['order'] === -1 && $operators[$o1]['precedence'] <= $operators[$o2]['precedence'])
|| ($operators[$o1]['order'] === 1 && $operators[$o1]['precedence'] < $operators[$o2]['precedence'])) || ($operators[$o1]['order'] === 1 && $operators[$o1]['precedence'] < $operators[$o2]['precedence']))
) { ) {
$output[] = \array_pop($stack); $output[] = \array_pop($stack);
$o2 = end($stack); $o2 = \end($stack);
} }
$stack[] = $o1; $stack[] = $o1;
} elseif ($token === '(') { } elseif ($token === '(') {
$stack[] = $token; $stack[] = $token;
} elseif ($token === ')') { } elseif ($token === ')') {
while (end($stack) !== '(') { while (\end($stack) !== '(') {
$output[] = \array_pop($stack); $output[] = \array_pop($stack);
} }
@ -143,7 +143,7 @@ class Evaluator
} }
} }
while (count($stack) > 0) { while (\count($stack) > 0) {
$output[] = \array_pop($stack); $output[] = \array_pop($stack);
} }

View File

@ -63,7 +63,7 @@ final class Average
*/ */
public static function averageDatasetChange(array $x, int $h = 1) : float public static function averageDatasetChange(array $x, int $h = 1) : float
{ {
$count = count($x); $count = \count($x);
return $h * ($x[$count - 1] - $x[0]) / ($count - 1); return $h * ($x[$count - 1] - $x[0]) / ($count - 1);
} }
@ -85,7 +85,7 @@ final class Average
public static function totalMovingAverage(array $x, int $order, array $weight = null, bool $symmetric = false) : array public static function totalMovingAverage(array $x, int $order, array $weight = null, bool $symmetric = false) : array
{ {
$periods = (int) ($order / 2); $periods = (int) ($order / 2);
$count = count($x) - ($symmetric ? $periods : 0); $count = \count($x) - ($symmetric ? $periods : 0);
$avg = []; $avg = [];
for ($i = $periods; $i < $count; ++$i) { for ($i = $periods; $i < $count; ++$i) {
@ -113,7 +113,7 @@ final class Average
public static function movingAverage(array $x, int $t, int $order, array $weight = null, bool $symmetric = false) : float public static function movingAverage(array $x, int $t, int $order, array $weight = null, bool $symmetric = false) : float
{ {
$periods = (int) ($order / 2); $periods = (int) ($order / 2);
$count = count($x); $count = \count($x);
if ($t < $periods || ($count < $periods) || ($symmetric && $t + $periods < $count)) { if ($t < $periods || ($count < $periods) || ($symmetric && $t + $periods < $count)) {
throw new \Exception('Periods'); throw new \Exception('Periods');
@ -146,8 +146,8 @@ final class Average
*/ */
public static function weightedAverage(array $values, array $weight) : float public static function weightedAverage(array $values, array $weight) : float
{ {
if (($count = count($values)) !== count($weight)) { if (($count = \count($values)) !== \count($weight)) {
throw new InvalidDimensionException(count($values) . 'x' . count($weight)); throw new InvalidDimensionException(\count($values) . 'x' . \count($weight));
} }
$avg = 0.0; $avg = 0.0;
@ -174,7 +174,7 @@ final class Average
*/ */
public static function arithmeticMean(array $values) : float public static function arithmeticMean(array $values) : float
{ {
$count = count($values); $count = \count($values);
if ($count === 0) { if ($count === 0) {
throw new ZeroDevisionException(); throw new ZeroDevisionException();
@ -197,7 +197,7 @@ final class Average
public static function mode(array $values) : float public static function mode(array $values) : float
{ {
$count = array_count_values($values); $count = array_count_values($values);
$best = max($count); $best = \max($count);
return (float) (array_keys($count, $best)[0] ?? 0.0); return (float) (array_keys($count, $best)[0] ?? 0.0);
} }
@ -216,7 +216,7 @@ final class Average
public static function median(array $values) : float public static function median(array $values) : float
{ {
sort($values); sort($values);
$count = count($values); $count = \count($values);
$middleval = (int) floor(($count - 1) / 2); $middleval = (int) floor(($count - 1) / 2);
if ($count % 2) { if ($count % 2) {
@ -246,13 +246,13 @@ final class Average
*/ */
public static function geometricMean(array $values, int $offset = 0) : float public static function geometricMean(array $values, int $offset = 0) : float
{ {
$count = count($values); $count = \count($values);
if ($count === 0) { if ($count === 0) {
throw new ZeroDevisionException(); throw new ZeroDevisionException();
} }
return pow(\array_product($values), 1 / $count); return \pow(\array_product($values), 1 / $count);
} }
/** /**
@ -277,7 +277,7 @@ final class Average
$values = array_slice($values, $offset, -$offset); $values = array_slice($values, $offset, -$offset);
} }
$count = count($values); $count = \count($values);
$sum = 0.0; $sum = 0.0;
foreach ($values as $value) { foreach ($values as $value) {
@ -307,11 +307,11 @@ final class Average
{ {
$y = 0; $y = 0;
$x = 0; $x = 0;
$size = count($angles); $size = \count($angles);
for ($i = 0; $i < $size; ++$i) { for ($i = 0; $i < $size; ++$i) {
$x += cos(deg2rad($angles[$i])); $x += \cos(deg2rad($angles[$i]));
$y += sin(deg2rad($angles[$i])); $y += \sin(deg2rad($angles[$i]));
} }
$x /= $size; $x /= $size;
@ -344,12 +344,12 @@ final class Average
$coss = 0.0; $coss = 0.0;
foreach ($angles as $a) { foreach ($angles as $a) {
$sins += sin(deg2rad($a)); $sins += \sin(deg2rad($a));
$coss += cos(deg2rad($a)); $coss += \cos(deg2rad($a));
} }
$avgsin = $sins / (0.0 + count($angles)); $avgsin = $sins / (0.0 + \count($angles));
$avgcos = $coss / (0.0 + count($angles)); $avgcos = $coss / (0.0 + \count($angles));
$avgang = rad2deg(atan2($avgsin, $avgcos)); $avgang = rad2deg(atan2($avgsin, $avgcos));
while ($avgang < 0.0) { while ($avgang < 0.0) {

View File

@ -51,7 +51,7 @@ final class Basic
$freaquency = []; $freaquency = [];
$sum = 1; $sum = 1;
if (!($isArray = is_array(reset($values)))) { if (!($isArray = is_array(\reset($values)))) {
$sum = array_sum($values); $sum = array_sum($values);
} }

View File

@ -66,7 +66,7 @@ final class Correlation
{ {
$squaredMeanDeviation = MeasureOfDispersion::squaredMeanDeviation($x); $squaredMeanDeviation = MeasureOfDispersion::squaredMeanDeviation($x);
$mean = Average::arithmeticMean($x); $mean = Average::arithmeticMean($x);
$count = count($x); $count = \count($x);
$sum = 0.0; $sum = 0.0;
for ($i = $k; $i < $count; ++$i) { for ($i = $k; $i < $count; ++$i) {

View File

@ -139,7 +139,7 @@ class Error
*/ */
public static function getRootMeanSquaredError(array $errors) : float public static function getRootMeanSquaredError(array $errors) : float
{ {
return sqrt(Average::arithmeticMean(Functions::powerInt($errors, 2))); return \sqrt(Average::arithmeticMean(Functions::powerInt($errors, 2)));
} }
/** /**
@ -158,8 +158,8 @@ class Error
*/ */
public static function getCoefficientOfDetermination(array $observed, array $forecasted) : float public static function getCoefficientOfDetermination(array $observed, array $forecasted) : float
{ {
$countO = count($observed); $countO = \count($observed);
$countF = count($forecasted); $countF = \count($forecasted);
$sum1 = 0; $sum1 = 0;
$sum2 = 0; $sum2 = 0;
$meanY = Average::arithmeticMean($observed); $meanY = Average::arithmeticMean($observed);
@ -224,7 +224,7 @@ class Error
*/ */
public static function getAkaikeInformationCriterion(float $sse, int $observations, int $predictors) : float public static function getAkaikeInformationCriterion(float $sse, int $observations, int $predictors) : float
{ {
return $observations * log($sse / $observations) + 2 * ($predictors + 2); return $observations * \log($sse / $observations) + 2 * ($predictors + 2);
} }
/** /**
@ -258,7 +258,7 @@ class Error
*/ */
public static function getSchwarzBayesianInformationCriterion(float $sse, int $observations, int $predictors) : float public static function getSchwarzBayesianInformationCriterion(float $sse, int $observations, int $predictors) : float
{ {
return $observations * log($sse / $observations) + ($predictors + 2) * log($observations); return $observations * \log($sse / $observations) + ($predictors + 2) * \log($observations);
} }
/** /**
@ -291,7 +291,7 @@ class Error
$error = []; $error = [];
foreach ($observed as $key => $value) { foreach ($observed as $key => $value) {
$error[] = 200 * abs($value - $forecasted[$key]) / ($value + $forecasted[$key]); $error[] = 200 * \abs($value - $forecasted[$key]) / ($value + $forecasted[$key]);
} }
return Average::arithmeticMean($error); return Average::arithmeticMean($error);
@ -335,7 +335,7 @@ class Error
$sum = 0.0; $sum = 0.0;
foreach ($observed as $value) { foreach ($observed as $value) {
$sum += abs($value - $mean); $sum += \abs($value - $mean);
} }
return $error / MeasureOfDispersion::meanDeviation($observed); return $error / MeasureOfDispersion::meanDeviation($observed);
@ -383,7 +383,7 @@ class Error
public static function getScaledErrorArray(array $errors, array $observed, int $m = 1) : array public static function getScaledErrorArray(array $errors, array $observed, int $m = 1) : array
{ {
$scaled = []; $scaled = [];
$naive = 1 / (count($observed) - $m) * self::getNaiveForecast($observed, $m); $naive = 1 / (\count($observed) - $m) * self::getNaiveForecast($observed, $m);
foreach ($errors as $error) { foreach ($errors as $error) {
$error[] = $error / $naive; $error[] = $error / $naive;
@ -405,7 +405,7 @@ class Error
*/ */
public static function getScaledError(float $error, array $observed, int $m = 1) : float public static function getScaledError(float $error, array $observed, int $m = 1) : float
{ {
return $error / (1 / (count($observed) - $m) * self::getNaiveForecast($observed, $m)); return $error / (1 / (\count($observed) - $m) * self::getNaiveForecast($observed, $m));
} }
/** /**
@ -421,10 +421,10 @@ class Error
private static function getNaiveForecast(array $observed, int $m = 1) : float private static function getNaiveForecast(array $observed, int $m = 1) : float
{ {
$sum = 0.0; $sum = 0.0;
$count = count($observed); $count = \count($observed);
for ($i = 0 + $m; $i < $count; ++$i) { for ($i = 0 + $m; $i < $count; ++$i) {
$sum += abs($observed[$i] - $observed[$i - $m]); $sum += \abs($observed[$i] - $observed[$i - $m]);
} }
return $sum; return $sum;

View File

@ -31,12 +31,12 @@ class LevelLogRegression extends RegressionAbstract
*/ */
public static function getRegression(array $x, array $y) : array public static function getRegression(array $x, array $y) : array
{ {
if (($c = count($x)) !== count($y)) { if (($c = \count($x)) !== \count($y)) {
throw new InvalidDimensionException($c . 'x' . count($y)); throw new InvalidDimensionException($c . 'x' . \count($y));
} }
for ($i = 0; $i < $c; ++$i) { for ($i = 0; $i < $c; ++$i) {
$x[$i] = log($x[$i]); $x[$i] = \log($x[$i]);
} }
return parent::getRegression($x, $y); return parent::getRegression($x, $y);

View File

@ -31,12 +31,12 @@ class LogLevelRegression extends RegressionAbstract
*/ */
public static function getRegression(array $x, array $y) : array public static function getRegression(array $x, array $y) : array
{ {
if (($c = count($x)) !== count($y)) { if (($c = \count($x)) !== \count($y)) {
throw new InvalidDimensionException($c . 'x' . count($y)); throw new InvalidDimensionException($c . 'x' . \count($y));
} }
for ($i = 0; $i < $c; ++$i) { for ($i = 0; $i < $c; ++$i) {
$y[$i] = log($y[$i]); $y[$i] = \log($y[$i]);
} }
return parent::getRegression($x, $y); return parent::getRegression($x, $y);

View File

@ -31,13 +31,13 @@ class LogLogRegression extends RegressionAbstract
*/ */
public static function getRegression(array $x, array $y) : array public static function getRegression(array $x, array $y) : array
{ {
if (($c = count($x)) !== count($y)) { if (($c = \count($x)) !== \count($y)) {
throw new InvalidDimensionException($c . 'x' . count($y)); throw new InvalidDimensionException($c . 'x' . \count($y));
} }
for ($i = 0; $i < $c; ++$i) { for ($i = 0; $i < $c; ++$i) {
$x[$i] = log($x[$i]); $x[$i] = \log($x[$i]);
$y[$i] = log($y[$i]); $y[$i] = \log($y[$i]);
} }
return parent::getRegression($x, $y); return parent::getRegression($x, $y);

View File

@ -22,11 +22,11 @@ class MultipleLinearRegression
*/ */
public static function getRegression(array $x, array $y) : array public static function getRegression(array $x, array $y) : array
{ {
$X = new Matrix(count($x), count($x[0])); $X = new Matrix(\count($x), \count($x[0]));
$X->setMatrix($x); $X->setMatrix($x);
$XT = $X->transpose(); $XT = $X->transpose();
$Y = new Matrix(count($y)); $Y = new Matrix(\count($y));
$Y->setMatrix($y); $Y->setMatrix($y);
return $XT->mult($X)->inverse()->mult($XT)->mult($Y)->getMatrix(); return $XT->mult($X)->inverse()->mult($XT)->mult($Y)->getMatrix();

View File

@ -44,8 +44,8 @@ abstract class RegressionAbstract
*/ */
public static function getRegression(array $x, array $y) : array public static function getRegression(array $x, array $y) : array
{ {
if (count($x) !== count($y)) { if (\count($x) !== \count($y)) {
throw new InvalidDimensionException(count($x) . 'x' . count($y)); throw new InvalidDimensionException(\count($x) . 'x' . \count($y));
} }
$b1 = self::getBeta1($x, $y); $b1 = self::getBeta1($x, $y);
@ -68,7 +68,7 @@ abstract class RegressionAbstract
*/ */
public static function getStandardErrorOfRegression(array $errors) : float public static function getStandardErrorOfRegression(array $errors) : float
{ {
$count = count($errors); $count = \count($errors);
$sum = 0.0; $sum = 0.0;
for ($i = 0; $i < $count; ++$i) { for ($i = 0; $i < $count; ++$i) {
@ -76,7 +76,7 @@ abstract class RegressionAbstract
} }
// todo: could this be - 1 depending on the different definitions?! // todo: could this be - 1 depending on the different definitions?!
return sqrt(1 / ($count - 2) * $sum); return \sqrt(1 / ($count - 2) * $sum);
} }
/** /**
@ -93,7 +93,7 @@ abstract class RegressionAbstract
*/ */
public static function getPredictionInterval(float $forecasted, array $x, array $errors, float $multiplier = ForecastIntervalMultiplier::P_95) : array public static function getPredictionInterval(float $forecasted, array $x, array $errors, float $multiplier = ForecastIntervalMultiplier::P_95) : array
{ {
$count = count($x); $count = \count($x);
$meanX = Average::arithmeticMean($x); $meanX = Average::arithmeticMean($x);
$sum = 0.0; $sum = 0.0;
@ -101,7 +101,7 @@ abstract class RegressionAbstract
$sum += ($x[$i] - $meanX) ** 2; $sum += ($x[$i] - $meanX) ** 2;
} }
$interval = $multiplier * self::getStandardErrorOfRegression($errors) * sqrt(1 + 1 / $count + $sum / (($count - 1) * MeasureOfDispersion::standardDeviation($x) ** 2)); $interval = $multiplier * self::getStandardErrorOfRegression($errors) * \sqrt(1 + 1 / $count + $sum / (($count - 1) * MeasureOfDispersion::standardDeviation($x) ** 2));
return [$forecasted - $interval, $forecasted + $interval]; return [$forecasted - $interval, $forecasted + $interval];
} }
@ -120,7 +120,7 @@ abstract class RegressionAbstract
*/ */
private static function getBeta1(array $x, array $y) : float private static function getBeta1(array $x, array $y) : float
{ {
$count = count($x); $count = \count($x);
$meanX = Average::arithmeticMean($x); $meanX = Average::arithmeticMean($x);
$meanY = Average::arithmeticMean($y); $meanY = Average::arithmeticMean($y);

View File

@ -52,8 +52,8 @@ final class MeasureOfDispersion
public static function range(array $values) : float public static function range(array $values) : float
{ {
sort($values); sort($values);
$end = end($values); $end = \end($values);
$start = reset($values); $start = \reset($values);
return $end - $start; return $end - $start;
} }
@ -106,7 +106,7 @@ final class MeasureOfDispersion
$sum += ($value - $mean) ** 2; $sum += ($value - $mean) ** 2;
} }
return sqrt($sum / (count($values) - 1)); return \sqrt($sum / (\count($values) - 1));
} }
/** /**
@ -129,7 +129,7 @@ final class MeasureOfDispersion
*/ */
public static function sampleVariance(array $values, float $mean = null) : float public static function sampleVariance(array $values, float $mean = null) : float
{ {
$count = count($values); $count = \count($values);
if ($count < 2) { if ($count < 2) {
throw new ZeroDevisionException(); throw new ZeroDevisionException();
@ -159,7 +159,7 @@ final class MeasureOfDispersion
*/ */
public static function empiricalVariance(array $values, array $probabilities = [], float $mean = null) : float public static function empiricalVariance(array $values, array $probabilities = [], float $mean = null) : float
{ {
$count = count($values); $count = \count($values);
$hasProbability = !empty($probabilities); $hasProbability = !empty($probabilities);
if ($count === 0) { if ($count === 0) {
@ -196,14 +196,14 @@ final class MeasureOfDispersion
*/ */
public static function empiricalCovariance(array $x, array $y, float $meanX = null, float $meanY = null) : float public static function empiricalCovariance(array $x, array $y, float $meanX = null, float $meanY = null) : float
{ {
$count = count($x); $count = \count($x);
if ($count < 2) { if ($count < 2) {
throw new ZeroDevisionException(); throw new ZeroDevisionException();
} }
if ($count !== count($y)) { if ($count !== \count($y)) {
throw new InvalidDimensionException($count . 'x' . count($y)); throw new InvalidDimensionException($count . 'x' . \count($y));
} }
$xMean = $meanX !== null ? $meanX : Average::arithmeticMean($x); $xMean = $meanX !== null ? $meanX : Average::arithmeticMean($x);
@ -251,7 +251,7 @@ final class MeasureOfDispersion
$sum += ($xi - $mean); $sum += ($xi - $mean);
} }
return $sum / count($x); return $sum / \count($x);
} }
/** /**
@ -270,10 +270,10 @@ final class MeasureOfDispersion
$sum = 0.0; $sum = 0.0;
foreach ($x as $xi) { foreach ($x as $xi) {
$sum += abs($xi - $mean); $sum += \abs($xi - $mean);
} }
return $sum / count($x); return $sum / \count($x);
} }
/** /**
@ -295,6 +295,6 @@ final class MeasureOfDispersion
$sum += ($xi - $mean) ** 2; $sum += ($xi - $mean) ** 2;
} }
return $sum / count($x); return $sum / \count($x);
} }
} }

View File

@ -148,7 +148,7 @@ class BernoulliDistribution
*/ */
public static function getMgf(float $p, float $t) : float public static function getMgf(float $p, float $t) : float
{ {
return (1 - $p) + $p * exp($t); return (1 - $p) + $p * \exp($t);
} }
/** /**
@ -162,7 +162,7 @@ class BernoulliDistribution
*/ */
public static function getSkewness(float $p) : float public static function getSkewness(float $p) : float
{ {
return (1 - 2 * $p) / sqrt($p * (1 - $p)); return (1 - 2 * $p) / \sqrt($p * (1 - $p));
} }
/** /**
@ -176,7 +176,7 @@ class BernoulliDistribution
*/ */
public static function getEntropy(float $p) : float public static function getEntropy(float $p) : float
{ {
return -(1 - $p) * log(1 - $p) - $p * log($p); return -(1 - $p) * \log(1 - $p) - $p * \log($p);
} }
/** /**

View File

@ -57,7 +57,7 @@ class BinomialDistribution
*/ */
public static function getMgf(int $n, float $t, float $p) : float public static function getMgf(int $n, float $t, float $p) : float
{ {
return pow(1 - $p + $p * exp($t), $n); return \pow(1 - $p + $p * \exp($t), $n);
} }
/** /**
@ -72,7 +72,7 @@ class BinomialDistribution
*/ */
public static function getSkewness(int $n, float $p) : float public static function getSkewness(int $n, float $p) : float
{ {
return (1 - 2 * $p) / sqrt($n * $p * (1 - $p)); return (1 - 2 * $p) / \sqrt($n * $p * (1 - $p));
} }
/** /**
@ -142,7 +142,7 @@ class BinomialDistribution
*/ */
public static function getPmf(int $n, int $k, float $p) : float public static function getPmf(int $n, int $k, float $p) : float
{ {
return Functions::binomialCoefficient($n, $k) * pow($p, $k) * pow(1 - $p, $n - $k); return Functions::binomialCoefficient($n, $k) * \pow($p, $k) * \pow(1 - $p, $n - $k);
} }
/** /**

View File

@ -95,7 +95,7 @@ class CauchyDistribution
*/ */
public static function getEntropy(float $gamma) : float public static function getEntropy(float $gamma) : float
{ {
return log(4 * M_PI * $gamma); return \log(4 * M_PI * $gamma);
} }
public static function getRandom() public static function getRandom()

View File

@ -90,7 +90,7 @@ class ChiSquaredDistribution
*/ */
public static function testHypothesis(array $dataset, array $expected, float $significance = 0.05, int $df = 0) : array public static function testHypothesis(array $dataset, array $expected, float $significance = 0.05, int $df = 0) : array
{ {
if (($count = count($dataset)) !== count($expected)) { if (($count = \count($dataset)) !== \count($expected)) {
throw new \Exception('Dimension'); throw new \Exception('Dimension');
} }
@ -117,7 +117,7 @@ class ChiSquaredDistribution
} }
} }
$key = key(end(self::TABLE[$df])); $key = \key(\end(self::TABLE[$df]));
$p = 1 - ($p ?? ($key === false ? 1 : (float) $key)); $p = 1 - ($p ?? ($key === false ? 1 : (float) $key));
return ['P' => $p, 'H0' => ($p > $significance), 'df' => $df]; return ['P' => $p, 'H0' => ($p > $significance), 'df' => $df];
@ -134,10 +134,10 @@ class ChiSquaredDistribution
*/ */
public static function getDegreesOfFreedom(array $values) : int public static function getDegreesOfFreedom(array $values) : int
{ {
if (is_array($first = reset($values))) { if (is_array($first = \reset($values))) {
return (count($values) - 1) * (count($first) - 1); return (\count($values) - 1) * (\count($first) - 1);
} else { } else {
return count($values) - 1; return \count($values) - 1;
} }
} }
@ -159,7 +159,7 @@ class ChiSquaredDistribution
throw new \Exception('Out of bounds'); throw new \Exception('Out of bounds');
} }
return 1 / (pow(2, $df / 2) * Gamma::lanczosApproximationReal(($df / 2))) * pow($x, $df / 2 - 1) * exp(-$x / 2); return 1 / (\pow(2, $df / 2) * Gamma::lanczosApproximationReal(($df / 2))) * \pow($x, $df / 2 - 1) * \exp(-$x / 2);
} }
/** /**
@ -173,7 +173,7 @@ class ChiSquaredDistribution
*/ */
public static function getMode(int $df) : int public static function getMode(int $df) : int
{ {
return max([$df - 2, 0]); return \max([$df - 2, 0]);
} }
/** /**
@ -236,7 +236,7 @@ class ChiSquaredDistribution
throw new \Exception('Out of bounds'); throw new \Exception('Out of bounds');
} }
return pow(1 - 2 * $t, -$df / 2); return \pow(1 - 2 * $t, -$df / 2);
} }
/** /**
@ -250,7 +250,7 @@ class ChiSquaredDistribution
*/ */
public static function getSkewness(int $df) : float public static function getSkewness(int $df) : float
{ {
return sqrt(8 / $df); return \sqrt(8 / $df);
} }
/** /**

View File

@ -36,7 +36,7 @@ class ExponentialDistribution
*/ */
public static function getPdf(float $x, float $lambda) : float public static function getPdf(float $x, float $lambda) : float
{ {
return $x >= 0 ? $lambda * exp(-$lambda * $x) : 0; return $x >= 0 ? $lambda * \exp(-$lambda * $x) : 0;
} }
/** /**
@ -51,7 +51,7 @@ class ExponentialDistribution
*/ */
public static function getCdf(float $x, float $lambda) : float public static function getCdf(float $x, float $lambda) : float
{ {
return $x >= 0 ? 1 - exp($lambda * $x) : 0; return $x >= 0 ? 1 - \exp($lambda * $x) : 0;
} }
/** /**
@ -105,7 +105,7 @@ class ExponentialDistribution
*/ */
public static function getVariance(float $lambda) : float public static function getVariance(float $lambda) : float
{ {
return pow($lambda, -2); return \pow($lambda, -2);
} }
/** /**

View File

@ -36,7 +36,7 @@ class GeometricDistribution
*/ */
public static function getPmf(float $p, int $k) : float public static function getPmf(float $p, int $k) : float
{ {
return pow(1 - $p, $k - 1) * $p; return \pow(1 - $p, $k - 1) * $p;
} }
/** /**
@ -51,7 +51,7 @@ class GeometricDistribution
*/ */
public static function getCdf(float $p, int $k) : float public static function getCdf(float $p, int $k) : float
{ {
return 1 - pow(1 - $p, $k); return 1 - \pow(1 - $p, $k);
} }
/** /**
@ -91,7 +91,7 @@ class GeometricDistribution
*/ */
public static function getMedian(float $p) : float public static function getMedian(float $p) : float
{ {
return ceil(-1 / (log(1 - $p, 2))); return ceil(-1 / (\log(1 - $p, 2)));
} }
/** /**
@ -120,7 +120,7 @@ class GeometricDistribution
*/ */
public static function getMgf(float $p, float $t) : float public static function getMgf(float $p, float $t) : float
{ {
return $p * exp($t) / (1 - (1 - $p) * exp($t)); return $p * \exp($t) / (1 - (1 - $p) * \exp($t));
} }
/** /**
@ -134,7 +134,7 @@ class GeometricDistribution
*/ */
public static function getSkewness(float $lambda) : float public static function getSkewness(float $lambda) : float
{ {
return (2 - $lambda) / sqrt(1 - $lambda); return (2 - $lambda) / \sqrt(1 - $lambda);
} }
/** /**

View File

@ -37,7 +37,7 @@ class LaplaceDistribution
*/ */
public static function getPdf(float $x, float $mu, float $b) : float public static function getPdf(float $x, float $mu, float $b) : float
{ {
return 1 / (2 * $b) * exp(-abs($x - $mu) / $b); return 1 / (2 * $b) * \exp(-abs($x - $mu) / $b);
} }
/** /**
@ -53,7 +53,7 @@ class LaplaceDistribution
*/ */
public static function getCdf(float $x, float $mu, float $b) : float public static function getCdf(float $x, float $mu, float $b) : float
{ {
return $x < $mu ? exp(($x - $mu) / $b) / 2 : 1 - exp(-($x - $mu) / $b) / 2; return $x < $mu ? \exp(($x - $mu) / $b) / 2 : 1 - \exp(-($x - $mu) / $b) / 2;
} }
/** /**
@ -131,7 +131,7 @@ class LaplaceDistribution
throw new \Exception('Out of bounds'); throw new \Exception('Out of bounds');
} }
return exp($mu * $t) / (1 - $b ** 2 * $t ** 2); return \exp($mu * $t) / (1 - $b ** 2 * $t ** 2);
} }
/** /**

View File

@ -38,7 +38,7 @@ class NormalDistribution
*/ */
public static function getPdf(float $x, float $mu, float $sig) : float public static function getPdf(float $x, float $mu, float $sig) : float
{ {
return 1 / ($sig * sqrt(2 * pi())) * exp(-($x - $mu) ** 2 / (2 * $sig ** 2)); return 1 / ($sig * \sqrt(2 * pi())) * \exp(-($x - $mu) ** 2 / (2 * $sig ** 2));
} }
/** /**
@ -110,7 +110,7 @@ class NormalDistribution
*/ */
public static function getMgf(float $t, float $mu, float $sig) : float public static function getMgf(float $t, float $mu, float $sig) : float
{ {
return exp($mu * $t + ($sig ** 2 * $t ** 2) / 2); return \exp($mu * $t + ($sig ** 2 * $t ** 2) / 2);
} }
/** /**

View File

@ -30,7 +30,7 @@ class PoissonDistribution
/** /**
* Get density. * Get density.
* *
* Formula: e^(k * ln(lambda) - lambda - log(gamma(k+1)) * Formula: e^(k * ln(lambda) - lambda - \log(gamma(k+1))
* *
* @param int $k Value k * @param int $k Value k
* @param float $lambda Lambda * @param float $lambda Lambda
@ -41,7 +41,7 @@ class PoissonDistribution
*/ */
public static function getPmf(int $k, float $lambda) : float public static function getPmf(int $k, float $lambda) : float
{ {
return exp($k * log($lambda) - $lambda - log(Gamma::getGammaInteger($k + 1))); return \exp($k * \log($lambda) - $lambda - \log(Gamma::getGammaInteger($k + 1)));
} }
/** /**
@ -59,10 +59,10 @@ class PoissonDistribution
$sum = 0.0; $sum = 0.0;
for ($i = 0; $i < $k + 1; ++$i) { for ($i = 0; $i < $k + 1; ++$i) {
$sum += pow($lambda, $i) / Functions::fact($i); $sum += \pow($lambda, $i) / Functions::fact($i);
} }
return exp(-$lambda) * $sum; return \exp(-$lambda) * $sum;
} }
/** /**
@ -133,7 +133,7 @@ class PoissonDistribution
*/ */
public static function getMgf(float $lambda, float $t) : float public static function getMgf(float $lambda, float $t) : float
{ {
return exp($lambda * (exp($t) - 1)); return \exp($lambda * (\exp($t) - 1));
} }
/** /**
@ -147,7 +147,7 @@ class PoissonDistribution
*/ */
public static function getSkewness(float $lambda) : float public static function getSkewness(float $lambda) : float
{ {
return pow($lambda, -1 / 2); return \pow($lambda, -1 / 2);
} }
/** /**
@ -161,7 +161,7 @@ class PoissonDistribution
*/ */
public static function getFisherInformation(float $lambda) : float public static function getFisherInformation(float $lambda) : float
{ {
return pow($lambda, -1); return \pow($lambda, -1);
} }
/** /**
@ -175,7 +175,7 @@ class PoissonDistribution
*/ */
public static function getExKurtosis(float $lambda) : float public static function getExKurtosis(float $lambda) : float
{ {
return pow($lambda, -1); return \pow($lambda, -1);
} }
public static function getRandom() public static function getRandom()

View File

@ -91,7 +91,7 @@ class UniformDistributionContinuous
*/ */
public static function getMgf(int $t, float $a, float $b) : float public static function getMgf(int $t, float $a, float $b) : float
{ {
return $t === 0 ? 1 : (exp($t * $b) - exp($t * $a)) / ($t * ($b - $a)); return $t === 0 ? 1 : (\exp($t * $b) - \exp($t * $a)) / ($t * ($b - $a));
} }
/** /**

View File

@ -59,7 +59,7 @@ class UniformDistributionDiscrete
throw new \Exception('Out of bounds'); throw new \Exception('Out of bounds');
} }
return (floor($k) - $a + 1) / ($b - $a + 1); return (\floor($k) - $a + 1) / ($b - $a + 1);
} }
/** /**
@ -75,7 +75,7 @@ class UniformDistributionDiscrete
*/ */
public static function getMgf(int $t, float $a, float $b) : float public static function getMgf(int $t, float $a, float $b) : float
{ {
return (exp($a * $t) - exp(($b + 1) * $t)) / (($b - $a + 1) * (1 - exp($t))); return (\exp($a * $t) - \exp(($b + 1) * $t)) / (($b - $a + 1) * (1 - \exp($t)));
} }
/** /**

View File

@ -44,11 +44,11 @@ class NaiveBayesFilter
$n = 0.0; $n = 0.0;
foreach ($toMatch as $element) { foreach ($toMatch as $element) {
if (isset($normalizedDict[$element])) { if (isset($normalizedDict[$element])) {
$n += log(1 - $normalizedDict[$element]['match'] / $normalizedDict[$element]['total']) - log($normalizedDict[$element]['match'] / $normalizedDict[$element]['total']); $n += \log(1 - $normalizedDict[$element]['match'] / $normalizedDict[$element]['total']) - \log($normalizedDict[$element]['match'] / $normalizedDict[$element]['total']);
} }
} }
return 1 / (1 + exp($n)); return 1 / (1 + \exp($n));
} }
private function normalizeDictionary() : array private function normalizeDictionary() : array

View File

@ -77,7 +77,7 @@ final class Header extends HeaderAbstract
return false; return false;
} }
$key = strtolower($key); $key = \strtolower($key);
if (!$overwrite && isset($this->header[$key])) { if (!$overwrite && isset($this->header[$key])) {
return false; return false;
@ -105,7 +105,7 @@ final class Header extends HeaderAbstract
*/ */
public static function isSecurityHeader(string $key) : bool public static function isSecurityHeader(string $key) : bool
{ {
$key = strtolower($key); $key = \strtolower($key);
return $key === 'content-security-policy' return $key === 'content-security-policy'
|| $key === 'x-xss-protection' || $key === 'x-xss-protection'

View File

@ -145,7 +145,7 @@ class EmailAbstract
*/ */
public function connect(string $user = '', string $pass = '') : void public function connect(string $user = '', string $pass = '') : void
{ {
$this->mailbox = substr($this->mailbox, 0, -1) . ($this->ssl ? '/ssl/validate-cert' : '/novalidate-cert') . '}'; $this->mailbox = \substr($this->mailbox, 0, -1) . ($this->ssl ? '/ssl/validate-cert' : '/novalidate-cert') . '}';
// /novalidate-cert // /novalidate-cert
if ($this->con === null) { if ($this->con === null) {
@ -235,7 +235,7 @@ class EmailAbstract
{ {
$ids = imap_search($this->con, $option, SE_FREE, 'UTF-8'); $ids = imap_search($this->con, $option, SE_FREE, 'UTF-8');
return is_array($ids) ? imap_fetch_overview($this->con, implode(',', $ids)) : []; return is_array($ids) ? imap_fetch_overview($this->con, \implode(',', $ids)) : [];
} }
/** /**

View File

@ -240,7 +240,7 @@ class Meta implements RenderableInterface
*/ */
public function render() : string public function render() : string
{ {
return (count($this->keywords) > 0 ? '<meta name="keywords" content="' . ViewAbstract::html(implode(',', $this->keywords)) . '">"' : '') return (\count($this->keywords) > 0 ? '<meta name="keywords" content="' . ViewAbstract::html(\implode(',', $this->keywords)) . '">"' : '')
. (!empty($this->author) ? '<meta name="author" content="' . ViewAbstract::html($this->author) . '">' : '') . (!empty($this->author) ? '<meta name="author" content="' . ViewAbstract::html($this->author) . '">' : '')
. (!empty($this->description) ? '<meta name="description" content="' . ViewAbstract::html($this->description) . '">' : '') . (!empty($this->description) ? '<meta name="description" content="' . ViewAbstract::html($this->description) . '">' : '')
. (!empty($this->charset) ? '<meta charset="' . ViewAbstract::html($this->charset) . '">' : '') . (!empty($this->charset) ? '<meta charset="' . ViewAbstract::html($this->charset) . '">' : '')

View File

@ -147,14 +147,14 @@ final class ModuleManager
$uriPdo = ''; $uriPdo = '';
$i = 1; $i = 1;
$c = count($uriHash); $c = \count($uriHash);
for ($k = 0; $k < $c; ++$k) { for ($k = 0; $k < $c; ++$k) {
$uriPdo .= ':pid' . $i . ','; $uriPdo .= ':pid' . $i . ',';
++$i; ++$i;
} }
$uriPdo = rtrim($uriPdo, ','); $uriPdo = \rtrim($uriPdo, ',');
/* TODO: make join in order to see if they are active */ /* TODO: make join in order to see if they are active */
$sth = $this->app->dbPool->get('select')->con->prepare( $sth = $this->app->dbPool->get('select')->con->prepare(
@ -250,8 +250,8 @@ final class ModuleManager
{ {
if (empty($this->all)) { if (empty($this->all)) {
chdir($this->modulePath); chdir($this->modulePath);
$files = glob('*', GLOB_ONLYDIR); $files = \glob('*', GLOB_ONLYDIR);
$c = count($files); $c = \count($files);
for ($i = 0; $i < $c; ++$i) { for ($i = 0; $i < $c; ++$i) {
$path = $this->modulePath . '/' . $files[$i] . '/info.json'; $path = $this->modulePath . '/' . $files[$i] . '/info.json';

View File

@ -76,7 +76,7 @@ class Client extends SocketAbstract
try { try {
$i++; $i++;
$msg = 'disconnect'; $msg = 'disconnect';
socket_write($this->sock, $msg, strlen($msg)); socket_write($this->sock, $msg, \strlen($msg));
$read = [$this->sock]; $read = [$this->sock];
@ -86,7 +86,7 @@ class Client extends SocketAbstract
// socket_strerror(socket_last_error()); // socket_strerror(socket_last_error());
//} //}
if (count($read) > 0) { if (\count($read) > 0) {
$data = socket_read($this->sock, 1024); $data = socket_read($this->sock, 1024);
/* Server no data */ /* Server no data */
@ -95,7 +95,7 @@ class Client extends SocketAbstract
} }
/* Normalize */ /* Normalize */
$data = trim($data); $data = \trim($data);
if (!empty($data)) { if (!empty($data)) {
$data = \explode(' ', $data); $data = \explode(' ', $data);

View File

@ -28,7 +28,7 @@ class ClientManager
public function get($id) public function get($id)
{ {
return $this->clients[$id] ?? new NullClientConnection(uniqid(), null); return $this->clients[$id] ?? new NullClientConnection(\uniqid(), null);
} }
public function getBySocket($socket) public function getBySocket($socket)
@ -39,7 +39,7 @@ class ClientManager
} }
} }
return new NullClientConnection(uniqid(), null); return new NullClientConnection(\uniqid(), null);
} }
public function remove($id) public function remove($id)

View File

@ -223,7 +223,7 @@ class Server extends SocketAbstract
public function connectClient($socket) : void public function connectClient($socket) : void
{ {
$this->app->logger->debug('Connecting client...'); $this->app->logger->debug('Connecting client...');
$this->clientManager->add($client = new ClientConnection(uniqid(), $socket)); $this->clientManager->add($client = new ClientConnection(\uniqid(), $socket));
$this->conn[$client->getId()] = $socket; $this->conn[$client->getId()] = $socket;
$this->app->logger->debug('Connected client.'); $this->app->logger->debug('Connected client.');
} }
@ -262,19 +262,19 @@ class Server extends SocketAbstract
private function unmask($payload) : string private function unmask($payload) : string
{ {
$length = ord($payload[1]) & 127; $length = \ord($payload[1]) & 127;
if ($length == 126) { if ($length == 126) {
$masks = substr($payload, 4, 4); $masks = \substr($payload, 4, 4);
$data = substr($payload, 8); $data = \substr($payload, 8);
} elseif ($length == 127) { } elseif ($length == 127) {
$masks = substr($payload, 10, 4); $masks = \substr($payload, 10, 4);
$data = substr($payload, 14); $data = \substr($payload, 14);
} else { } else {
$masks = substr($payload, 2, 4); $masks = \substr($payload, 2, 4);
$data = substr($payload, 6); $data = \substr($payload, 6);
} }
$text = ''; $text = '';
for ($i = 0; $i < strlen($data); ++$i) { for ($i = 0; $i < \strlen($data); ++$i) {
$text .= $data[$i] ^ $masks[$i % 4]; $text .= $data[$i] ^ $masks[$i % 4];
} }

View File

@ -71,7 +71,7 @@ abstract class Enum
$constants = self::getConstants(); $constants = self::getConstants();
$keys = array_keys($constants); $keys = array_keys($constants);
return $constants[$keys[mt_rand(0, count($constants) - 1)]]; return $constants[$keys[mt_rand(0, \count($constants) - 1)]];
} }
/** /**
@ -135,7 +135,7 @@ abstract class Enum
*/ */
public static function count() : int public static function count() : int
{ {
return count(self::getConstants()); return \count(self::getConstants());
} }
/** /**

View File

@ -75,7 +75,7 @@ class Iban implements \Serializable
*/ */
public static function normalize(string $iban) : string public static function normalize(string $iban) : string
{ {
return strtoupper(\str_replace(' ', '', $iban)); return \strtoupper(\str_replace(' ', '', $iban));
} }
/** /**
@ -87,7 +87,7 @@ class Iban implements \Serializable
*/ */
public function getLength() : int public function getLength() : int
{ {
return strlen($this->iban); return \strlen($this->iban);
} }
/** /**

View File

@ -163,7 +163,7 @@ class SmartDateTime extends \DateTime
*/ */
public function getFirstDayOfMonth() : int public function getFirstDayOfMonth() : int
{ {
return getdate(mktime(0, 0, 0, (int) $this->format('m'), 1, (int) $this->format('Y')))['wday']; return getdate(\mktime(0, 0, 0, (int) $this->format('m'), 1, (int) $this->format('Y')))['wday'];
} }
/** /**

View File

@ -369,7 +369,7 @@ class Graph
*/ */
public function getOrder() : int public function getOrder() : int
{ {
return count($this->nodes); return \count($this->nodes);
} }
/** /**
@ -383,7 +383,7 @@ class Graph
*/ */
public function getSize() : int public function getSize() : int
{ {
return count($this->edges); return \count($this->edges);
} }
/** /**
@ -405,7 +405,7 @@ class Graph
continue; continue;
} }
$diameter = max($diameter, $this->getFloydWarshallShortestPath($node1, $node2)); $diameter = \max($diameter, $this->getFloydWarshallShortestPath($node1, $node2));
} }
} }

View File

@ -82,7 +82,7 @@ class Tree extends Graph
$neighbors = $this->getNeighbors($currentNode); $neighbors = $this->getNeighbors($currentNode);
foreach ($neighbors as $neighbor) { foreach ($neighbors as $neighbor) {
$depth = max($depth, $depth + $this->getMaxDepth($neighbor)); $depth = \max($depth, $depth + $this->getMaxDepth($neighbor));
} }
return $depth; return $depth;
@ -114,7 +114,7 @@ class Tree extends Graph
$depth = empty($depth) ? 0 : $depth; $depth = empty($depth) ? 0 : $depth;
return min($depth) + 1; return \min($depth) + 1;
} }
/** /**
@ -148,7 +148,7 @@ class Tree extends Graph
*/ */
public function isLeaf(Node $node) : bool public function isLeaf(Node $node) : bool
{ {
return count($this->getEdgesOfNode($node)) === 1; return \count($this->getEdgesOfNode($node)) === 1;
} }
/** /**
@ -189,12 +189,12 @@ class Tree extends Graph
*/ */
public function isFull(int $type) : bool public function isFull(int $type) : bool
{ {
if (count($this->edges) % $type !== 0) { if (\count($this->edges) % $type !== 0) {
return false; return false;
} }
foreach ($this->nodes as $node) { foreach ($this->nodes as $node) {
$neighbors = count($this->getNeighbors($node)); $neighbors = \count($this->getNeighbors($node));
if ($neighbors !== $type && $neighbors !== 0) { if ($neighbors !== $type && $neighbors !== 0) {
return false; return false;
@ -216,7 +216,7 @@ class Tree extends Graph
*/ */
public function preOrder(Node $node, \Closure $callback) : void public function preOrder(Node $node, \Closure $callback) : void
{ {
if (count($this->nodes) === 0) { if (\count($this->nodes) === 0) {
return; return;
} }
@ -241,7 +241,7 @@ class Tree extends Graph
*/ */
public function postOrder(Node $node, \Closure $callback) : void public function postOrder(Node $node, \Closure $callback) : void
{ {
if (count($this->nodes) === 0) { if (\count($this->nodes) === 0) {
return; return;
} }

View File

@ -86,7 +86,7 @@ class MultiMap implements \Countable
*/ */
public function add(array $keys, $value, bool $overwrite = true) : bool public function add(array $keys, $value, bool $overwrite = true) : bool
{ {
$id = count($this->values); $id = \count($this->values);
$inserted = false; $inserted = false;
if ($this->keyType !== KeyType::SINGLE) { if ($this->keyType !== KeyType::SINGLE) {
@ -205,14 +205,14 @@ class MultiMap implements \Countable
$keys = Permutation::permut($key); $keys = Permutation::permut($key);
foreach ($keys as $key => $value) { foreach ($keys as $key => $value) {
$key = implode(':', $value); $key = \implode(':', $value);
if (isset($this->keys[$key])) { if (isset($this->keys[$key])) {
return $this->values[$this->keys[$key]]; return $this->values[$this->keys[$key]];
} }
} }
} else { } else {
$key = implode(':', $key); $key = \implode(':', $key);
} }
} }
@ -558,6 +558,6 @@ class MultiMap implements \Countable
*/ */
public function count() : int public function count() : int
{ {
return count($this->values); return \count($this->values);
} }
} }

View File

@ -64,7 +64,7 @@ class PriorityQueue implements \Countable, \Serializable
public function insert($data, string $job, float $priority = 1.0) : int public function insert($data, string $job, float $priority = 1.0) : int
{ {
do { do {
$key = rand(); $key = \rand();
} while (array_key_exists($key, $this->queue)); } while (array_key_exists($key, $this->queue));
if ($this->count === 0) { if ($this->count === 0) {
@ -201,6 +201,6 @@ class PriorityQueue implements \Countable, \Serializable
public function unserialize($data) public function unserialize($data)
{ {
$this->queue = \json_decode($data); $this->queue = \json_decode($data);
$this->count = count($this->queue); $this->count = \count($this->queue);
} }
} }

View File

@ -56,7 +56,7 @@ final class FileUtils
*/ */
public static function getExtensionType(string $extension) : int public static function getExtensionType(string $extension) : int
{ {
$extension = strtolower($extension); $extension = \strtolower($extension);
if (\in_array($extension, self::CODE_EXTENSION)) { if (\in_array($extension, self::CODE_EXTENSION)) {
return ExtensionType::CODE; return ExtensionType::CODE;
@ -93,7 +93,7 @@ final class FileUtils
public static function absolute(string $origPath) : string public static function absolute(string $origPath) : string
{ {
if (!\file_exists($origPath) || \realpath($origPath) === false) { if (!\file_exists($origPath) || \realpath($origPath) === false) {
$startsWithSlash = strpos($origPath, '/') === 0 ? '/' : ''; $startsWithSlash = \strpos($origPath, '/') === 0 ? '/' : '';
$path = []; $path = [];
$parts = \explode('/', $origPath); $parts = \explode('/', $origPath);

View File

@ -36,17 +36,17 @@ class Directory extends FileAbstract implements DirectoryInterface
{ {
public static function ftpConnect(Http $http) public static function ftpConnect(Http $http)
{ {
$con = ftp_connect($http->getBase() . $http->getPath(), $http->getPort()); $con = \ftp_connect($http->getBase() . $http->getPath(), $http->getPort());
ftp_login($con, $http->getUser(), $http->getPass()); \ftp_login($con, $http->getUser(), $http->getPass());
ftp_chdir($con, $http->getPath()); // todo: is this required ? \ftp_chdir($con, $http->getPath()); // todo: is this required ?
return $con; return $con;
} }
public static function ftpExists($con, string $path) public static function ftpExists($con, string $path)
{ {
$list = ftp_nlist($con, LocalFile::parent($path)); $list = \ftp_nlist($con, LocalFile::parent($path));
return \in_array(LocalFile::name($path), $list); return \in_array(LocalFile::name($path), $list);
} }
@ -54,13 +54,13 @@ class Directory extends FileAbstract implements DirectoryInterface
public static function ftpCreate($con, string $path, int $permission, bool $recursive) public static function ftpCreate($con, string $path, int $permission, bool $recursive)
{ {
$parts = \explode('/', $path); $parts = \explode('/', $path);
ftp_chdir($con, '/' . $parts[0]); \ftp_chdir($con, '/' . $parts[0]);
foreach ($parts as $part) { foreach ($parts as $part) {
if (self::ftpExists($con, $part)) { if (self::ftpExists($con, $part)) {
ftp_\mkdir($con, $part); \ftp_\kdir($con, $part);
ftp_chdir($con, $part); \ftp_chdir($con, $part);
ftp_chmod($con, $permission, $part); \ftp_chmod($con, $permission, $part);
} }
} }
} }
@ -274,7 +274,7 @@ class Directory extends FileAbstract implements DirectoryInterface
*/ */
public function rewind() public function rewind()
{ {
reset($this->nodes); \reset($this->nodes);
} }
/** /**
@ -282,7 +282,7 @@ class Directory extends FileAbstract implements DirectoryInterface
*/ */
public function current() public function current()
{ {
return current($this->nodes); return \current($this->nodes);
} }
/** /**
@ -290,7 +290,7 @@ class Directory extends FileAbstract implements DirectoryInterface
*/ */
public function key() public function key()
{ {
return key($this->nodes); return \key($this->nodes);
} }
/** /**
@ -298,7 +298,7 @@ class Directory extends FileAbstract implements DirectoryInterface
*/ */
public function next() public function next()
{ {
return next($this->nodes); return \next($this->nodes);
} }
/** /**
@ -306,7 +306,7 @@ class Directory extends FileAbstract implements DirectoryInterface
*/ */
public function valid() public function valid()
{ {
$key = key($this->nodes); $key = \key($this->nodes);
return ($key !== null && $key !== false); return ($key !== null && $key !== false);
} }

View File

@ -136,7 +136,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
parent::index(); parent::index();
foreach (\glob($this->path . DIRECTORY_SEPARATOR . $this->filter) as $filename) { foreach (\glob($this->path . DIRECTORY_SEPARATOR . $this->filter) as $filename) {
if (!StringUtils::endsWith(trim($filename), '.')) { if (!StringUtils::endsWith(\trim($filename), '.')) {
$file = \is_dir($filename) ? new self($filename) : new File($filename); $file = \is_dir($filename) ? new self($filename) : new File($filename);
$this->addNode($file); $this->addNode($file);

View File

@ -101,8 +101,8 @@ abstract class FileAbstract implements ContainerInterface
*/ */
public function __construct(string $path) public function __construct(string $path)
{ {
$this->path = rtrim($path, '/\\'); $this->path = \rtrim($path, '/\\');
$this->name = basename($path); $this->name = \basename($path);
$this->createdAt = new \DateTime('now'); $this->createdAt = new \DateTime('now');
$this->changedAt = new \DateTime('now'); $this->changedAt = new \DateTime('now');

View File

@ -68,7 +68,7 @@ final class Storage
} }
} else { } else {
$stg = $env; $stg = $env;
$env = ucfirst(strtolower($env)); $env = \ucfirst(\strtolower($env));
$env = __NAMESPACE__ . '\\' . $env . '\\' . $env . 'Storage'; $env = __NAMESPACE__ . '\\' . $env . '\\' . $env . 'Storage';
try { try {

View File

@ -43,11 +43,11 @@ final class OperatingSystem
*/ */
public static function getSystem() : int public static function getSystem() : int
{ {
if (stristr(PHP_OS, 'DAR') !== false) { if (\stristr(PHP_OS, 'DAR') !== false) {
return SystemType::OSX; return SystemType::OSX;
} elseif (stristr(PHP_OS, 'WIN') !== false) { } elseif (\stristr(PHP_OS, 'WIN') !== false) {
return SystemType::WIN; return SystemType::WIN;
} elseif (stristr(PHP_OS, 'LINUX') !== false) { } elseif (\stristr(PHP_OS, 'LINUX') !== false) {
return SystemType::LINUX; return SystemType::LINUX;
} }

View File

@ -90,7 +90,7 @@ final class SystemUtils
return $memUsage; return $memUsage;
} }
$free = trim($free); $free = \trim($free);
$freeArr = \explode("\n", $free); $freeArr = \explode("\n", $free);
$mem = \explode(' ', $freeArr[1]); $mem = \explode(' ', $freeArr[1]);
$mem = \array_values(\array_filter($mem)); $mem = \array_values(\array_filter($mem));

View File

@ -257,7 +257,7 @@ final class Argument implements UriInterface
*/ */
public function getPathElement(int $pos = null) : string public function getPathElement(int $pos = null) : string
{ {
return explode('/', $this->path)[$pos] ?? ''; return \explode('/', $this->path)[$pos] ?? '';
} }
/** /**
@ -265,7 +265,7 @@ final class Argument implements UriInterface
*/ */
public function getPathElements() : array public function getPathElements() : array
{ {
return explode('/', $this->path); return \explode('/', $this->path);
} }
/** /**

View File

@ -116,7 +116,7 @@ final class UriFactory
{ {
self::setQuery('/scheme', $uri->getScheme()); self::setQuery('/scheme', $uri->getScheme());
self::setQuery('/host', $uri->getHost()); self::setQuery('/host', $uri->getHost());
self::setQuery('/base', rtrim($uri->getBase(), '/')); self::setQuery('/base', \rtrim($uri->getBase(), '/'));
self::setQuery('/rootPath', $uri->getRootPath()); self::setQuery('/rootPath', $uri->getRootPath());
self::setQuery('?', $uri->getQuery()); self::setQuery('?', $uri->getQuery());
self::setQuery('%', $uri->__toString()); self::setQuery('%', $uri->__toString());
@ -189,10 +189,10 @@ final class UriFactory
{ {
$parts = \explode('&', \str_replace('?', '&', $url)); $parts = \explode('&', \str_replace('?', '&', $url));
if (count($parts) >= 2) { if (\count($parts) >= 2) {
$pars = \array_slice($parts, 1); $pars = \array_slice($parts, 1);
$comps = []; $comps = [];
$length = count($pars); $length = \count($pars);
for ($i = 0; $i < $length; ++$i) { for ($i = 0; $i < $length; ++$i) {
$spl = \explode('=', $pars[$i]); $spl = \explode('=', $pars[$i]);

View File

@ -48,7 +48,7 @@ final class ArrayUtils
*/ */
public static function unsetArray(string $path, array $data, string $delim = '/') : array public static function unsetArray(string $path, array $data, string $delim = '/') : array
{ {
$nodes = \explode($delim, trim($path, $delim)); $nodes = \explode($delim, \trim($path, $delim));
$prevEl = null; $prevEl = null;
$el = &$data; $el = &$data;
$node = null; $node = null;
@ -89,7 +89,7 @@ final class ArrayUtils
*/ */
public static function setArray(string $path, array $data, $value, string $delim = '/', bool $overwrite = false) : array public static function setArray(string $path, array $data, $value, string $delim = '/', bool $overwrite = false) : array
{ {
$pathParts = \explode($delim, trim($path, $delim)); $pathParts = \explode($delim, \trim($path, $delim));
$current = &$data; $current = &$data;
if ($pathParts === false) { if ($pathParts === false) {
@ -128,7 +128,7 @@ final class ArrayUtils
*/ */
public static function getArray(string $path, array $data, string $delim = '/') public static function getArray(string $path, array $data, string $delim = '/')
{ {
$pathParts = \explode($delim, trim($path, $delim)); $pathParts = \explode($delim, \trim($path, $delim));
$current = $data; $current = $data;
if ($pathParts === false) { if ($pathParts === false) {
@ -237,7 +237,7 @@ final class ArrayUtils
$key = '\'' . $key . '\''; $key = '\'' . $key . '\'';
} }
switch (gettype($value)) { switch (\gettype($value)) {
case 'array': case 'array':
$str .= $key . ' => ' . self::stringify($value) . ', '; $str .= $key . ' => ' . self::stringify($value) . ', ';
break; break;
@ -306,11 +306,11 @@ final class ArrayUtils
*/ */
public static function getArg(string $id, array $args) : ?string public static function getArg(string $id, array $args) : ?string
{ {
if (($key = \array_search($id, $args)) === false || $key === count($args) - 1) { if (($key = \array_search($id, $args)) === false || $key === \count($args) - 1) {
return null; return null;
} }
return trim($args[(int) $key + 1], '" '); return \trim($args[(int) $key + 1], '" ');
} }
/** /**
@ -375,7 +375,7 @@ final class ArrayUtils
*/ */
public static function arraySum(array $array, int $start = 0, int $count = 0) public static function arraySum(array $array, int $start = 0, int $count = 0)
{ {
$count = $count === 0 ? count($array) : $start + $count; $count = $count === 0 ? \count($array) : $start + $count;
$sum = 0; $sum = 0;
$array = array_values($array); $array = array_values($array);

View File

@ -285,7 +285,7 @@ abstract class C128Abstract
$checksum += $values[$activeKey] * $pos; $checksum += $values[$activeKey] * $pos;
} }
$codeString .= static::$CODEARRAY[$keys[($checksum - (intval($checksum / 103) * 103))]]; $codeString .= static::$CODEARRAY[$keys[($checksum - (\intval($checksum / 103) * 103))]];
return $codeString; return $codeString;
} }

View File

@ -91,6 +91,6 @@ class C128a extends C128Abstract
*/ */
public function setContent(string $content) : void public function setContent(string $content) : void
{ {
parent::setContent(strtoupper($content)); parent::setContent(\strtoupper($content));
} }
} }

View File

@ -91,15 +91,15 @@ class C128c extends C128Abstract
$keys = array_keys(self::$CODEARRAY); $keys = array_keys(self::$CODEARRAY);
$values = array_flip($keys); $values = array_flip($keys);
$codeString = ''; $codeString = '';
$length = strlen($this->content); $length = \strlen($this->content);
$checksum = self::$CHECKSUM; $checksum = self::$CHECKSUM;
$checkPos = 1; $checkPos = 1;
for ($pos = 1; $pos <= $length; $pos += 2) { for ($pos = 1; $pos <= $length; $pos += 2) {
if ($pos + 1 <= $length) { if ($pos + 1 <= $length) {
$activeKey = substr($this->content, ($pos - 1), 2); $activeKey = \substr($this->content, ($pos - 1), 2);
} else { } else {
$activeKey = substr($this->content, ($pos - 1), 1) . '0'; $activeKey = \substr($this->content, ($pos - 1), 1) . '0';
} }
$codeString .= self::$CODEARRAY[$activeKey]; $codeString .= self::$CODEARRAY[$activeKey];
@ -107,7 +107,7 @@ class C128c extends C128Abstract
$checkPos++; $checkPos++;
} }
$codeString .= self::$CODEARRAY[$keys[($checksum - (intval($checksum / 103) * 103))]]; $codeString .= self::$CODEARRAY[$keys[($checksum - (\intval($checksum / 103) * 103))]];
return $codeString; return $codeString;
} }

View File

@ -109,13 +109,13 @@ class C25 extends C128Abstract
protected function generateCodeString() : string protected function generateCodeString() : string
{ {
$codeString = ''; $codeString = '';
$length = strlen($this->content); $length = \strlen($this->content);
$arrayLength = count(self::$CODEARRAY); $arrayLength = \count(self::$CODEARRAY);
$temp = []; $temp = [];
for ($posX = 1; $posX <= $length; $posX++) { for ($posX = 1; $posX <= $length; $posX++) {
for ($posY = 0; $posY < $arrayLength; $posY++) { for ($posY = 0; $posY < $arrayLength; $posY++) {
if (substr($this->content, ($posX - 1), 1) == self::$CODEARRAY[$posY]) { if (\substr($this->content, ($posX - 1), 1) == self::$CODEARRAY[$posY]) {
$temp[$posX] = self::$CODEARRAY2[$posY]; $temp[$posX] = self::$CODEARRAY2[$posY];
} }
} }
@ -126,7 +126,7 @@ class C25 extends C128Abstract
$temp1 = \explode('-', $temp[$posX]); $temp1 = \explode('-', $temp[$posX]);
$temp2 = \explode('-', $temp[($posX + 1)]); $temp2 = \explode('-', $temp[($posX + 1)]);
$count = count($temp1); $count = \count($temp1);
for ($posY = 0; $posY < $count; $posY++) { for ($posY = 0; $posY < $count; $posY++) {
$codeString .= $temp1[$posY] . $temp2[$posY]; $codeString .= $temp1[$posY] . $temp2[$posY];
} }

View File

@ -72,7 +72,7 @@ class C39 extends C128Abstract
*/ */
public function setContent(string $content) : void public function setContent(string $content) : void
{ {
parent::setContent(strtoupper($content)); parent::setContent(\strtoupper($content));
} }
/** /**
@ -85,7 +85,7 @@ class C39 extends C128Abstract
protected function generateCodeString() : string protected function generateCodeString() : string
{ {
$codeString = ''; $codeString = '';
$length = strlen($this->content); $length = \strlen($this->content);
for ($X = 1; $X <= $length; $X++) { for ($X = 1; $X <= $length; $X++) {
$codeString .= self::$CODEARRAY[substr($this->content, ($X - 1), 1)] . '1'; $codeString .= self::$CODEARRAY[substr($this->content, ($X - 1), 1)] . '1';

View File

@ -73,7 +73,7 @@ class Codebar extends C128Abstract
*/ */
public function setContent(string $content) : void public function setContent(string $content) : void
{ {
parent::setContent(strtoupper($content)); parent::setContent(\strtoupper($content));
} }
/** /**
@ -86,12 +86,12 @@ class Codebar extends C128Abstract
protected function generateCodeString() : string protected function generateCodeString() : string
{ {
$codeString = ''; $codeString = '';
$length = strlen($this->content); $length = \strlen($this->content);
$lenCodearr = count(self::$CODEARRAY); $lenCodearr = \count(self::$CODEARRAY);
for ($posX = 1; $posX <= $length; $posX++) { for ($posX = 1; $posX <= $length; $posX++) {
for ($posY = 0; $posY < $lenCodearr; $posY++) { for ($posY = 0; $posY < $lenCodearr; $posY++) {
if (substr($this->content, ($posX - 1), 1) == self::$CODEARRAY[$posY]) { if (\substr($this->content, ($posX - 1), 1) == self::$CODEARRAY[$posY]) {
$codeString .= self::$CODEARRAY2[$posY] . '1'; $codeString .= self::$CODEARRAY2[$posY] . '1';
} }
} }

Some files were not shown because too many files have changed in this diff Show More