Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer 2016-03-28 15:13:36 +00:00
parent bde9db585e
commit c40a8ed0a2
17 changed files with 99 additions and 99 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -45,7 +45,7 @@ class Git {
*/
public static function setBin(string $path)
{
if(realpath($path) === false) {
if (realpath($path) === false) {
throw new \PathException($path);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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