Merge pull request #17 from Orange-Management/scrutinizer-patch-1

Scrutinizer Auto-Fixes
This commit is contained in:
Dennis Eichhorn 2016-03-28 16:46:07 +02:00
commit bde9db585e
41 changed files with 171 additions and 135 deletions

View File

@ -94,17 +94,23 @@ class Numbers
// This tests if the 6 least significant bits are right. // This tests if the 6 least significant bits are right.
// Moving the to be tested bit to the highest position saves us masking. // 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); $numberOfTrailingZeros = self::countTrailingZeros($n);
// Each square ends with an even number of zeros. // Each square ends with an even number of zeros.
if (($numberOfTrailingZeros & 1) !== 0) return false; if (($numberOfTrailingZeros & 1) !== 0) {
return false;
}
$n >>= $numberOfTrailingZeros; $n >>= $numberOfTrailingZeros;
// Now x is either 0 or odd. // Now x is either 0 or odd.
// In binary each odd square ends with 001. // In binary each odd square ends with 001.
// Postpone the sign test until now; handle zero in the branch. // 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. // Do it in the classical way.
// The correctness is not trivial as the conversion from long to double is lossy! // The correctness is not trivial as the conversion from long to double is lossy!
$tst = (int) sqrt($n); $tst = (int) sqrt($n);

View File

@ -4,7 +4,9 @@ class GaussianElimination
{ {
private function swapRows(&$a, &$b, $r1, $r2) private function swapRows(&$a, &$b, $r1, $r2)
{ {
if ($r1 == $r2) return; if ($r1 == $r2) {
return;
}
$tmp = $a[$r1]; $tmp = $a[$r1];
$a[$r1] = $a[$r2]; $a[$r1] = $a[$r2];

View File

@ -329,7 +329,9 @@ class Average
$avgcos = $coss / (0.0 + count($angles)); $avgcos = $coss / (0.0 + count($angles));
$avgang = rad2deg(atan2($avgsin, $avgcos)); $avgang = rad2deg(atan2($avgsin, $avgcos));
while ($avgang < 0.0) $avgang += 360.0; while ($avgang < 0.0) {
$avgang += 360.0;
}
return $avgang; return $avgang;
} }

View File

@ -584,14 +584,18 @@ class Markdown
if (isset($block['closed'])) { if (isset($block['closed'])) {
return null; 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']++; $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) { if ($block['depth'] > 0) {
$block['depth']--; $block['depth']--;
}
} else { } else {
$block['closed'] = true; $block['closed'] = true;
} }

View File

@ -491,10 +491,14 @@ class Interval
private function validateMinute(array $array) : bool private function validateMinute(array $array) : bool
{ {
foreach ($array['minutes'] as $minute) { 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; return true;
} }
@ -512,10 +516,14 @@ class Interval
private function validateHour(array $array) : bool private function validateHour(array $array) : bool
{ {
foreach ($array['hours'] as $hour) { 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; return true;
} }
@ -533,11 +541,17 @@ class Interval
private function validateDayOfMonth(array $array) : bool private function validateDayOfMonth(array $array) : bool
{ {
foreach ($array['dayOfMonth'] as $dayOfMonth) { 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['step'] > 31 || $array['step'] < 1) {
if ($array['nearest'] > 31 || $array['nearest'] < 1) return false; return false;
}
if ($array['nearest'] > 31 || $array['nearest'] < 1) {
return false;
}
return true; return true;
} }
@ -555,10 +569,14 @@ class Interval
private function validateMonth(array $array) : bool private function validateMonth(array $array) : bool
{ {
foreach ($array['month'] as $month) { 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; return true;
} }
@ -576,10 +594,14 @@ class Interval
private function validateDayOfWeek(array $array) : bool private function validateDayOfWeek(array $array) : bool
{ {
foreach ($array['dayOfWeek'] as $dayOfWeek) { 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; return true;
} }