Apply "Squiz.WhiteSpace.OperatorSpacing"

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Henrique Moody 2019-02-07 20:57:28 +01:00
parent 8e59ec5d4a
commit 0e0581a9da
No known key found for this signature in database
GPG key ID: 221E9281655813A6
5 changed files with 12 additions and 8 deletions

View file

@ -54,8 +54,7 @@ final class Cnh extends AbstractRule
return false;
}
if ($input[10] != (((($dv2 = ($s2 % 11) - (($dv1 > 9) ? 2 : 0)) < 0)
? $dv2 + 11 : $dv2) > 9) ? 0 : $dv2) {
if ($input[10] != (((($dv2 = ($s2 % 11) - (($dv1 > 9) ? 2 : 0)) < 0) ? $dv2 + 11 : $dv2) > 9) ? 0 : $dv2) {
return false;
}

View file

@ -54,7 +54,7 @@ final class Cnpj extends AbstractRule
$n = 0;
for ($i = 0; $i < 12; ++$i) {
$n += $digits[$i] * $bases[$i+1];
$n += $digits[$i] * $bases[$i + 1];
}
if ($digits[12] != ((($n %= 11) < 2) ? 0 : 11 - $n)) {

View file

@ -68,8 +68,10 @@ final class EndsWith extends AbstractRule
return end($input) == $this->endValue;
}
return mb_strripos($input, $this->endValue, -1, $enc = mb_detect_encoding($input))
=== mb_strlen($input, $enc) - mb_strlen($this->endValue, $enc);
$encoding = mb_detect_encoding($input);
$endPosition = mb_strlen($input, $encoding) - mb_strlen($this->endValue, $encoding);
return mb_strripos($input, $this->endValue, -1, $encoding) === $endPosition;
}
private function validateIdentical($input): bool
@ -78,7 +80,9 @@ final class EndsWith extends AbstractRule
return end($input) === $this->endValue;
}
return mb_strrpos($input, $this->endValue, 0, $enc = mb_detect_encoding($input))
=== mb_strlen($input, $enc) - mb_strlen($this->endValue, $enc);
$encoding = mb_detect_encoding($input);
$endPosition = mb_strlen($input, $encoding) - mb_strlen($this->endValue, $encoding);
return mb_strrpos($input, $this->endValue, 0, $encoding) === $endPosition;
}
}

View file

@ -75,4 +75,5 @@
<property name="spacingBeforeFirst" value="0" />
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.OperatorSpacing" />
</ruleset>

View file

@ -63,7 +63,7 @@ final class FactorTest extends RuleTestCase
'6 is factor \'2\'' => [new Factor(6), '2'],
'4 is factor 2.00' => [new Factor(4), 2.0],
'-0 is factor -5.000000' => [new Factor(-0), -5.000000],
'-0 is factor (float) -mt_rand()' => [new Factor(-0), (float) -mt_rand()],
'-0 is factor (float) - mt_rand()' => [new Factor(-0), (float) - mt_rand()],
];
}