diff --git a/Math/Function/Fibunacci.php b/Math/Function/Fibunacci.php index bb1435eeb..1174730eb 100644 --- a/Math/Function/Fibunacci.php +++ b/Math/Function/Fibunacci.php @@ -46,7 +46,7 @@ class Fibunacci $old_2 = $start; $fib = 0; - for($i = 4; $i < $n; $i++) { + for ($i = 4; $i < $n; $i++) { $fib = $old_1 + $old_2; $old_1 = $old_2; $old_2 = $fib; diff --git a/Math/Matrix/Matrix.php b/Math/Matrix/Matrix.php index c15d6656f..ce9c379cc 100644 --- a/Math/Matrix/Matrix.php +++ b/Math/Matrix/Matrix.php @@ -334,14 +334,14 @@ class Matrix implements ArrayAccess, Iterator public function det() { - if($this->n === 1) { + if ($this->n === 1) { return $this->matrix[0][0]; } $trianglize = $this->matrix; $prod = $this->upperTrianglize($trianglize); - for($i = 0; $i < $this->n; $i++) { + for ($i = 0; $i < $this->n; $i++) { $prod *= $trianglize[$i][$i]; } diff --git a/Math/Number/Numbers.php b/Math/Number/Numbers.php index ae834d008..13330171d 100644 --- a/Math/Number/Numbers.php +++ b/Math/Number/Numbers.php @@ -43,8 +43,8 @@ class Numbers { $sum = 0; - for($i = 1; $i < $n; $i++) { - if($n % $i == 0) { + for ($i = 1; $i < $n; $i++) { + if ($n % $i == 0) { $sum += $i; } } @@ -89,7 +89,7 @@ class Numbers $goodMask = 0xC840C04048404040; // 0xC840C04048404040 computed below for ($i = 0; $i < 64; ++$i) { - $goodMask |= PHP_INT_MIN >> ($i*$i); + $goodMask |= PHP_INT_MIN >> ($i * $i); } // This tests if the 6 least significant bits are right. @@ -108,7 +108,7 @@ class Numbers // 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) { + if (($n & 7) != 1 | $n <= 0) { return $n === 0; } // Do it in the classical way. @@ -132,7 +132,7 @@ class Numbers { $count = 0; while ($n !== 0) { - if ($n & 1 == 1) { + if ($n & 1 == 1) { break; } else { $count++; @@ -156,10 +156,10 @@ class Numbers */ public static function greatestCommonDivisor(int $n, int $m) : int { - while(true) { - if($n === $m) { + while (true) { + if ($n === $m) { return $m; - } if($n > $m) { + } if ($n > $m) { $n -= $m; } else { $m -= $n; diff --git a/System/File/Directory.php b/System/File/Directory.php index 3bc541949..1d6b15dbe 100644 --- a/System/File/Directory.php +++ b/System/File/Directory.php @@ -130,12 +130,12 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess */ public static function createPath(string $path, int $permission = 0644, bool $recursive = false) : bool { - if($recursive && !file_exists($parent = self::getParent($path))) { + if ($recursive && !file_exists($parent = self::getParent($path))) { self::createPath($parent, $permission, $recursive); } if (!file_exists($path)) { - if(is_writable(self::getParent($path))) { + if (is_writable(self::getParent($path))) { mkdir($path, $permission, true); return true; diff --git a/Utils/Barcode/C25.php b/Utils/Barcode/C25.php index 7646ac600..cf8860639 100644 --- a/Utils/Barcode/C25.php +++ b/Utils/Barcode/C25.php @@ -35,7 +35,7 @@ class C25 extends C128Abstract * @var string[] * @since 1.0.0 */ - protected static $CODEARRAY = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']; + protected static $CODEARRAY = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']; /** * Char weighted array. diff --git a/Utils/Git/Commit.php b/Utils/Git/Commit.php index 8bc515c2d..35134935f 100644 --- a/Utils/Git/Commit.php +++ b/Utils/Git/Commit.php @@ -139,11 +139,11 @@ class Commit */ private function addChange(string $path, int $line, string $old, string $new) { - if(!isset($this->files[$path])) { + if (!isset($this->files[$path])) { throw new \Exception(); } - if(!isset($this->files[$path][$line])) { + if (!isset($this->files[$path][$line])) { $this->files[$path][$line] = ['old' => $old, 'new' => $new]; } else { throw new \Exception(); diff --git a/Utils/Git/Git.php b/Utils/Git/Git.php index 610d543da..a6c81c8db 100644 --- a/Utils/Git/Git.php +++ b/Utils/Git/Git.php @@ -45,7 +45,7 @@ class Git { */ public static function setBin(string $path) { - if(realpath($path) === false) { + if (realpath($path) === false) { throw new \PathException($path); } diff --git a/Utils/MultiMap.php b/Utils/MultiMap.php index b159b6393..a1ca38cdc 100644 --- a/Utils/MultiMap.php +++ b/Utils/MultiMap.php @@ -90,7 +90,7 @@ class MultiMap implements \Countable $id = count($this->values); $inserted = false; - if($this->keyType !== KeyType::MULTIPLE) { + if ($this->keyType !== KeyType::MULTIPLE) { $keys = [implode($keys, ':')]; } @@ -148,7 +148,7 @@ class MultiMap implements \Countable */ public function get($key) { - if($this->keyType === KeyType::SINGLE) { + if ($this->keyType === KeyType::SINGLE) { return $this->getSingle($key); } else { return $this->getMultiple($key); @@ -182,14 +182,14 @@ class MultiMap implements \Countable */ private function getMultiple($key) { - if(is_array($key)) { - if($this->orderType === OrderType::LOOSE) { + if (is_array($key)) { + if ($this->orderType === OrderType::LOOSE) { $keys = Permutation::permut($key); - foreach($keys as $key => $value) { + foreach ($keys as $key => $value) { $key = implode($value, ':'); - if(isset($this->keys[$key])) { + if (isset($this->keys[$key])) { return $this->values[$this->keys[$key]]; } } @@ -214,7 +214,7 @@ class MultiMap implements \Countable */ public function set($key, $value) : bool { - if($this->keyType === KeyType::MULTIPLE && is_array($key)) { + if ($this->keyType === KeyType::MULTIPLE && is_array($key)) { return $this->setMultiple($key, $value); } else { return $this->setSingle($key, $value); @@ -258,11 +258,11 @@ class MultiMap implements \Countable */ private function setMultiple($key, $value) : bool { - if($this->orderType !== OrderType::LOOSE) { + if ($this->orderType !== OrderType::LOOSE) { $permutation = Permutation::permut($key); - foreach($permutation as $permut) { - if($this->set(implode($permut, ':'), $value)) { + foreach ($permutation as $permut) { + if ($this->set(implode($permut, ':'), $value)) { return true; } } @@ -285,7 +285,7 @@ class MultiMap implements \Countable */ public function remove($key) : bool { - if($this->keyType === KeyType::MULTIPLE && is_array($key)) { + if ($this->keyType === KeyType::MULTIPLE && is_array($key)) { return $this->removeMultiple($key); } else { return $this->removeSingle($key); @@ -329,12 +329,12 @@ class MultiMap implements \Countable */ private function removeMultiple($key) : bool { - if($this->orderType === OrderType::LOOSE) { + if ($this->orderType === OrderType::LOOSE) { $keys = Permutation::permut($key); $removed = false; - foreach($keys as $key => $value) { + foreach ($keys as $key => $value) { $removed |= $this->remove(implode($value, ':')); } @@ -359,7 +359,7 @@ class MultiMap implements \Countable */ public function remap($old, $new) : bool { - if($this->keyType === KeyType::MULTIPLE) { + if ($this->keyType === KeyType::MULTIPLE) { return false; } @@ -388,7 +388,7 @@ class MultiMap implements \Countable */ public function removeKey($key) : bool { - if($this->keyType === KeyType::MULTIPLE && is_array($key)) { + if ($this->keyType === KeyType::MULTIPLE && is_array($key)) { return $this->removeKeyMultiple($key); } else { return $this->removeKeySingle($key); @@ -434,12 +434,12 @@ class MultiMap implements \Countable */ private function removeKeyMultiple($key) : bool { - if($this->orderType === OrderType::LOOSE) { + if ($this->orderType === OrderType::LOOSE) { $keys = Permutation::permut($key); $removed = false; - foreach($keys as $key => $value) { + foreach ($keys as $key => $value) { $removed |= $this->removeKey(implode($value, ':')); } @@ -461,7 +461,7 @@ class MultiMap implements \Countable */ public function getSiblings($key) : array { - if($this->keyType === KeyType::MULTIPLE) { + if ($this->keyType === KeyType::MULTIPLE) { return $this->getSiblingsMultiple($key); } @@ -506,7 +506,7 @@ class MultiMap implements \Countable */ public function getSiblingsMultiple($key) : array { - if($this->orderType === OrderType::LOOSE) { + if ($this->orderType === OrderType::LOOSE) { return Permutation::permut($key); } else { return []; diff --git a/Utils/Parser/Php/ArrayParser.php b/Utils/Parser/Php/ArrayParser.php index b202a8219..bdc81c72d 100644 --- a/Utils/Parser/Php/ArrayParser.php +++ b/Utils/Parser/Php/ArrayParser.php @@ -64,11 +64,11 @@ class ArrayParser $stringify = '[' . PHP_EOL; foreach ($arr as $key => $val) { - if(is_string($key)) { + if (is_string($key)) { $key = '"' . $key . '"'; } - $stringify .= ' ' . $key . ' => ' . MemberParser::parseVariable($val). ',' . PHP_EOL; + $stringify .= ' ' . $key . ' => ' . MemberParser::parseVariable($val) . ',' . PHP_EOL; } diff --git a/Utils/Parser/Php/ClassParser.php b/Utils/Parser/Php/ClassParser.php index d1db9ed39..d438e18ef 100644 --- a/Utils/Parser/Php/ClassParser.php +++ b/Utils/Parser/Php/ClassParser.php @@ -136,7 +136,7 @@ class ClassParser public function addUse(string $namespace, string $as = null) { - if(isset($as)) { + if (isset($as)) { $this->use[$as] = $namespace; } else { $this->use[] = $namespace; @@ -145,7 +145,7 @@ class ClassParser public function removeUse($id) : bool { - if(isset($this->use[$id])) { + if (isset($this->use[$id])) { unset($this->use[$id]); return true; @@ -186,7 +186,7 @@ class ClassParser public function addTrait(string $trait, string $as = null) { - if(isset($as)) { + if (isset($as)) { $this->traits[$as] = $trait; } else { $this->traits[] = $trait; @@ -200,7 +200,7 @@ class ClassParser public function removeMember(string $name) : bool { - if(isset($this->members[$name])) { + if (isset($this->members[$name])) { unset($this->members[$name]); return true; @@ -221,7 +221,7 @@ class ClassParser public function removeFunction(string $name) : bool { - if(isset($this->functions[$name])) { + if (isset($this->functions[$name])) { unset($this->functions[$name]); return true; @@ -239,67 +239,67 @@ class ClassParser { $class = ''; - if(!empty($this->requires)) { - foreach($this->requires as $require) { + if (!empty($this->requires)) { + foreach ($this->requires as $require) { $class .= 'require_once "' . $require . '";' . PHP_EOL; } $class .= PHP_EOL; } - if(!empty($this->includes)) { - foreach($this->includes as $include) { + if (!empty($this->includes)) { + foreach ($this->includes as $include) { $class .= 'include_once "' . $include . '";' . PHP_EOL; } $class .= PHP_EOL; } - if(isset($namespace)) { + if (isset($namespace)) { $class = $namespace . ';' . PHP_EOL . PHP_EOL; } - if(!empty($this->use)) { - foreach($this->use as $as => $use) { + if (!empty($this->use)) { + foreach ($this->use as $as => $use) { $class .= 'use ' . $use . (is_string($as) ? ' as ' . $as : '') . ';' . PHP_EOL; } $class .= PHP_EOL; } - if($this->isfinal) { + if ($this->isfinal) { $class .= 'final '; } - if($this->isAbstract) { + if ($this->isAbstract) { $class .= 'abstract '; } $class .= $this->type . ' ' . $this->name . ' '; - if(isset($this->extends)) { + if (isset($this->extends)) { $class .= 'extends ' . $this->extends . ' '; } - if(!empty($this->implements)) { + if (!empty($this->implements)) { $class .= 'implements ' . implode(', ', $this->implements) . PHP_EOL; } $class .= '{' . PHP_EOL . PHP_EOL; - if(!empty($this->traits)) { - foreach($this->traits as $as => $trait) { + if (!empty($this->traits)) { + foreach ($this->traits as $as => $trait) { $class .= 'use ' . $trait . ';' . PHP_EOL; } $class .= PHP_EOL; } - foreach($this->members as $name => $member) { + foreach ($this->members as $name => $member) { $class .= $member->parse() . PHP_EOL . PHP_EOL; } - foreach($this->functions as $name => $function) { + foreach ($this->functions as $name => $function) { $class .= $function->parse() . PHP_EOL . PHP_EOL; } diff --git a/Utils/Parser/Php/ClassType.php b/Utils/Parser/Php/ClassType.php index e86ad9586..13a678aeb 100644 --- a/Utils/Parser/Php/ClassType.php +++ b/Utils/Parser/Php/ClassType.php @@ -32,7 +32,7 @@ use phpOMS\Datatypes\Enum; */ abstract class ClassType extends Enum { - const _CLASS = 'class'; + const _CLASS = 'class'; const _TRAIT = 'trait'; - const _INTERFACE = 'interface'; + const _INTERFACE = 'interface'; } diff --git a/Utils/Parser/Php/FunctionParser.php b/Utils/Parser/Php/FunctionParser.php index 9d2865417..0ef81dda3 100644 --- a/Utils/Parser/Php/FunctionParser.php +++ b/Utils/Parser/Php/FunctionParser.php @@ -102,9 +102,9 @@ class FunctionParser { $this->isAbstract = $abstract; - if($this->isAbstract) { + if ($this->isAbstract) { $this->body = null; - } elseif(!$this->isAbstract && !isset($this->body)) { + } elseif (!$this->isAbstract && !isset($this->body)) { $this->body = ''; } } @@ -134,8 +134,8 @@ class FunctionParser $this->parameters[$name]['name'] = $name; $this->parameters[$name]['typehint'] = $typehint; - if(isset($default)) { - if($default === 'null') { + if (isset($default)) { + if ($default === 'null') { $default = null; } @@ -148,31 +148,31 @@ class FunctionParser $function = ''; $member .= str_repeat(' ', ClassParser::INDENT); - if($this->isFinal) { + if ($this->isFinal) { $member .= 'final '; } - if($this->isAbstract) { + if ($this->isAbstract) { $member .= 'abstract '; } $member .= $this->visibility . ' '; - if($this->isStatic) { + if ($this->isStatic) { $member .= 'static '; } $member .= 'function ' . $this->name . '('; $parameters = ''; - foreach($this->parameters as $name => $para) { - $parameters = (isset($para['typehint']) ? $para['typehint'] . ' ' : '') . $para['name'] . (array_key_exists('default', $para) ? ' = ' . MemberParser::parseVariable($para['default']) : '') . ', '; + foreach ($this->parameters as $name => $para) { + $parameters = (isset($para['typehint']) ? $para['typehint'] . ' ' : '') . $para['name'] . (array_key_exists('default', $para) ? ' = ' . MemberParser::parseVariable($para['default']) : '') . ', '; } $member .= rtrim($parameters, ', ') . ') '; $member .= ($this->return ?? '') . PHP_EOL; - if(isset($this->body)) { + if (isset($this->body)) { $member .= str_repeat(' ', ClassParser::INDENT) . '{' . PHP_EOL . $this->addIndent($this->body) . PHP_EOL . str_repeat(' ', ClassParser::INDENT) . '}'; } else { $member .= ';'; @@ -185,7 +185,7 @@ class FunctionParser { $body = preg_split('/\r\n|\r|\n/', $this->body); - foreach($body as &$line) { + foreach ($body as &$line) { $line = str_repeat(' ', ClassParser::INDENT) . $line; } diff --git a/Utils/Parser/Php/MemberParser.php b/Utils/Parser/Php/MemberParser.php index 7db17d715..4a274180c 100644 --- a/Utils/Parser/Php/MemberParser.php +++ b/Utils/Parser/Php/MemberParser.php @@ -62,7 +62,7 @@ class MemberParser public function setStatic(bool $static) { $this->isStatic = $static; - if($this->isStatic) { + if ($this->isStatic) { $this->isConst = false; } } @@ -76,7 +76,7 @@ class MemberParser { $this->isConst = $const; - if($this->isConst) { + if ($this->isConst) { $this->isStatic = false; } } @@ -92,11 +92,11 @@ class MemberParser $member .= $this->visibility . ' '; - if($this->isStatic) { + if ($this->isStatic) { $member .= 'static '; } - if($this->isConst) { + if ($this->isConst) { $member .= 'const '; } @@ -115,17 +115,17 @@ class MemberParser */ public static function parseVariable($value) : string { - if(is_array($value)) { + if (is_array($value)) { return ArrayParser::serializeArray($value) . PHP_EOL; - } elseif(is_string($value)) { + } elseif (is_string($value)) { return '"' . $value . '"'; - } elseif(is_scalar($value)) { + } elseif (is_scalar($value)) { return $value; - } elseif(is_null($value)) { + } elseif (is_null($value)) { return 'null'; - } elseif(is_bool($value)) { + } elseif (is_bool($value)) { return $value ? 'true' : 'false'; - } elseif($value instanceOf \Serializable) { + } elseif ($value instanceOf \Serializable) { return self::parseVariable($value->serialize()); } else { throw new \UnexpectedValueException(); diff --git a/Utils/Parser/Php/Visibility.php b/Utils/Parser/Php/Visibility.php index 269ade0aa..fba0fb457 100644 --- a/Utils/Parser/Php/Visibility.php +++ b/Utils/Parser/Php/Visibility.php @@ -32,7 +32,7 @@ use phpOMS\Datatypes\Enum; */ abstract class MemberVisibility extends Enum { - const _PUBLIC = 'public'; - const _PRIVATE = 'private'; - const _PROTECTED = 'protected'; + const _PUBLIC = 'public'; + const _PRIVATE = 'private'; + const _PROTECTED = 'protected'; } diff --git a/Utils/Permutation.php b/Utils/Permutation.php index 56f2e7da6..97c74cfb9 100644 --- a/Utils/Permutation.php +++ b/Utils/Permutation.php @@ -11,10 +11,10 @@ class Permutation { $permutations = []; - if(empty($toPermute)){ + if (empty($toPermute)) { $permutations[] = implode('', $result); - } else{ - foreach($toPermute as $key => $val){ + } else { + foreach ($toPermute as $key => $val) { $newArr = $toPermute; $newres = $result; $newres[] = $val; diff --git a/Utils/RnG/ArrayRandomize.php b/Utils/RnG/ArrayRandomize.php index cad51922e..1adf888b6 100644 --- a/Utils/RnG/ArrayRandomize.php +++ b/Utils/RnG/ArrayRandomize.php @@ -41,7 +41,7 @@ class ArrayRandomize { $shuffled = []; - while(!empty($arr)) { + while (!empty($arr)) { $rnd = array_rand($arr); $shuffled[] = $arr[$rnd]; array_splice($arr, $rnd, 1); @@ -62,7 +62,7 @@ class ArrayRandomize { $shuffled = []; - for($i = count($arr)-1; $i > 0; $i--){ + for ($i = count($arr) - 1; $i > 0; $i--) { $rnd = mt_rand(0, $i); $shuffled[$i] = $arr[$rnd]; $shuffled[$rnd] = $arr[$i]; diff --git a/Validation/BitcoinValidator.php b/Validation/BitcoinValidator.php index 768b45175..994f49e56 100644 --- a/Validation/BitcoinValidator.php +++ b/Validation/BitcoinValidator.php @@ -21,10 +21,10 @@ class BitcoinValidator { $decoded = decodeBase58($address); - $d1 = hash("sha256", substr($decoded,0,21), true); + $d1 = hash("sha256", substr($decoded, 0, 21), true); $d2 = hash("sha256", $d1, true); - if(substr_compare($decoded, $d2, 21, 4)) { + if (substr_compare($decoded, $d2, 21, 4)) { return false; } @@ -38,26 +38,26 @@ class BitcoinValidator $out = array_fill(0, 25, 0); $len = strlen($input); - for($i = 0; $i < $len; $i++){ - if(($p=strpos($alphabet, $input[$i]))===false){ + for ($i = 0; $i < $len; $i++) { + if (($p = strpos($alphabet, $input[$i])) === false) { throw new \Exception("invalid character found"); } $c = $p; - for ($j = 25; $j--; ) { - $c += (int)(58 * $out[$j]); - $out[$j] = (int)($c % 256); + for ($j = 25; $j--;) { + $c += (int) (58 * $out[$j]); + $out[$j] = (int) ($c % 256); $c /= 256; - $c = (int)$c; + $c = (int) $c; } - if($c !== 0){ + if ($c !== 0) { throw new \Exception("address too long"); } } $result = ""; - foreach($out as $val){ + foreach ($out as $val) { $result .= chr($val); }