From 114ce12de89f69a4465ae062907a3ea9c7ffbf74 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Mon, 28 Mar 2016 14:44:47 +0000 Subject: [PATCH] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- Account/Account.php | 6 +- Config/SettingsAbstract.php | 2 +- DataStorage/Cookie/CookieJar.php | 2 +- DataStorage/Database/DataMapperAbstract.php | 4 +- DataStorage/Database/GrammarAbstract.php | 4 +- DataStorage/Session/HttpSession.php | 6 +- Datatypes/SmartDateTime.php | 2 +- Localization/L11nManager.php | 2 +- Localization/Localization.php | 8 +-- Log/FileLogger.php | 4 +- Math/Algebra/PointPolygonIntersection.php | 2 +- Math/Function/Fibunacci.php | 6 +- Math/Function/Functions.php | 18 +++--- Math/Matrix/Matrix.php | 72 ++++++++++----------- Math/Number/Numbers.php | 12 +++- Math/Number/Prime.php | 10 +-- Math/Optimization/GaussianElimination.php | 4 +- Math/Optimization/Graph/Graph.php | 8 +-- Math/Statistic/Average.php | 4 +- Message/Http/Response.php | 10 +-- Message/Mail/Imap.php | 2 +- Message/RequestAbstract.php | 2 +- Module/ModuleFactory.php | 2 +- Module/ModuleManager.php | 2 +- System/File/Directory.php | 8 +-- System/File/File.php | 4 +- System/OperatingSystem.php | 2 +- Uri/Http.php | 2 +- Utils/Barcode/C128Abstract.php | 16 ++--- Utils/Barcode/C25.php | 4 +- Utils/Encoding/Gray.php | 2 +- Utils/Git/Commit.php | 6 +- Utils/Git/Git.php | 2 +- Utils/Git/Repository.php | 4 +- Utils/OrderType.php | 2 +- Utils/Parser/Markdown/Markdown.php | 8 ++- Utils/Permutation.php | 2 +- Utils/RnG/Text.php | 2 +- Utils/SystemUtils.php | 2 +- Utils/TaskSchedule/Interval.php | 44 +++++++++---- Validation/Base/CreditCard.php | 2 +- 41 files changed, 171 insertions(+), 135 deletions(-) diff --git a/Account/Account.php b/Account/Account.php index 3ffa94b17..ed5518e44 100644 --- a/Account/Account.php +++ b/Account/Account.php @@ -364,7 +364,7 @@ class Account */ public function setEmail(string $email) { - if(!Email::isValid($email)) { + if (!Email::isValid($email)) { throw new \InvalidArgumentException(); } @@ -383,7 +383,7 @@ class Account */ public function setStatus(int $status) { - if(!AccountStatus::isValidValue($status)) { + if (!AccountStatus::isValidValue($status)) { throw new \InvalidArgumentException(); } @@ -402,7 +402,7 @@ class Account */ public function setType(int $type) { - if(!AccountType::isValidValue($type)) { + if (!AccountType::isValidValue($type)) { throw new \InvalidArgumentException(); } diff --git a/Config/SettingsAbstract.php b/Config/SettingsAbstract.php index e1219ed35..7cf6a8eb1 100644 --- a/Config/SettingsAbstract.php +++ b/Config/SettingsAbstract.php @@ -126,7 +126,7 @@ abstract class SettingsAbstract implements OptionsInterface { $this->setOptions($options); - if($store) { + if ($store) { // save to db } } diff --git a/DataStorage/Cookie/CookieJar.php b/DataStorage/Cookie/CookieJar.php index a73a7881f..ab25a125b 100644 --- a/DataStorage/Cookie/CookieJar.php +++ b/DataStorage/Cookie/CookieJar.php @@ -72,7 +72,7 @@ class CookieJar public function save() { - if(self::$isLocked) { + if (self::$isLocked) { throw new \Exception('Already locked'); } diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index 73dc87ce1..d029347c7 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -1000,11 +1000,11 @@ abstract class DataMapperAbstract implements DataMapperInterface $query = new Builder($this->db); $query->prefix($this->db->getPrefix()); - if($relations === RelationType::ALL) { + if ($relations === RelationType::ALL) { $query->select($value['table'] . '.' . $value['src']) ->from($value['table']) ->where($value['table'] . '.' . $value['dst'], '=', $primaryKey); - } elseif($relations === RelationType::NEWEST) { + } elseif ($relations === RelationType::NEWEST) { /* SELECT c.*, p1.* diff --git a/DataStorage/Database/GrammarAbstract.php b/DataStorage/Database/GrammarAbstract.php index 6d75c736c..f9177248d 100644 --- a/DataStorage/Database/GrammarAbstract.php +++ b/DataStorage/Database/GrammarAbstract.php @@ -78,7 +78,7 @@ abstract class GrammarAbstract implode(' ', array_filter( $this->compileComponents($query), - function ($value) { + function($value) { return (string) $value !== ''; } ) @@ -135,7 +135,7 @@ abstract class GrammarAbstract { // todo: move remaining * test also here not just if .* but also if * (should be done in else?) if (count($split = explode('.', $system)) == 2) { - if($split[1] === '*') { + if ($split[1] === '*') { $system = $split[1]; } else { $system = $this->compileSystem($split[1]); diff --git a/DataStorage/Session/HttpSession.php b/DataStorage/Session/HttpSession.php index bfe43dc20..364bf4874 100644 --- a/DataStorage/Session/HttpSession.php +++ b/DataStorage/Session/HttpSession.php @@ -60,7 +60,7 @@ class HttpSession implements SessionInterface */ public function __construct(int $liftetime = 3600, $sid = false) { - if(self::$isLocked) { + if (self::$isLocked) { throw new \Exception('Already locked'); } @@ -89,7 +89,7 @@ class HttpSession implements SessionInterface { $this->set('UID', 0, false); - if(($CSRF = $this->get('CSRF')) === null) { + if (($CSRF = $this->get('CSRF')) === null) { $CSRF = StringUtils::generateString(10, 16); $this->set('CSRF', $CSRF, false); } @@ -110,7 +110,7 @@ class HttpSession implements SessionInterface */ public function set($key, $value, bool $overwrite = true) : bool { - if($overwrite || !isset($this->sessionData[$key])) { + if ($overwrite || !isset($this->sessionData[$key])) { $this->sessionData[$key] = $value; return true; diff --git a/Datatypes/SmartDateTime.php b/Datatypes/SmartDateTime.php index f242f0fb5..df337487e 100644 --- a/Datatypes/SmartDateTime.php +++ b/Datatypes/SmartDateTime.php @@ -36,7 +36,7 @@ class SmartDateTime extends \DateTime * @var string * @since 1.0.0 */ - const FORMAT = 'Y-m-d hh:mm:ss'; + const FORMAT = 'Y-m-d hh:mm:ss'; /** * Default timezone diff --git a/Localization/L11nManager.php b/Localization/L11nManager.php index a1c96ee60..e08eadeb8 100644 --- a/Localization/L11nManager.php +++ b/Localization/L11nManager.php @@ -71,7 +71,7 @@ class L11nManager */ public function loadLanguage(string $language, string $from, array $files) { - if(!isset($files[$from])) { + if (!isset($files[$from])) { throw new \Exception('Unexpected language key: ' . $from); } diff --git a/Localization/Localization.php b/Localization/Localization.php index 65b0a7cd3..89002c0e8 100644 --- a/Localization/Localization.php +++ b/Localization/Localization.php @@ -125,7 +125,7 @@ class Localization */ public function setCountry(string $country) { - if(!ISO3166Enum::isValidValue($country)) { + if (!ISO3166Enum::isValidValue($country)) { throw new InvalidEnumValue($country); } @@ -153,7 +153,7 @@ class Localization */ public function setTimezone(string $timezone) { - if(!TimeZoneEnumArray::isValidValue($timezone)) { + if (!TimeZoneEnumArray::isValidValue($timezone)) { throw new InvalidEnumValue($timezone); } @@ -181,7 +181,7 @@ class Localization */ public function setLanguage(string $language) { - if(!ISO639x1Enum::isValidValue($language)) { + if (!ISO639x1Enum::isValidValue($language)) { throw new InvalidEnumValue($language); } @@ -233,7 +233,7 @@ class Localization */ public function setCurrency(string $currency) { - if(!ISO4217Enum::isValidValue($currency)) { + if (!ISO4217Enum::isValidValue($currency)) { throw new InvalidEnumValue($currency); } diff --git a/Log/FileLogger.php b/Log/FileLogger.php index 389667eff..2284e2d68 100644 --- a/Log/FileLogger.php +++ b/Log/FileLogger.php @@ -290,13 +290,13 @@ class FileLogger implements LoggerInterface { $this->fp = fopen($this->path, 'a'); - if($this->fp !== false) { + if ($this->fp !== false) { fwrite($this->fp, $message . "\n"); fclose($this->fp); $this->fp = false; } - if(self::$verbose) { + if (self::$verbose) { echo $message . "\n"; } } diff --git a/Math/Algebra/PointPolygonIntersection.php b/Math/Algebra/PointPolygonIntersection.php index 8ccd2b589..3725b3e4a 100644 --- a/Math/Algebra/PointPolygonIntersection.php +++ b/Math/Algebra/PointPolygonIntersection.php @@ -38,7 +38,7 @@ class PointPolygonIntersection } // Inside or ontop? - $countIntersect = 0; + $countIntersect = 0; $vertices_count = count($vertices); // todo: return based on highest possibility not by first match diff --git a/Math/Function/Fibunacci.php b/Math/Function/Fibunacci.php index 7dad9d8bb..bb1435eeb 100644 --- a/Math/Function/Fibunacci.php +++ b/Math/Function/Fibunacci.php @@ -31,12 +31,12 @@ class Fibunacci { public static function isFibunacci(int $n) { - return Functions::isSquare(5*$n**2+4) || Functions::isSquare(5*$n**2-4); + return Functions::isSquare(5 * $n**2 + 4) || Functions::isSquare(5 * $n**2 - 4); } public static function fibunacci(int $n, int $start = 1) : int { - if($n < 2) { + if ($n < 2) { return 0; } elseif ($n < 4) { return $start; @@ -57,6 +57,6 @@ class Fibunacci 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))); } } \ No newline at end of file diff --git a/Math/Function/Functions.php b/Math/Function/Functions.php index 70fa13713..d61386be4 100644 --- a/Math/Function/Functions.php +++ b/Math/Function/Functions.php @@ -129,13 +129,13 @@ class Functions */ public static function ackermann(int $m, int $n) : int { - if($m === 0) { - return $n+1; - } elseif($n === 0) { - return self::ackermann($m-1, 1); + if ($m === 0) { + return $n + 1; + } elseif ($n === 0) { + return self::ackermann($m - 1, 1); } - return ackermann($m-1, ackermann($m, $n-1)); + return ackermann($m - 1, ackermann($m, $n - 1)); } /** @@ -149,7 +149,7 @@ class Functions * @since 1.0.0 * @author Dennis Eichhorn */ - public static function invMod($a, $n){ + public static function invMod($a, $n) { if ($n < 0) { $n = -$n; } @@ -164,12 +164,12 @@ class Functions $nr = $a % $n; while ($nr != 0) { - $quot = (int) ($r/$nr); + $quot = (int) ($r / $nr); $tmp = $nt; - $nt = $t - $quot*$nt; + $nt = $t - $quot * $nt; $t = $tmp; $tmp = $nr; - $nr = $r - $quot*$nr; + $nr = $r - $quot * $nr; $r = $tmp; } diff --git a/Math/Matrix/Matrix.php b/Math/Matrix/Matrix.php index 4e5a3081f..c15d6656f 100644 --- a/Math/Matrix/Matrix.php +++ b/Math/Matrix/Matrix.php @@ -14,14 +14,14 @@ class Matrix implements ArrayAccess, Iterator $this->n = $n; $this->m = $m; - for($i = 0; $i < $m; $i++) { + for ($i = 0; $i < $m; $i++) { $this->matrix[$i] = array_fill(0, $n, 0); } } public function setMatrix(array $matrix) { - if($this->m !== count($matrix) || $this->n !== count($matrix[0])) { + if ($this->m !== count($matrix) || $this->n !== count($matrix[0])) { throw new \Exception('Dimension'); } @@ -53,9 +53,9 @@ class Matrix implements ArrayAccess, Iterator public function mult($value) : Matrix { - if($value instanceOf Matrix) { + if ($value instanceOf Matrix) { return $this->multMatrix($value); - } elseif(is_scalar($value)) { + } elseif (is_scalar($value)) { return $this->multScalar($value); } } @@ -65,7 +65,7 @@ class Matrix implements ArrayAccess, Iterator $nDim = $matrix->getN(); $mDim = $matrix->getM(); - if($this->n !== $mDim) { + if ($this->n !== $mDim) { throw new \Exception('Dimension'); } @@ -73,11 +73,11 @@ class Matrix implements ArrayAccess, Iterator $newMatrix = new Matrix($this->m, $nDim); $newMatrixArr = $newMatrix->getMatrix(); - for($i = 0; $i < $this->m; $i++) { // Row of $this - for($c = 0; $c < $nDim; $c++) { // Column of $matrix + for ($i = 0; $i < $this->m; $i++) { // Row of $this + for ($c = 0; $c < $nDim; $c++) { // Column of $matrix $temp = 0; - for($j = 0; $j < $mDim; $i++) { // Row of $matrix + for ($j = 0; $j < $mDim; $i++) { // Row of $matrix $temp += $this->matrix[$i][$j] * $matrixArr[$j][$c]; } @@ -94,8 +94,8 @@ class Matrix implements ArrayAccess, Iterator { $newMatrixArr = $this->matrix; - foreach($newMatrixArr as $i => $vector) { - foreach($vector as $j => $value) { + foreach ($newMatrixArr as $i => $vector) { + foreach ($vector as $j => $value) { $newMatrixArr[$i][$j] *= $value; } } @@ -108,33 +108,33 @@ class Matrix implements ArrayAccess, Iterator public function add($value) : Matrix { - if($value instanceOf Matrix) { + if ($value instanceOf Matrix) { return $this->addMatrix($value); - } elseif(is_scalar($value)) { + } elseif (is_scalar($value)) { return $this->addScalar($value); } } public function sub($value) : Matrix { - if($value instanceOf Matrix) { + if ($value instanceOf Matrix) { return $this->add($this->multMatrix(-1)); - } elseif(is_scalar($value)) { + } elseif (is_scalar($value)) { return $this->addScalar(-$value); } } private function addMatrix(Matrix $value) : Matrix { - if($this->m !== $value->getM() || $this->n !== $value->getN()) { + if ($this->m !== $value->getM() || $this->n !== $value->getN()) { throw new \Exception('Dimension'); } $matrixArr = $value->getMatrix(); $newMatrixArr = $this->matrix; - foreach($newMatrixArr as $i => $vector) { - foreach($vector as $j => $value) { + foreach ($newMatrixArr as $i => $vector) { + foreach ($vector as $j => $value) { $newMatrixArr[$i][$j] += $matrixArr[$i][$j]; } } @@ -149,8 +149,8 @@ class Matrix implements ArrayAccess, Iterator { $newMatrixArr = $this->matrix; - foreach($newMatrixArr as $i => $vector) { - foreach($vector as $j => $value) { + foreach ($newMatrixArr as $i => $vector) { + foreach ($vector as $j => $value) { $newMatrixArr[$i][$j] += $value; } } @@ -184,11 +184,11 @@ class Matrix implements ArrayAccess, Iterator public function inverse(int $algorithm = InversionType::GAUSS_JORDAN) : Matrix { - if($this->n !== $this->m) { + if ($this->n !== $this->m) { throw new \Exception('Dimension'); } - switch($algorithm) { + switch ($algorithm) { case InversionType::GAUSS_JORDAN: return $this->inverseGaussJordan(); default: @@ -201,10 +201,10 @@ class Matrix implements ArrayAccess, Iterator $newMatrixArr = $this->matrix; // extending matrix by identity matrix - for($i = 0; $i < $this->n; $i++) { - for($j = $this->n; $j < $this->n * 2; $j++) { + for ($i = 0; $i < $this->n; $i++) { + for ($j = $this->n; $j < $this->n * 2; $j++) { - if($j === ($i + $this->n)) { + if ($j === ($i + $this->n)) { $newMatrixArr[$i][$j] = 1; } else { $newMatrixArr[$i][$j] = 0; @@ -219,16 +219,16 @@ class Matrix implements ArrayAccess, Iterator $newMatrixArr = $this->diag($newMatrixArr); /* create unit matrix */ - for($i = 0; $i < $mDim; $i++) { + for ($i = 0; $i < $mDim; $i++) { $temp = $newMatrixArr[$i][$i]; - for($j = 0; $j < $nDim; $j++) { + for ($j = 0; $j < $nDim; $j++) { $newMatrixArr[$i][$j] = $newMatrixArr[$i][$j] / $temp; } } /* removing identity matrix */ - for($i = 0; $i < $mDim; $i++) { + for ($i = 0; $i < $mDim; $i++) { $newMatrixArr[$i] = array_slice($newMatrixArr[$i], $mDim); } @@ -244,7 +244,7 @@ class Matrix implements ArrayAccess, Iterator $newMatrixArr = $newMatrix->getMatrix(); for ($i = 0; $i < $this->n; $i++) { - for ($j = 0; $j < $i+1; $j++) { + for ($j = 0; $j < $i + 1; $j++) { $temp = 0; for ($c = 0; $c < $j; $c++) { @@ -265,23 +265,23 @@ class Matrix implements ArrayAccess, Iterator $mDim = count($arr); $nDim = count($arr[0]); - for($i = $mDim - 1; $i > 0; $i--) { + for ($i = $mDim - 1; $i > 0; $i--) { if ($arr[$i - 1][0] < $arr[$i][0]) { - for($j = 0; $j < $nDim; $j++) { + for ($j = 0; $j < $nDim; $j++) { $temp = $arr[$i][$j]; - $arr[$i][$j] = $arr[$i-1][$j]; - $arr[$i-1][$j] = $temp; + $arr[$i][$j] = $arr[$i - 1][$j]; + $arr[$i - 1][$j] = $temp; } } } /* create diagonal matrix */ - for($i = 0; $i < $mDim; $i++) { - for($j = 0; $j < $mDim; $j++) { + for ($i = 0; $i < $mDim; $i++) { + for ($j = 0; $j < $mDim; $j++) { if ($j !== $i) { $temp = $arr[$j][$i] / $arr[$i][$i]; - for($c = 0; $c < $nDim; $c++) { + for ($c = 0; $c < $nDim; $c++) { $arr[$j][$c] -= $arr[$i][$c] * $temp; } } @@ -323,7 +323,7 @@ class Matrix implements ArrayAccess, Iterator continue; } - for ($c = $i; $c < $n; $c ++) { + for ($c = $i; $c < $n; $c++) { $arr[$j][$c] -= $arr[$i][$c] * $r; } } diff --git a/Math/Number/Numbers.php b/Math/Number/Numbers.php index 4ab9bf792..ae834d008 100644 --- a/Math/Number/Numbers.php +++ b/Math/Number/Numbers.php @@ -94,17 +94,23 @@ class Numbers // This tests if the 6 least significant bits are right. // Moving the to be tested bit to the highest position saves us masking. - if ($goodMask << $n >= 0) return false; + if ($goodMask << $n >= 0) { + return false; + } $numberOfTrailingZeros = self::countTrailingZeros($n); // Each square ends with an even number of zeros. - if (($numberOfTrailingZeros & 1) !== 0) return false; + if (($numberOfTrailingZeros & 1) !== 0) { + return false; + } $n >>= $numberOfTrailingZeros; // Now x is either 0 or odd. // In binary each odd square ends with 001. // Postpone the sign test until now; handle zero in the branch. - if (($n&7) != 1 | $n <= 0) return $n === 0; + if (($n&7) != 1 | $n <= 0) { + return $n === 0; + } // Do it in the classical way. // The correctness is not trivial as the conversion from long to double is lossy! $tst = (int) sqrt($n); diff --git a/Math/Number/Prime.php b/Math/Number/Prime.php index 30c484dc8..7a8161289 100644 --- a/Math/Number/Prime.php +++ b/Math/Number/Prime.php @@ -41,7 +41,7 @@ class Prime */ public static function isMersenne(int $n) : bool { - $mersenne = log($n+1, 2); + $mersenne = log($n + 1, 2); return $mersenne - (int) $mersenne < 0.00001; } @@ -78,7 +78,7 @@ class Prime return true; } - if ($n < 2 || $n % 2 == 0){ + if ($n < 2 || $n % 2 == 0) { return false; } @@ -91,11 +91,11 @@ class Prime } for ($i = 0; $i < $k; $i++) { - $a = mt_rand(2, $n-1); + $a = mt_rand(2, $n - 1); $x = bcpowmod($a, $d, $n); - if ($x == 1 || $x == $n-1) { + if ($x == 1 || $x == $n - 1) { continue; } @@ -106,7 +106,7 @@ class Prime return false; } - if ($x == $n-1) { + if ($x == $n - 1) { continue 2; } } diff --git a/Math/Optimization/GaussianElimination.php b/Math/Optimization/GaussianElimination.php index 87cfe1236..b12e1e45f 100644 --- a/Math/Optimization/GaussianElimination.php +++ b/Math/Optimization/GaussianElimination.php @@ -4,7 +4,9 @@ class GaussianElimination { private function swapRows(&$a, &$b, $r1, $r2) { - if ($r1 == $r2) return; + if ($r1 == $r2) { + return; + } $tmp = $a[$r1]; $a[$r1] = $a[$r2]; diff --git a/Math/Optimization/Graph/Graph.php b/Math/Optimization/Graph/Graph.php index cb1db1aaa..d088b188a 100644 --- a/Math/Optimization/Graph/Graph.php +++ b/Math/Optimization/Graph/Graph.php @@ -67,7 +67,7 @@ class Graph */ public function addVertice(VerticeInterface $vertice) : bool { - if(!isset($this->vertices[$vertice->getId()])) { + if (!isset($this->vertices[$vertice->getId()])) { $this->vertices[$vertice->getId()] = $vertice; return true; @@ -88,7 +88,7 @@ class Graph */ public function addEdge(EdgeInterface $edge) : bool { - if(!isset($this->edges[$edge->getId()])) { + if (!isset($this->edges[$edge->getId()])) { $this->edges[$edge->getId()] = $edge; return true; @@ -109,7 +109,7 @@ class Graph */ public function removeVertice($id) : bool { - if(isset($this->vertices[$id])) { + if (isset($this->vertices[$id])) { unset($this->vertices[$id]); return true; @@ -146,7 +146,7 @@ class Graph */ public function removeEdgeById($id) : bool { - if(isset($this->edge[$id])) { + if (isset($this->edge[$id])) { unset($this->edge[$id]); return true; diff --git a/Math/Statistic/Average.php b/Math/Statistic/Average.php index 80c905796..8def8c17c 100644 --- a/Math/Statistic/Average.php +++ b/Math/Statistic/Average.php @@ -329,7 +329,9 @@ class Average $avgcos = $coss / (0.0 + count($angles)); $avgang = rad2deg(atan2($avgsin, $avgcos)); - while ($avgang < 0.0) $avgang += 360.0; + while ($avgang < 0.0) { + $avgang += 360.0; + } return $avgang; } diff --git a/Message/Http/Response.php b/Message/Http/Response.php index 4809a13a8..c44a01cba 100644 --- a/Message/Http/Response.php +++ b/Message/Http/Response.php @@ -79,7 +79,7 @@ class Response extends ResponseAbstract implements RenderableInterface */ public function pushHeaderId($name) { - if(self::$isLocked) { + if (self::$isLocked) { throw new \Exception('Already locked'); } @@ -102,7 +102,7 @@ class Response extends ResponseAbstract implements RenderableInterface */ public function removeHeader(int $key) : bool { - if(self::$isLocked) { + if (self::$isLocked) { throw new \Exception('Already locked'); } @@ -212,7 +212,7 @@ class Response extends ResponseAbstract implements RenderableInterface */ public function pushHeader() { - if(self::$isLocked) { + if (self::$isLocked) { throw new \Exception('Already locked'); } @@ -237,7 +237,7 @@ class Response extends ResponseAbstract implements RenderableInterface */ public function remove(int $id) : bool { - if(self::$isLocked) { + if (self::$isLocked) { throw new \Exception('Already locked'); } @@ -374,7 +374,7 @@ class Response extends ResponseAbstract implements RenderableInterface */ public function setHeader($key, string $header, bool $overwrite = false) : bool { - if(self::$isLocked) { + if (self::$isLocked) { throw new \Exception('Already locked'); } diff --git a/Message/Mail/Imap.php b/Message/Mail/Imap.php index fac8dcc50..cfbace181 100644 --- a/Message/Mail/Imap.php +++ b/Message/Mail/Imap.php @@ -50,7 +50,7 @@ class Imap extends Mail public function getInbox(string $option = 'ALL') : array { - $ids = imap_search($this->inbox, $option, SE_FREE, 'UTF-8'); + $ids = imap_search($this->inbox, $option, SE_FREE, 'UTF-8'); return is_array($ids) ? imap_fetch_overview($this->inbox, implode(',', $ids)) : []; } diff --git a/Message/RequestAbstract.php b/Message/RequestAbstract.php index 2926cec67..6fec593cd 100644 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -184,7 +184,7 @@ abstract class RequestAbstract implements MessageInterface */ public function setRequestSource($source) { - if(!RequestSource::isValidValue($source)) { + if (!RequestSource::isValidValue($source)) { throw new InvalidEnumValue($source); } diff --git a/Module/ModuleFactory.php b/Module/ModuleFactory.php index 41b0a8153..8dbe241d4 100644 --- a/Module/ModuleFactory.php +++ b/Module/ModuleFactory.php @@ -81,7 +81,7 @@ class ModuleFactory self::$loaded[$module] = $obj; self::registerRequesting($obj); self::registerProvided($obj); - } catch(\Exception $e) { + } catch (\Exception $e) { self::$loaded[$module] = new NullModule($app); } } diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index 61710643d..efdaf7dc5 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -298,7 +298,7 @@ class ModuleManager $path = realpath($oldPath = self::MODULE_PATH . '/' . $module . '/' . 'info.json'); - if($path === false || strpos($path, self::MODULE_PATH) === false) { + if ($path === false || strpos($path, self::MODULE_PATH) === false) { throw new PathException($module); } diff --git a/System/File/Directory.php b/System/File/Directory.php index b6c87f9af..3bc541949 100644 --- a/System/File/Directory.php +++ b/System/File/Directory.php @@ -179,7 +179,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess $this->filter = $filter; parent::__construct($path); - if(file_exists($this->path)) { + if (file_exists($this->path)) { parent::index(); } } @@ -242,7 +242,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess */ public function remove(string $name) : bool { - if(isset($this->nodes[$name])) { + if (isset($this->nodes[$name])) { $this->count -= $this->nodes[$name]->getCount(); $this->size -= $this->nodes[$name]->getSize(); @@ -269,7 +269,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess foreach (glob($this->path . DIRECTORY_SEPARATOR . $this->filter) as $filename) { // todo: handle . and ..???!!! - if(is_dir($filename)) { + if (is_dir($filename)) { $file = new Directory($filename); $file->index(); } else { @@ -349,7 +349,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess */ public function offsetUnset($offset) { - if(isset($this->nodes[$offset])) { + if (isset($this->nodes[$offset])) { unset($this->nodes[$offset]); } } diff --git a/System/File/File.php b/System/File/File.php index 540544add..611548f07 100644 --- a/System/File/File.php +++ b/System/File/File.php @@ -44,7 +44,7 @@ class File extends FileAbstract public static function createFile(string $path) : bool { if (!file_exists($path)) { - if(is_writable(Directory::getParent($path))) { + if (is_writable(Directory::getParent($path))) { touch($path); return true; @@ -69,7 +69,7 @@ class File extends FileAbstract parent::__construct($path); $this->count = 1; - if(file_exists($this->path)) { + if (file_exists($this->path)) { $this->index(); } } diff --git a/System/OperatingSystem.php b/System/OperatingSystem.php index c5c921630..4b8243278 100644 --- a/System/OperatingSystem.php +++ b/System/OperatingSystem.php @@ -37,7 +37,7 @@ final class OperatingSystem { */ public static function getSystem() : int { - switch(PHP_OS) { + switch (PHP_OS) { case stristr(PHP_OS, 'DAR'): return SystemType::OSX; case stristr(PHP_OS, 'WIN'): diff --git a/Uri/Http.php b/Uri/Http.php index 57bcbd7ba..87d5d19ca 100644 --- a/Uri/Http.php +++ b/Uri/Http.php @@ -307,7 +307,7 @@ class Http implements UriInterface $this->pass = $url['pass'] ?? null; $this->path = $url['path'] ?? null; $this->path = rtrim($this->path, '.php'); - $this->path = strpos($this->path, $this->rootPath) === 0 ? substr($this->path, strlen($this->rootPath), strlen($this->path)) : $this->path; // TODO: this could cause a bug if the rootpath is the same as a regular path which is usually the language + $this->path = strpos($this->path, $this->rootPath) === 0 ? substr($this->path, strlen($this->rootPath), strlen($this->path)) : $this->path; // TODO: this could cause a bug if the rootpath is the same as a regular path which is usually the language $this->query = $url['query'] ?? null; if (isset($this->query)) { diff --git a/Utils/Barcode/C128Abstract.php b/Utils/Barcode/C128Abstract.php index 12d044e8d..a52e54d84 100644 --- a/Utils/Barcode/C128Abstract.php +++ b/Utils/Barcode/C128Abstract.php @@ -60,7 +60,7 @@ abstract class C128Abstract * @var string * @since 1.0.0 */ - protected static $CODE_END = ''; + protected static $CODE_END = ''; /** * Orientation. @@ -76,7 +76,7 @@ abstract class C128Abstract * @var int * @since 1.0.0 */ - protected $size = 0; + protected $size = 0; /** * Barcode dimension. @@ -86,7 +86,7 @@ abstract class C128Abstract * @var int[] * @since 1.0.0 */ - protected $dimension = ['width' => 0, 'height' => 0]; + protected $dimension = ['width' => 0, 'height' => 0]; /** * Content to encrypt. @@ -94,7 +94,7 @@ abstract class C128Abstract * @var string|int * @since 1.0.0 */ - protected $content = 0; + protected $content = 0; /** * Show text below barcode. @@ -102,7 +102,7 @@ abstract class C128Abstract * @var string * @since 1.0.0 */ - protected $showText = true; + protected $showText = true; /** * Margin for barcode (padding). @@ -110,7 +110,7 @@ abstract class C128Abstract * @var int[] * @since 1.0.0 */ - protected $margin = ['top' => 0, 'right' => 4, 'bottom' => 0, 'left' => 4]; + protected $margin = ['top' => 0, 'right' => 4, 'bottom' => 0, 'left' => 4]; /** * Background color. @@ -118,7 +118,7 @@ abstract class C128Abstract * @var int[] * @since 1.0.0 */ - protected $background = ['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]; + protected $background = ['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]; /** * Front color. @@ -126,7 +126,7 @@ abstract class C128Abstract * @var int[] * @since 1.0.0 */ - protected $front = ['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]; + protected $front = ['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]; /** * Constructor diff --git a/Utils/Barcode/C25.php b/Utils/Barcode/C25.php index ad7075610..7646ac600 100644 --- a/Utils/Barcode/C25.php +++ b/Utils/Barcode/C25.php @@ -78,7 +78,7 @@ class C25 extends C128Abstract */ public function __construct(string $content = '', int $size = 20, int $orientation = OrientationType::HORIZONTAL) { - if(!ctype_digit($content)) { + if (!ctype_digit($content)) { throw new \InvalidArgumentException($content); } @@ -95,7 +95,7 @@ class C25 extends C128Abstract */ public function setContent(string $content) { - if(!ctype_digit($content)) { + if (!ctype_digit($content)) { throw new \InvalidArgumentException($content); } diff --git a/Utils/Encoding/Gray.php b/Utils/Encoding/Gray.php index ea6ca3475..96a90a478 100644 --- a/Utils/Encoding/Gray.php +++ b/Utils/Encoding/Gray.php @@ -42,7 +42,7 @@ final class Gray { { $source = $gray; - while($gray >>= 1) { + while ($gray >>= 1) { $source ^= $gray; } diff --git a/Utils/Git/Commit.php b/Utils/Git/Commit.php index d0fcc4e53..8bc515c2d 100644 --- a/Utils/Git/Commit.php +++ b/Utils/Git/Commit.php @@ -105,7 +105,7 @@ class Commit $branch = new Branch(); $tag = new Tag(); - if(!empty($id)) { + if (!empty($id)) { // todo: fill base info } } @@ -119,7 +119,7 @@ class Commit * @author Dennis Eichhorn */ public function addFile(string $path) { - if(!isset($this->files[$path])) { + if (!isset($this->files[$path])) { $this->files[$path] = []; } } @@ -203,7 +203,7 @@ class Commit */ public function removeFile(string $path) : bool { - if(isset($this->files[$path])) { + if (isset($this->files[$path])) { unset($this->files[$path]); return true; diff --git a/Utils/Git/Git.php b/Utils/Git/Git.php index 7ae887ba8..610d543da 100644 --- a/Utils/Git/Git.php +++ b/Utils/Git/Git.php @@ -81,7 +81,7 @@ class Git { $stdout = stream_get_contents($pipes[1]); $stderr = stream_get_contents($pipes[2]); - foreach($pipes as $pipe) { + foreach ($pipes as $pipe) { fclose($pipe); } diff --git a/Utils/Git/Repository.php b/Utils/Git/Repository.php index 8811b063d..ad715bf1b 100644 --- a/Utils/Git/Repository.php +++ b/Utils/Git/Repository.php @@ -34,7 +34,7 @@ class Repository * @var string * @since 1.0.0 */ - private $path = ''; + private $path = ''; /** * Bare repository. @@ -42,7 +42,7 @@ class Repository * @var bool * @since 1.0.0 */ - private $bare = false; + private $bare = false; /** * Env variables. diff --git a/Utils/OrderType.php b/Utils/OrderType.php index 2759cfe85..455bf9127 100644 --- a/Utils/OrderType.php +++ b/Utils/OrderType.php @@ -31,5 +31,5 @@ use phpOMS\Datatypes\Enum; abstract class OrderType extends Enum { const LOOSE = 0; - const STRICT= 1; + const STRICT = 1; } diff --git a/Utils/Parser/Markdown/Markdown.php b/Utils/Parser/Markdown/Markdown.php index 201905ea9..a8fcce2e4 100644 --- a/Utils/Parser/Markdown/Markdown.php +++ b/Utils/Parser/Markdown/Markdown.php @@ -584,14 +584,18 @@ class Markdown if (isset($block['closed'])) { return null; } - if (preg_match('/^<' . $block['name'] . '(?:[ ]*' . $this->regexHtmlAttribute . ')*[ ]*>/i', $line['text'])) # open + if (preg_match('/^<' . $block['name'] . '(?:[ ]*' . $this->regexHtmlAttribute . ')*[ ]*>/i', $line['text'])) { + # open { $block['depth']++; } - if (preg_match('/(.*?)<\/' . $block['name'] . '>[ ]*$/i', $line['text'], $matches)) # close + } + if (preg_match('/(.*?)<\/' . $block['name'] . '>[ ]*$/i', $line['text'], $matches)) { + # close { if ($block['depth'] > 0) { $block['depth']--; + } } else { $block['closed'] = true; } diff --git a/Utils/Permutation.php b/Utils/Permutation.php index 27b1e0640..56f2e7da6 100644 --- a/Utils/Permutation.php +++ b/Utils/Permutation.php @@ -13,7 +13,7 @@ class Permutation if(empty($toPermute)){ $permutations[] = implode('', $result); - }else{ + } else{ foreach($toPermute as $key => $val){ $newArr = $toPermute; $newres = $result; diff --git a/Utils/RnG/Text.php b/Utils/RnG/Text.php index c854d8b97..9a2feaf0b 100644 --- a/Utils/RnG/Text.php +++ b/Utils/RnG/Text.php @@ -294,7 +294,7 @@ class Text */ public function generateText($length, $words = null) { - if($length === 0) { + if ($length === 0) { return ''; } diff --git a/Utils/SystemUtils.php b/Utils/SystemUtils.php index 96812225d..b563aa8ae 100644 --- a/Utils/SystemUtils.php +++ b/Utils/SystemUtils.php @@ -56,7 +56,7 @@ class SystemUtils $countSize = 0; $count = 0; - if(is_readable($dir)) { + if (is_readable($dir)) { $dir_array = scandir($dir); foreach ($dir_array as $key => $filename) { diff --git a/Utils/TaskSchedule/Interval.php b/Utils/TaskSchedule/Interval.php index 08f21699b..af7ab29b9 100644 --- a/Utils/TaskSchedule/Interval.php +++ b/Utils/TaskSchedule/Interval.php @@ -491,10 +491,14 @@ class Interval private function validateMinute(array $array) : bool { foreach ($array['minutes'] as $minute) { - if ($minute > 59 || $minute < 0) return false; + if ($minute > 59 || $minute < 0) { + return false; + } } - if ($array['step'] > 59 || $array['step'] < 0) return false; + if ($array['step'] > 59 || $array['step'] < 0) { + return false; + } return true; } @@ -512,10 +516,14 @@ class Interval private function validateHour(array $array) : bool { foreach ($array['hours'] as $hour) { - if ($hour > 23 || $hour < 0) return false; + if ($hour > 23 || $hour < 0) { + return false; + } } - if ($array['step'] > 23 || $array['step'] < 0) return false; + if ($array['step'] > 23 || $array['step'] < 0) { + return false; + } return true; } @@ -533,11 +541,17 @@ class Interval private function validateDayOfMonth(array $array) : bool { foreach ($array['dayOfMonth'] as $dayOfMonth) { - if ($dayOfMonth > 31 || $dayOfMonth < 1) return false; + if ($dayOfMonth > 31 || $dayOfMonth < 1) { + return false; + } } - if ($array['step'] > 31 || $array['step'] < 1) return false; - if ($array['nearest'] > 31 || $array['nearest'] < 1) return false; + if ($array['step'] > 31 || $array['step'] < 1) { + return false; + } + if ($array['nearest'] > 31 || $array['nearest'] < 1) { + return false; + } return true; } @@ -555,10 +569,14 @@ class Interval private function validateMonth(array $array) : bool { foreach ($array['month'] as $month) { - if ($month > 12 || $month < 1) return false; + if ($month > 12 || $month < 1) { + return false; + } } - if ($array['step'] > 12 || $array['step'] < 1) return false; + if ($array['step'] > 12 || $array['step'] < 1) { + return false; + } return true; } @@ -576,10 +594,14 @@ class Interval private function validateDayOfWeek(array $array) : bool { foreach ($array['dayOfWeek'] as $dayOfWeek) { - if ($dayOfWeek > 7 || $dayOfWeek < 1) return false; + if ($dayOfWeek > 7 || $dayOfWeek < 1) { + return false; + } } - if ($array['step'] > 5 || $array['step'] < 1) return false; + if ($array['step'] > 5 || $array['step'] < 1) { + return false; + } return true; } diff --git a/Validation/Base/CreditCard.php b/Validation/Base/CreditCard.php index bf78b1175..b3ad83ab4 100644 --- a/Validation/Base/CreditCard.php +++ b/Validation/Base/CreditCard.php @@ -75,7 +75,7 @@ abstract class CreditCard extends ValidatorAbstract public static function luhnTest(string $num) { $len = strlen($num); - for ($i = $len-1; $i >= 0; $i--) { + for ($i = $len - 1; $i >= 0; $i--) { $ord = ord($num[$i]); if (($len - 1) & $i) {