From 270f42a41c9f20bac4ef842e417f4c42e17c3b14 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Sun, 29 Oct 2017 10:24:22 +0000 Subject: [PATCH] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- Business/Finance/Depreciation.php | 4 +- .../ExponentialSmoothing.php | 132 +++++++++--------- Business/Programming/Metrics.php | 2 +- Business/Sales/MarketShareEstimation.php | 4 +- DataStorage/Cache/FileCache.php | 14 +- DataStorage/Database/DataMapperAbstract.php | 2 +- .../InvalidConnectionConfigException.php | 2 +- Math/Geometry/ConvexHull/MonotoneChain.php | 4 +- Math/Geometry/Shape/D2/Polygon.php | 2 +- Math/Matrix/CholeskyDecomposition.php | 2 +- Math/Matrix/LUDecomposition.php | 12 +- Math/Matrix/QRDecomposition.php | 16 +-- Math/Stochastic/NaiveBayesFilter.php | 4 +- Stdlib/Base/SmartDateTime.php | 2 +- Stdlib/Graph/BinaryTree.php | 4 +- Utils/Encoding/Caesar.php | 2 +- Views/ViewAbstract.php | 2 +- 17 files changed, 105 insertions(+), 105 deletions(-) diff --git a/Business/Finance/Depreciation.php b/Business/Finance/Depreciation.php index bc81ee37a..ff3531b11 100644 --- a/Business/Finance/Depreciation.php +++ b/Business/Finance/Depreciation.php @@ -29,7 +29,7 @@ class Depreciation public static function getArithmeticProgressivDepreciationRate(float $start, int $duration) : float { - return $start / ($duration * ($duration+1) / 2); + return $start / ($duration * ($duration + 1) / 2); } public static function getArithmeticProgressivDepreciationInT(float $start, int $duration, int $t) : float @@ -44,7 +44,7 @@ class Depreciation 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)); } public static function getGeometicDegressivDepreciationInT(float $start, float $residual, int $duration, int $t) : float diff --git a/Business/Finance/Forecasting/ExponentialSmoothing/ExponentialSmoothing.php b/Business/Finance/Forecasting/ExponentialSmoothing/ExponentialSmoothing.php index 29d5c78d8..2aa496d13 100644 --- a/Business/Finance/Forecasting/ExponentialSmoothing/ExponentialSmoothing.php +++ b/Business/Finance/Forecasting/ExponentialSmoothing/ExponentialSmoothing.php @@ -35,7 +35,7 @@ class ExponentialSmoothing public function __construct(array $data) { - $this->data = $data; + $this->data = $data; } public function getRMSE() : float @@ -86,7 +86,7 @@ class ExponentialSmoothing if ($this->rmse < $bestError) { $bestError = $this->rmse; - $forecast = $tempForecast; + $forecast = $tempForecast; } } } @@ -137,14 +137,14 @@ class ExponentialSmoothing $alpha = 0.00; while ($alpha < 1) { - $error = []; + $error = []; $tempForecast = []; for ($i = 1; $i < $dataLength; $i++) { - $level[$i] = $alpha * ($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) + (1 - $alpha) * $level[$i-1]; + $level[$i] = $alpha * ($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) + (1 - $alpha) * $level[$i - 1]; $tempForecast[$i] = $level[$i]; - $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; + $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; } $tempRMSE = Error::getRootMeanSquaredError($error); @@ -172,8 +172,8 @@ class ExponentialSmoothing $forecast = []; $seasonal = []; - for ($i = 1; $i < $cycle+1; $i++) { - $seasonal[$i] = $this->data[$i-1] - $level[0]; + for ($i = 1; $i < $cycle + 1; $i++) { + $seasonal[$i] = $this->data[$i - 1] - $level[0]; } $alpha = 0.00; @@ -182,17 +182,17 @@ class ExponentialSmoothing while ($gamma < 1) { $gamma_ = $gamma * (1 - $alpha); - $error = []; + $error = []; $tempForecast = []; for ($i = 1; $i < $dataLength; $i++) { - $hm = (int) floor(($i-1) % $cycle) + 1; + $hm = (int) floor(($i - 1) % $cycle) + 1; - $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) - $seasonal[$i]) + (1 - $alpha) * $level[$i-1]; - $seasonal[$i+$cycle] = $gamma_*(($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) - $level[$i-1]) + (1 - $gamma_) * $seasonal[$i]; + $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) - $seasonal[$i]) + (1 - $alpha) * $level[$i - 1]; + $seasonal[$i + $cycle] = $gamma_ * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) - $level[$i - 1]) + (1 - $gamma_) * $seasonal[$i]; - $tempForecast[$i] = $level[$i] + $seasonal[$i+$hm]; - $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; + $tempForecast[$i] = $level[$i] + $seasonal[$i + $hm]; + $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; } $tempRMSE = Error::getRootMeanSquaredError($error); @@ -223,7 +223,7 @@ class ExponentialSmoothing $forecast = []; $seasonal = []; - for ($i = 1; $i < $cycle+1; $i++) { + for ($i = 1; $i < $cycle + 1; $i++) { $seasonal[$i] = $this->data[$i] / $level[0]; } @@ -233,17 +233,17 @@ class ExponentialSmoothing while ($gamma < 1) { $gamma_ = $gamma * (1 - $alpha); - $error = []; + $error = []; $tempForecast = []; for ($i = 1; $i < $dataLength; $i++) { - $hm = (int) floor(($i-1) % $cycle) + 1; + $hm = (int) floor(($i - 1) % $cycle) + 1; - $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) / $seasonal[$i]) + (1 - $alpha) * $level[$i-1]; - $seasonal[$i+$cycle] = $gamma_*(($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) / $level[$i-1]) + (1 - $gamma_) * $seasonal[$i]; + $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) / $seasonal[$i]) + (1 - $alpha) * $level[$i - 1]; + $seasonal[$i + $cycle] = $gamma_ * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) / $level[$i - 1]) + (1 - $gamma_) * $seasonal[$i]; - $tempForecast[$i] = $level[$i] + $seasonal[$i+$hm]; - $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; + $tempForecast[$i] = $level[$i] + $seasonal[$i + $hm]; + $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; } $tempRMSE = Error::getRootMeanSquaredError($error); @@ -279,15 +279,15 @@ class ExponentialSmoothing $beta = 0.00; while ($beta < 1) { - $error = []; + $error = []; $tempForecast = []; for ($i = 1; $i < $dataLength; $i++) { - $level[$i] = $alpha * ($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) + (1 - $alpha) * ($level[$i-1] + $damping * $trend[$i-1]); - $trend[$i] = $beta * ($level[$i] - $level[$i-1]) + (1 - $beta) * $damping * $trend[$i-1]; + $level[$i] = $alpha * ($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) + (1 - $alpha) * ($level[$i - 1] + $damping * $trend[$i - 1]); + $trend[$i] = $beta * ($level[$i] - $level[$i - 1]) + (1 - $beta) * $damping * $trend[$i - 1]; $tempForecast[$i] = $level[$i] + $this->dampingSum($damping, $i) * $trend[$i]; - $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; + $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; } $tempRMSE = Error::getRootMeanSquaredError($error); @@ -320,14 +320,14 @@ class ExponentialSmoothing $seasonal = []; $sum = 0; - for ($i = 1; $i < $cycle+1; $i++) { + for ($i = 1; $i < $cycle + 1; $i++) { $sum += ($this->data[$cycle] - $this->data[$i]) / $cycle; } $trend[0] *= $sum; - for ($i = 1; $i < $cycle+1; $i++) { - $seasonal[$i] = $this->data[$i-1] - $level[0]; + for ($i = 1; $i < $cycle + 1; $i++) { + $seasonal[$i] = $this->data[$i - 1] - $level[0]; } $alpha = 0.00; @@ -339,18 +339,18 @@ class ExponentialSmoothing while ($gamma < 1) { $gamma_ = $gamma * (1 - $alpha); - $error = []; + $error = []; $tempForecast = []; for ($i = 1; $i < $dataLength; $i++) { - $hm = (int) floor(($i-1) % $cycle) + 1; + $hm = (int) floor(($i - 1) % $cycle) + 1; - $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) - $seasonal[$i]) + (1 - $alpha) * ($level[$i-1] + $damping * $trend[$i-1]); - $trend[$i] = $beta * ($level[$i] - $level[$i-1]) + (1 - $beta) * $damping * $trend[$i-1]; - $seasonal[$i+$cycle] = $gamma_*(($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) - $level[$i-1]) + (1 - $gamma_) * $seasonal[$i]; + $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) - $seasonal[$i]) + (1 - $alpha) * ($level[$i - 1] + $damping * $trend[$i - 1]); + $trend[$i] = $beta * ($level[$i] - $level[$i - 1]) + (1 - $beta) * $damping * $trend[$i - 1]; + $seasonal[$i + $cycle] = $gamma_ * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) - $level[$i - 1]) + (1 - $gamma_) * $seasonal[$i]; - $tempForecast[$i] = $level[$i] + $this->dampingSum($damping, $i) * $trend[$i] + $seasonal[$i+$hm]; - $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; + $tempForecast[$i] = $level[$i] + $this->dampingSum($damping, $i) * $trend[$i] + $seasonal[$i + $hm]; + $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; } $tempRMSE = Error::getRootMeanSquaredError($error); @@ -387,13 +387,13 @@ class ExponentialSmoothing $gamma_ = $gamma * (1 - $alpha); $sum = 0; - for ($i = 1; $i < $cycle+1; $i++) { + for ($i = 1; $i < $cycle + 1; $i++) { $sum += ($this->data[$cycle] - $this->data[$i]) / $cycle; } $trend[0] *= $sum; - for ($i = 1; $i < $cycle+1; $i++) { + for ($i = 1; $i < $cycle + 1; $i++) { $seasonal[$i] = $this->data[$i] / $level[0]; } @@ -406,18 +406,18 @@ class ExponentialSmoothing while ($gamma < 1) { $gamma_ = $gamma * (1 - $alpha); - $error = []; + $error = []; $tempForecast = []; for ($i = 1; $i < $dataLength; $i++) { - $hm = (int) floor(($i-1) % $cycle) + 1; + $hm = (int) floor(($i - 1) % $cycle) + 1; - $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) / $seasonal[$i]) + (1 - $alpha) * ($level[$i-1] + $damping * $trend[$i-1]); - $trend[$i] = $beta * ($level[$i] - $level[$i-1]) + (1 - $beta) * $damping * $trend[$i-1]; - $seasonal[$i+$cycle] = $gamma_*($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) / ($level[$i-1] + $damping * $trend[$i-1]) + (1 - $gamma_) * $seasonal[$i]; + $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) / $seasonal[$i]) + (1 - $alpha) * ($level[$i - 1] + $damping * $trend[$i - 1]); + $trend[$i] = $beta * ($level[$i] - $level[$i - 1]) + (1 - $beta) * $damping * $trend[$i - 1]; + $seasonal[$i + $cycle] = $gamma_ * ($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) / ($level[$i - 1] + $damping * $trend[$i - 1]) + (1 - $gamma_) * $seasonal[$i]; - $tempForecast[] = ($level[$i] + $this->dampingSum($damping, $i) * $trend[$i-1]) * $seasonal[$i+$hm]; - $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; + $tempForecast[] = ($level[$i] + $this->dampingSum($damping, $i) * $trend[$i - 1]) * $seasonal[$i + $hm]; + $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; } $tempRMSE = Error::getRootMeanSquaredError($error); @@ -456,15 +456,15 @@ class ExponentialSmoothing $beta = 0.00; while ($beta < 1) { - $error = []; + $error = []; $tempForecast = []; for ($i = 1; $i < $dataLength; $i++) { - $level[$i] = $alpha * ($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) + (1 - $alpha) * $level[$i-1] * pow($trend[$i-1], $damping); - $trend[$i] = $beta * ($level[$i] / $level[$i-1]) + (1 - $beta) * pow($trend[$i-1], $damping); + $level[$i] = $alpha * ($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) + (1 - $alpha) * $level[$i - 1] * pow($trend[$i - 1], $damping); + $trend[$i] = $beta * ($level[$i] / $level[$i - 1]) + (1 - $beta) * pow($trend[$i - 1], $damping); $tempForecast[$i] = $level[$i] * pow($trend[$i], $this->dampingSum($damping, $i)); - $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; + $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; } $tempRMSE = Error::getRootMeanSquaredError($error); @@ -496,14 +496,14 @@ class ExponentialSmoothing $seasonal = []; $sum = 0; - for ($i = 1; $i < $cycle+1; $i++) { + for ($i = 1; $i < $cycle + 1; $i++) { $sum += ($this->data[$cycle] - $this->data[$i]) / $cycle; } $trend[0] *= $sum; - for ($i = 1; $i < $cycle+1; $i++) { - $seasonal[$i] = $this->data[$i-1] - $level[0]; + for ($i = 1; $i < $cycle + 1; $i++) { + $seasonal[$i] = $this->data[$i - 1] - $level[0]; } $alpha = 0.00; @@ -515,18 +515,18 @@ class ExponentialSmoothing while ($gamma < 1) { $gamma_ = $gamma * (1 - $alpha); - $error = []; + $error = []; $tempForecast = []; for ($i = 1; $i < $dataLength; $i++) { - $hm = (int) floor(($i-1) % $cycle) + 1; + $hm = (int) floor(($i - 1) % $cycle) + 1; - $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) - $seasonal[$i]) + (1 - $alpha) * $level[$i-1] * pow($trend[$i-1], $damping); - $trend[$i] = $beta * ($level[$i] / $level[$i-1]) + (1 - $beta) * pow($trend[$i-1], $damping); - $seasonal[$i+$cycle] = $gamma_*(($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) - $level[$i-1] * pow($trend[$i-1], $damping)) + (1 - $gamma_) * $seasonal[$i]; + $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) - $seasonal[$i]) + (1 - $alpha) * $level[$i - 1] * pow($trend[$i - 1], $damping); + $trend[$i] = $beta * ($level[$i] / $level[$i - 1]) + (1 - $beta) * pow($trend[$i - 1], $damping); + $seasonal[$i + $cycle] = $gamma_ * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) - $level[$i - 1] * pow($trend[$i - 1], $damping)) + (1 - $gamma_) * $seasonal[$i]; - $tempForecast[$i] = $level[$i] * pow($trend[$i], $this->dampingSum($damping, $i)) + $seasonal[$i+$hm]; - $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; + $tempForecast[$i] = $level[$i] * pow($trend[$i], $this->dampingSum($damping, $i)) + $seasonal[$i + $hm]; + $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; } $tempRMSE = Error::getRootMeanSquaredError($error); @@ -562,13 +562,13 @@ class ExponentialSmoothing $seasonal = []; $sum = 0; - for ($i = 1; $i < $cycle+1; $i++) { + for ($i = 1; $i < $cycle + 1; $i++) { $sum += ($this->data[$cycle] - $this->data[$i]) / $cycle; } $trend[0] *= $sum; - for ($i = 1; $i < $cycle+1; $i++) { + for ($i = 1; $i < $cycle + 1; $i++) { $seasonal[$i] = $this->data[$i] / $level[0]; } @@ -581,18 +581,18 @@ class ExponentialSmoothing while ($gamma < 1) { $gamma_ = $gamma * (1 - $alpha); - $error = []; + $error = []; $tempForecast = []; for ($i = 1; $i < $dataLength; $i++) { - $hm = (int) floor(($i-1) % $cycle) + 1; + $hm = (int) floor(($i - 1) % $cycle) + 1; - $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) / $seasonal[$i]) + (1 - $alpha) * $level[$i-1] * pow($trend[$i-1], $damping); - $trend[$i] = $beta * ($level[$i] / $level[$i-1]) + (1 - $beta) * pow($trend[$i-1], $damping); - $seasonal[$i+$cycle] = $gamma_*($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) / ($level[$i-1] * pow($trend[$i-1], $damping)) + (1 - $gamma_) * $seasonal[$i]; + $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) / $seasonal[$i]) + (1 - $alpha) * $level[$i - 1] * pow($trend[$i - 1], $damping); + $trend[$i] = $beta * ($level[$i] / $level[$i - 1]) + (1 - $beta) * pow($trend[$i - 1], $damping); + $seasonal[$i + $cycle] = $gamma_ * ($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) / ($level[$i - 1] * pow($trend[$i - 1], $damping)) + (1 - $gamma_) * $seasonal[$i]; - $tempForecast[$i] = $level[$i] * pow($trend[$i], $this->dampingSum($damping, $i)) * $seasonal[$i+$hm]; - $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; + $tempForecast[$i] = $level[$i] * pow($trend[$i], $this->dampingSum($damping, $i)) * $seasonal[$i + $hm]; + $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; } $tempRMSE = Error::getRootMeanSquaredError($error); diff --git a/Business/Programming/Metrics.php b/Business/Programming/Metrics.php index 73523e6ce..d1287ad90 100644 --- a/Business/Programming/Metrics.php +++ b/Business/Programming/Metrics.php @@ -42,7 +42,7 @@ class Metrics { */ 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); } /** diff --git a/Business/Sales/MarketShareEstimation.php b/Business/Sales/MarketShareEstimation.php index 0d9af9ccd..0a6d525bd 100644 --- a/Business/Sales/MarketShareEstimation.php +++ b/Business/Sales/MarketShareEstimation.php @@ -45,7 +45,7 @@ class MarketShareEstimation { { $sum = 0.0; 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)); @@ -68,7 +68,7 @@ class MarketShareEstimation { { $sum = 0.0; for ($i = 0; $i < $participants; $i++) { - $sum += 1 / pow($i+1, $modifier); + $sum += 1 / pow($i + 1, $modifier); } return (1 / pow($rank, $modifier)) / $sum; diff --git a/DataStorage/Cache/FileCache.php b/DataStorage/Cache/FileCache.php index d2106fe6d..df4f5a264 100644 --- a/DataStorage/Cache/FileCache.php +++ b/DataStorage/Cache/FileCache.php @@ -262,9 +262,9 @@ class FileCache implements CacheInterface private function getExpire(string $raw) : int { $expireStart = strpos($raw, self::DELIM); - $expireEnd = strpos($raw, self::DELIM, $expireStart+1); + $expireEnd = strpos($raw, self::DELIM, $expireStart + 1); - return (int) substr($raw, $expireStart+1, $expireEnd - ($expireStart+1)); + return (int) substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1)); } /** @@ -294,8 +294,8 @@ class FileCache implements CacheInterface $type = $raw[0]; $expireStart = strpos($raw, self::DELIM); - $expireEnd = strpos($raw, self::DELIM, $expireStart+1); - $cacheExpire = substr($raw, $expireStart+1, $expireEnd - ($expireStart+1)); + $expireEnd = strpos($raw, self::DELIM, $expireStart + 1); + $cacheExpire = substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1)); if ($cacheExpire >= 0 && $created + $cacheExpire < $now) { $this->delete($key); @@ -324,7 +324,7 @@ class FileCache implements CacheInterface case CacheType::_SERIALIZABLE: case CacheType::_JSONSERIALIZABLE: $namespaceStart = strpos($raw, self::DELIM, $expireEnd); - $namespaceEnd = strpos($raw, self::DELIM, $namespaceStart+1); + $namespaceEnd = strpos($raw, self::DELIM, $namespaceStart + 1); $namespace = substr($raw, $namespaceStart, $namespaceEnd); $value = $namespace::unserialize(substr($raw, $namespaceEnd + 1)); @@ -357,8 +357,8 @@ class FileCache implements CacheInterface $now = time(); $raw = file_get_contents($path); $expireStart = strpos($raw, self::DELIM); - $expireEnd = strpos($raw, self::DELIM, $expireStart+1); - $cacheExpire = substr($raw, $expireStart+1, $expireEnd - ($expireStart+1)); + $expireEnd = strpos($raw, self::DELIM, $expireStart + 1); + $cacheExpire = substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1)); if ($cacheExpire >= 0 && $created + $cacheExpire > $now) { File::delete($path); diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index b94509788..2a322af40 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -377,7 +377,7 @@ class DataMapperAbstract implements DataMapperInterface { self::extend(__CLASS__); - $objId = self::createModelArray($obj); + $objId = self::createModelArray($obj); settype($objId, static::$columns[static::$primaryField]['type']); $obj[static::$columns[static::$primaryField]['internal']] = $objId; diff --git a/DataStorage/Database/Exception/InvalidConnectionConfigException.php b/DataStorage/Database/Exception/InvalidConnectionConfigException.php index 1acdb5fc5..0106fdb90 100644 --- a/DataStorage/Database/Exception/InvalidConnectionConfigException.php +++ b/DataStorage/Database/Exception/InvalidConnectionConfigException.php @@ -37,6 +37,6 @@ class InvalidConnectionConfigException extends \InvalidArgumentException */ public function __construct(string $message = '', int $code = 0, \Exception $previous = null) { - parent::__construct('Missing config value for "'. $message .'".', $code, $previous); + parent::__construct('Missing config value for "' . $message . '".', $code, $previous); } } diff --git a/Math/Geometry/ConvexHull/MonotoneChain.php b/Math/Geometry/ConvexHull/MonotoneChain.php index 5c1198bec..f16cb8c46 100644 --- a/Math/Geometry/ConvexHull/MonotoneChain.php +++ b/Math/Geometry/ConvexHull/MonotoneChain.php @@ -55,7 +55,7 @@ final class MonotoneChain } // Upper hull - for ($i = $n - 2, $t = $k+1; $i >= 0; $i--) { + for ($i = $n - 2, $t = $k + 1; $i >= 0; $i--) { while ($k >= $t && self::cross($result[$k - 2], $result[$k - 1], $points[$i]) <= 0) { $k--; } @@ -65,7 +65,7 @@ final class MonotoneChain ksort($result); - return array_slice($result, 0, $k-1); + return array_slice($result, 0, $k - 1); } return $points; diff --git a/Math/Geometry/Shape/D2/Polygon.php b/Math/Geometry/Shape/D2/Polygon.php index 1a09d74f1..43c0c32de 100644 --- a/Math/Geometry/Shape/D2/Polygon.php +++ b/Math/Geometry/Shape/D2/Polygon.php @@ -157,7 +157,7 @@ class Polygon implements D2ShapeInterface } // Inside or ontop? - $countIntersect = 0; + $countIntersect = 0; $polygon_count = count($polygon); // todo: return based on highest possibility not by first match diff --git a/Math/Matrix/CholeskyDecomposition.php b/Math/Matrix/CholeskyDecomposition.php index 5941057c4..6cc81d63b 100644 --- a/Math/Matrix/CholeskyDecomposition.php +++ b/Math/Matrix/CholeskyDecomposition.php @@ -46,7 +46,7 @@ class CholeskyDecomposition } } - for ($k = $i+1; $k < $this->m; ++$k) { + for ($k = $i + 1; $k < $this->m; ++$k) { $this->L[$i][$k] = 0.0; } } diff --git a/Math/Matrix/LUDecomposition.php b/Math/Matrix/LUDecomposition.php index 920f5c7ab..b7152ced6 100644 --- a/Math/Matrix/LUDecomposition.php +++ b/Math/Matrix/LUDecomposition.php @@ -48,7 +48,7 @@ class LUDecomposition for ($i = 0; $i < $this->m; ++$i) { $LUrowi = $this->LU[$i]; // Most of the time is spent in the following dot product. - $kmax = min($i,$j); + $kmax = min($i, $j); $s = 0.0; for ($k = 0; $k < $kmax; ++$k) { $s += $LUrowi[$k] * $LUcolj[$k]; @@ -57,7 +57,7 @@ class LUDecomposition } // Find pivot and exchange if necessary. $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])) { $p = $i; } @@ -75,7 +75,7 @@ class LUDecomposition } // Compute multipliers. if (($j < $this->m) && ($this->LU[$j][$j] != 0.0)) { - for ($i = $j+1; $i < $this->m; ++$i) { + for ($i = $j + 1; $i < $this->m; ++$i) { $this->LU[$i][$j] /= $this->LU[$j][$j]; } } @@ -159,11 +159,11 @@ class LUDecomposition } $nx = $B->getM(); - $X = $B->getMatrix($this->piv, 0, $nx-1); + $X = $B->getMatrix($this->piv, 0, $nx - 1); // Solve L*Y = B(piv,:) for ($k = 0; $k < $this->n; ++$k) { - for ($i = $k+1; $i < $this->n; ++$i) { + for ($i = $k + 1; $i < $this->n; ++$i) { for ($j = 0; $j < $nx; ++$j) { $X->A[$i][$j] -= $X->A[$k][$j] * $this->LU[$i][$k]; } @@ -171,7 +171,7 @@ class LUDecomposition } // Solve U*X = Y; - for ($k = $this->n-1; $k >= 0; --$k) { + for ($k = $this->n - 1; $k >= 0; --$k) { for ($j = 0; $j < $nx; ++$j) { $X->A[$k][$j] /= $this->LU[$k][$k]; } diff --git a/Math/Matrix/QRDecomposition.php b/Math/Matrix/QRDecomposition.php index 068199f55..ee07a89dc 100644 --- a/Math/Matrix/QRDecomposition.php +++ b/Math/Matrix/QRDecomposition.php @@ -51,13 +51,13 @@ class QRDecomposition $this->QR[$k][$k] += 1.0; // Apply transformation to remaining columns. - for ($j = $k+1; $j < $this->n; ++$j) { + for ($j = $k + 1; $j < $this->n; ++$j) { $s = 0.0; for ($i = $k; $i < $this->m; ++$i) { $s += $this->QR[$i][$k] * $this->QR[$i][$j]; } - $s = -$s/$this->QR[$k][$k]; + $s = -$s / $this->QR[$k][$k]; for ($i = $k; $i < $this->m; ++$i) { $this->QR[$i][$j] += $s * $this->QR[$i][$k]; } @@ -125,7 +125,7 @@ class QRDecomposition { $Q = [[]]; - for ($k = $this->n-1; $k >= 0; --$k) { + for ($k = $this->n - 1; $k >= 0; --$k) { for ($i = 0; $i < $this->m; ++$i) { $Q[$i][$k] = 0.0; } @@ -137,7 +137,7 @@ class QRDecomposition for ($i = $k; $i < $this->m; ++$i) { $s += $this->QR[$i][$k] * $Q[$i][$j]; } - $s = -$s/$this->QR[$k][$k]; + $s = -$s / $this->QR[$k][$k]; for ($i = $k; $i < $this->m; ++$i) { $Q[$i][$j] += $s * $this->QR[$i][$k]; } @@ -168,20 +168,20 @@ class QRDecomposition for ($i = $k; $i < $this->m; ++$i) { $s += $this->QR[$i][$k] * $X[$i][$j]; } - $s = -$s/$this->QR[$k][$k]; + $s = -$s / $this->QR[$k][$k]; for ($i = $k; $i < $this->m; ++$i) { $X[$i][$j] += $s * $this->QR[$i][$k]; } } } // Solve R*X = Y; - for ($k = $this->n-1; $k >= 0; --$k) { + for ($k = $this->n - 1; $k >= 0; --$k) { for ($j = 0; $j < $nx; ++$j) { $X[$k][$j] /= $this->Rdiag[$k]; } for ($i = 0; $i < $k; ++$i) { for ($j = 0; $j < $nx; ++$j) { - $X[$i][$j] -= $X[$k][$j]* $this->QR[$i][$k]; + $X[$i][$j] -= $X[$k][$j] * $this->QR[$i][$k]; } } } @@ -189,6 +189,6 @@ class QRDecomposition $matrix = new Matrix(); $matrix->setArray($X); - return $matrix->getMatrix(0, $this->n-1, 0, $nx); + return $matrix->getMatrix(0, $this->n - 1, 0, $nx); } } \ No newline at end of file diff --git a/Math/Stochastic/NaiveBayesFilter.php b/Math/Stochastic/NaiveBayesFilter.php index c45cd3b41..e66fd67c7 100644 --- a/Math/Stochastic/NaiveBayesFilter.php +++ b/Math/Stochastic/NaiveBayesFilter.php @@ -45,11 +45,11 @@ class NaiveBayesFilter $n = 0.0; foreach ($toMatch as $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 diff --git a/Stdlib/Base/SmartDateTime.php b/Stdlib/Base/SmartDateTime.php index 22a0a676d..28962eec0 100644 --- a/Stdlib/Base/SmartDateTime.php +++ b/Stdlib/Base/SmartDateTime.php @@ -282,7 +282,7 @@ class SmartDateTime extends \DateTime // add difference to $weekStartsWith counting backwards from days of previous month (reorder so that lowest value first) for ($i = $daysPreviousMonth - $diffToWeekStart; $i < $daysPreviousMonth; $i++) { - $days[] = new \DateTime($previousMonth->format('Y') . '-' . $previousMonth->format('m') . '-' . ($i+1)); + $days[] = new \DateTime($previousMonth->format('Y') . '-' . $previousMonth->format('m') . '-' . ($i + 1)); } // add normal count of current days diff --git a/Stdlib/Graph/BinaryTree.php b/Stdlib/Graph/BinaryTree.php index ce018945d..cc6a2baad 100644 --- a/Stdlib/Graph/BinaryTree.php +++ b/Stdlib/Graph/BinaryTree.php @@ -154,11 +154,11 @@ class BinaryTree extends Tree $right = $this->getRight($node); if (isset($left)) { - $this->getVerticalOrder($left, $horizontalDistance-1, $order); + $this->getVerticalOrder($left, $horizontalDistance - 1, $order); } if (isset($right)) { - $this->getVerticalOrder($right, $horizontalDistance+1, $order); + $this->getVerticalOrder($right, $horizontalDistance + 1, $order); } } diff --git a/Utils/Encoding/Caesar.php b/Utils/Encoding/Caesar.php index 423d75994..477bbd770 100644 --- a/Utils/Encoding/Caesar.php +++ b/Utils/Encoding/Caesar.php @@ -85,7 +85,7 @@ class Caesar $ascii = ord($raw[$i]) - ord($key[$j]); if ($ascii < self::LIMIT_LOWER) { - $ascii = self::LIMIT_UPPER + ($ascii - self::LIMIT_LOWER) ; + $ascii = self::LIMIT_UPPER + ($ascii - self::LIMIT_LOWER); } $result .= chr($ascii); diff --git a/Views/ViewAbstract.php b/Views/ViewAbstract.php index c235f92cf..29e5971c0 100644 --- a/Views/ViewAbstract.php +++ b/Views/ViewAbstract.php @@ -232,7 +232,7 @@ abstract class ViewAbstract implements \Serializable ob_start(); /** @noinspection PhpIncludeInspection */ $includeData = include $path; - $ob = ob_get_clean(); + $ob = ob_get_clean(); if (is_array($includeData)) { return json_encode($includeData);