Apply "SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Henrique Moody 2019-02-09 13:28:08 +01:00
parent 3abf64f496
commit 99b912ff87
No known key found for this signature in database
GPG key ID: 221E9281655813A6
62 changed files with 107 additions and 106 deletions

View file

@ -43,7 +43,7 @@ final class CreditCardException extends ValidationException
*/
protected function chooseTemplate(): string
{
if (CreditCard::ANY === $this->getParam('brand')) {
if ($this->getParam('brand') === CreditCard::ANY) {
return self::STANDARD;
}

View file

@ -43,7 +43,7 @@ class KeySetException extends GroupedValidationException implements NonOmissible
*/
protected function chooseTemplate(): string
{
if (0 === count($this->getChildren())) {
if (count($this->getChildren()) === 0) {
return self::STRUCTURE;
}

View file

@ -193,7 +193,7 @@ class NestedValidationException extends ValidationException implements IteratorA
return false;
}
if (1 !== count($exception->getChildren())) {
if (count($exception->getChildren()) !== 1) {
return false;
}

View file

@ -132,7 +132,7 @@ class ValidationException extends InvalidArgumentException implements Exception
public function hasCustomTemplate(): bool
{
return false === isset(static::$defaultTemplates[$this->mode][$this->template]);
return isset(static::$defaultTemplates[$this->mode][$this->template]) === false;
}
public function __toString(): string
@ -177,7 +177,7 @@ class ValidationException extends InvalidArgumentException implements Exception
}
$value = $vars[$match[1]];
if ('name' == $match[1] && is_string($value)) {
if ($match[1] == 'name' && is_string($value)) {
return $value;
}

View file

@ -102,7 +102,7 @@ final class Factory
*/
public static function getDefaultInstance(): self
{
if (null === self::$defaultInstance) {
if (self::$defaultInstance === null) {
self::$defaultInstance = new self(
self::DEFAULT_RULES_NAMESPACES,
self::DEFAULT_EXCEPTIONS_NAMESPACES,
@ -247,7 +247,7 @@ final class Factory
$property->setAccessible(true);
$propertyValue = $property->getValue($validatable);
if (null === $propertyValue) {
if ($propertyValue === null) {
continue;
}
@ -255,7 +255,7 @@ final class Factory
}
$parentReflection = $reflection->getParentClass();
if (false !== $parentReflection) {
if ($parentReflection !== false) {
return $values + $this->extractPropertiesValues($validatable, $parentReflection);
}

View file

@ -46,7 +46,7 @@ trait CanCompareValues
return $value;
}
if (1 === mb_strlen($value)) {
if (mb_strlen($value) === 1) {
return $value;
}

View file

@ -48,7 +48,7 @@ trait CanValidateDateTime
*/
private function isDateTimeParsable(array $info): bool
{
return 0 === $info['error_count'] && 0 === $info['warning_count'];
return $info['error_count'] === 0 && $info['warning_count'] === 0;
}
private function isDateFormat(string $format): bool

View file

@ -70,7 +70,7 @@ abstract class AbstractAge extends AbstractRule
return false;
}
if (null === $this->format) {
if ($this->format === null) {
return $this->isValidWithoutFormat((string) $input);
}
@ -80,7 +80,7 @@ abstract class AbstractAge extends AbstractRule
private function isValidWithoutFormat(string $dateTime): bool
{
$timestamp = strtotime($dateTime);
if (false === $timestamp) {
if ($timestamp === false) {
return false;
}

View file

@ -119,12 +119,12 @@ abstract class AbstractComposite extends AbstractRule
private function hasName(Validatable $rule): bool
{
return null !== $rule->getName();
return $rule->getName() !== null;
}
private function updateExceptionTemplate(ValidationException $exception): void
{
if (null === $this->template || $exception->hasCustomTemplate()) {
if ($this->template === null || $exception->hasCustomTemplate()) {
return;
}

View file

@ -49,13 +49,13 @@ abstract class AbstractFilterRule extends AbstractRule
}
$stringInput = (string) $input;
if ('' === $stringInput) {
if ($stringInput === '') {
return false;
}
$filteredInput = $this->filter($stringInput);
return '' === $filteredInput || $this->validateFilteredInput($filteredInput);
return $filteredInput === '' || $this->validateFilteredInput($filteredInput);
}
private function filter(string $input): string

View file

@ -39,6 +39,6 @@ final class Base64 extends AbstractRule
return false;
}
return 0 === mb_strlen($input) % 4;
return mb_strlen($input) % 4 === 0;
}
}

View file

@ -36,7 +36,7 @@ final class Bsn extends AbstractRule
return false;
}
if (9 !== mb_strlen($input)) {
if (mb_strlen($input) !== 9) {
return false;
}
@ -45,6 +45,6 @@ final class Bsn extends AbstractRule
$sum += $i * $input[9 - $i];
}
return 0 !== $sum && 0 === $sum % 11;
return $sum !== 0 && $sum % 11 === 0;
}
}

View file

@ -40,7 +40,7 @@ final class Cnh extends AbstractRule
$input = preg_replace('{\D}', '', (string) $input);
// Validate length and invalid numbers
if (11 != mb_strlen($input) || (0 === (int) $input)) {
if (mb_strlen($input) != 11 || ((int) $input === 0)) {
return false;
}

View file

@ -48,7 +48,7 @@ final class Cnpj extends AbstractRule
return false;
}
if (14 !== count($digits)) {
if (count($digits) !== 14) {
return false;
}

View file

@ -70,15 +70,15 @@ final class Contains extends AbstractRule
private function validateString(string $haystack, string $needle): bool
{
if ('' === $needle) {
if ($needle === '') {
return false;
}
$encoding = mb_detect_encoding($haystack);
if ($this->identical) {
return false !== mb_strpos($haystack, $needle, 0, $encoding);
return mb_strpos($haystack, $needle, 0, $encoding) !== false;
}
return false !== mb_stripos($haystack, $needle, 0, $encoding);
return mb_stripos($haystack, $needle, 0, $encoding) !== false;
}
}

View file

@ -37,7 +37,7 @@ final class Cpf extends AbstractRule
// Code ported from jsfromhell.com
$c = preg_replace('/\D/', '', $input);
if (11 != mb_strlen($c) || preg_match("/^{$c[0]}{11}$/", $c)) {
if (mb_strlen($c) != 11 || preg_match("/^{$c[0]}{11}$/", $c)) {
return false;
}

View file

@ -52,15 +52,15 @@ final class DateTime extends AbstractRule
public function validate($input): bool
{
if ($input instanceof DateTimeInterface) {
return null === $this->format;
return $this->format === null;
}
if (!is_scalar($input)) {
return false;
}
if (null === $this->format) {
return false !== strtotime((string) $input);
if ($this->format === null) {
return strtotime((string) $input) !== false;
}
return $this->isDateTime($this->format, (string) $input);

View file

@ -54,7 +54,7 @@ class Domain extends AbstractComposite
new AnyOf(
new Not(new Contains('--')),
new Callback(static function ($str) {
return 1 == mb_substr_count($str, '--');
return mb_substr_count($str, '--') == 1;
})
),
new Not(new EndsWith('-'))

View file

@ -54,7 +54,7 @@ final class Email extends AbstractRule
return false;
}
if (null !== $this->validator) {
if ($this->validator !== null) {
return $this->validator->isValid($input, new RFCValidation());
}

View file

@ -30,10 +30,10 @@ final class Even extends AbstractRule
*/
public function validate($input): bool
{
if (false === filter_var($input, FILTER_VALIDATE_INT)) {
if (filter_var($input, FILTER_VALIDATE_INT) === false) {
return false;
}
return 0 === (int) $input % 2;
return (int) $input % 2 === 0;
}
}

View file

@ -46,12 +46,12 @@ final class Factor extends AbstractRule
{
// Every integer is a factor of zero, and zero is the only integer that
// has zero for a factor.
if (0 === $this->dividend) {
if ($this->dividend === 0) {
return true;
}
// Factors must be integers that are not zero.
if (!is_numeric($input) || (int) $input != $input || 0 == $input) {
if (!is_numeric($input) || (int) $input != $input || $input == 0) {
return false;
}

View file

@ -30,6 +30,6 @@ final class FalseVal extends AbstractRule
*/
public function validate($input): bool
{
return false === filter_var($input, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
return filter_var($input, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) === false;
}
}

View file

@ -28,12 +28,12 @@ class HexRgbColor extends Xdigit
return false;
}
if (0 === mb_strpos($input, '#')) {
if (mb_strpos($input, '#') === 0) {
$input = mb_substr($input, 1);
}
$length = mb_strlen($input);
if (3 != $length && 6 != $length) {
if ($length != 3 && $length != 6) {
return false;
}

View file

@ -58,6 +58,6 @@ final class Image extends AbstractRule
return false;
}
return 0 === mb_strpos($this->fileInfo->file($input), 'image/');
return mb_strpos($this->fileInfo->file($input), 'image/') === 0;
}
}

View file

@ -41,7 +41,7 @@ final class Imei extends AbstractRule
}
$numbers = preg_replace('/\D/', '', $input);
if (self::IMEI_SIZE != mb_strlen($numbers)) {
if (mb_strlen($numbers) != self::IMEI_SIZE) {
return false;
}

View file

@ -57,13 +57,13 @@ final class In extends AbstractRule
return in_array($input, $this->haystack);
}
if (null === $input || '' === $input) {
if ($input === null || $input === '') {
return $input == $this->haystack;
}
$inputString = (string) $input;
return false !== mb_stripos($this->haystack, $inputString, 0, mb_detect_encoding($inputString));
return mb_stripos($this->haystack, $inputString, 0, mb_detect_encoding($inputString)) !== false;
}
/**
@ -75,13 +75,13 @@ final class In extends AbstractRule
return in_array($input, $this->haystack, true);
}
if (null === $input || '' === $input) {
if ($input === null || $input === '') {
return $input === $this->haystack;
}
$inputString = (string) $input;
return false !== mb_strpos($this->haystack, $inputString, 0, mb_detect_encoding($inputString));
return mb_strpos($this->haystack, $inputString, 0, mb_detect_encoding($inputString)) !== false;
}
/**

View file

@ -36,6 +36,6 @@ final class IntVal extends AbstractRule
return false;
}
return false !== filter_var($input, FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_OCTAL);
return filter_var($input, FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_OCTAL) !== false;
}
}

View file

@ -115,11 +115,11 @@ final class Ip extends AbstractRule
private function parseRange(string $input): void
{
if ('*' == $input || '*.*.*.*' == $input || '0.0.0.0-255.255.255.255' == $input) {
if ($input == '*' || $input == '*.*.*.*' || $input == '0.0.0.0-255.255.255.255') {
return;
}
if (false !== mb_strpos($input, '-')) {
if (mb_strpos($input, '-') !== false) {
list($this->startAddress, $this->endAddress) = explode('-', $input);
if (!$this->verifyAddress($this->startAddress)) {
@ -133,13 +133,13 @@ final class Ip extends AbstractRule
return;
}
if (false !== mb_strpos($input, '*')) {
if (mb_strpos($input, '*') !== false) {
$this->parseRangeUsingWildcards($input);
return;
}
if (false !== mb_strpos($input, '/')) {
if (mb_strpos($input, '/') !== false) {
$this->parseRangeUsingCidr($input);
return;
@ -166,7 +166,7 @@ final class Ip extends AbstractRule
$parts = explode('/', $input);
$this->startAddress = $this->fillAddress($parts[0], '0');
$isAddressMask = false !== mb_strpos($parts[1], '.');
$isAddressMask = mb_strpos($parts[1], '.') !== false;
if ($isAddressMask && $this->verifyAddress($parts[1])) {
$this->mask = sprintf('%032b', ip2long($parts[1]));
@ -183,7 +183,7 @@ final class Ip extends AbstractRule
private function verifyAddress(string $address): bool
{
return false !== filter_var($address, FILTER_VALIDATE_IP, ['flags' => $this->options]);
return filter_var($address, FILTER_VALIDATE_IP, ['flags' => $this->options]) !== false;
}
private function verifyNetwork(string $input): bool
@ -196,7 +196,7 @@ final class Ip extends AbstractRule
private function belongsToSubnet(string $input): bool
{
if (null === $this->mask) {
if ($this->mask === null) {
return false;
}

View file

@ -30,12 +30,12 @@ final class Json extends AbstractRule
*/
public function validate($input): bool
{
if (!is_string($input) || '' === $input) {
if (!is_string($input) || $input === '') {
return false;
}
json_decode($input);
return JSON_ERROR_NONE === json_last_error();
return json_last_error() === JSON_ERROR_NONE;
}
}

View file

@ -28,7 +28,7 @@ class Key extends AbstractRelated
*/
public function __construct($reference, Validatable $referenceValidator = null, bool $mandatory = true)
{
if (!is_scalar($reference) || '' === $reference) {
if (!is_scalar($reference) || $reference === '') {
throw new ComponentException('Invalid array key name');
}
parent::__construct($reference, $referenceValidator, $mandatory);

View file

@ -62,7 +62,7 @@ final class KeySet extends AbstractWrapper
}
if (!$validatable instanceof AllOf
|| 1 !== count($validatable->getRules())) {
|| count($validatable->getRules()) !== 1) {
throw new ComponentException('KeySet rule accepts only Key rules');
}
@ -94,7 +94,7 @@ final class KeySet extends AbstractWrapper
unset($input[$keyRule->reference]);
}
return 0 == count($input);
return count($input) == 0;
}
/**

View file

@ -535,7 +535,7 @@ final class LanguageCode extends AbstractEnvelope
public function __construct(string $set = self::ALPHA2)
{
$index = array_search($set, self::AVAILABLE_SETS, true);
if (false === $index) {
if ($index === false) {
throw new ComponentException(sprintf('"%s" is not a valid language set for ISO 639', $set));
}

View file

@ -45,7 +45,7 @@ final class LeapDate extends AbstractRule
public function validate($input): bool
{
if ($input instanceof DateTimeInterface) {
return '02-29' === $input->format('m-d');
return $input->format('m-d') === '02-29';
}
if (is_scalar($input)) {

View file

@ -62,7 +62,7 @@ final class Length extends AbstractRule
$this->maxValue = $max;
$this->inclusive = $inclusive;
if (null !== $max && $min > $max) {
if ($max !== null && $min > $max) {
throw new ComponentException(sprintf('%d cannot be less than %d for validation', $min, $max));
}
}
@ -73,7 +73,7 @@ final class Length extends AbstractRule
public function validate($input): bool
{
$length = $this->extractLength($input);
if (null === $length) {
if ($length === null) {
return false;
}
@ -106,7 +106,7 @@ final class Length extends AbstractRule
private function validateMin(int $length): bool
{
if (null === $this->minValue) {
if ($this->minValue === null) {
return true;
}
@ -119,7 +119,7 @@ final class Length extends AbstractRule
private function validateMax(int $length): bool
{
if (null === $this->maxValue) {
if ($this->maxValue === null) {
return true;
}

View file

@ -57,6 +57,6 @@ final class Luhn extends AbstractRule
$sum += $digit;
}
return 0 == ($sum % 10);
return ($sum % 10) == 0;
}
}

View file

@ -35,10 +35,10 @@ final class Multiple extends AbstractRule
*/
public function validate($input): bool
{
if (0 == $this->multipleOf) {
return 0 == $input;
if ($this->multipleOf == 0) {
return $input == 0;
}
return 0 == $input % $this->multipleOf;
return $input % $this->multipleOf == 0;
}
}

View file

@ -34,14 +34,14 @@ class NfeAccessKey extends AbstractRule
*/
public function validate($input): bool
{
if (44 !== mb_strlen($input)) {
if (mb_strlen($input) !== 44) {
return false;
}
$digits = array_map('intval', str_split($input));
$w = [];
for ($i = 0, $z = 5, $m = 43; $i <= $m; ++$i) {
$z = $i < $m ? 1 == ($z - 1) ? 9 : ($z - 1) : 0;
$z = $i < $m ? ($z - 1) == 1 ? 9 : ($z - 1) : 0;
$w[] = $z;
}
@ -50,7 +50,7 @@ class NfeAccessKey extends AbstractRule
}
$s -= 11 * floor($s / 11);
$v = 0 == $s || 1 == $s ? 0 : (11 - $s);
$v = $s == 0 || $s == 1 ? 0 : (11 - $s);
return $v == $digits[43];
}

View file

@ -56,11 +56,11 @@ final class Nif extends AbstractRule
private function validateNie(string $prefix, string $number, string $control): bool
{
if ('Y' === $prefix) {
if ($prefix === 'Y') {
return $this->validateDni((int) ('1'.$number), $control);
}
if ('Z' === $prefix) {
if ($prefix === 'Z') {
return $this->validateDni((int) ('2'.$number), $control);
}
@ -74,7 +74,7 @@ final class Nif extends AbstractRule
/** @var int $digit */
foreach (str_split($number) as $digit) {
$increaser = $digit;
if (0 !== $position % 2) {
if ($position % 2 !== 0) {
$increaser = array_sum(str_split((string) ($digit * 2)));
}
@ -84,7 +84,7 @@ final class Nif extends AbstractRule
$digits = str_split((string) $code);
$lastDigit = (int) array_pop($digits);
$key = 0 === $lastDigit ? 0 : (10 - $lastDigit);
$key = $lastDigit === 0 ? 0 : (10 - $lastDigit);
if (is_numeric($control)) {
return (int) $key === (int) $control;

View file

@ -36,7 +36,7 @@ final class NoWhitespace extends AbstractRule
return true;
}
if (false === is_scalar($input)) {
if (is_scalar($input) === false) {
return false;
}

View file

@ -45,7 +45,7 @@ class Not extends AbstractRule
*/
public function validate($input): bool
{
return false === $this->rule->validate($input);
return $this->rule->validate($input) === false;
}
/**

View file

@ -34,7 +34,7 @@ final class NotBlank extends AbstractRule
public function validate($input): bool
{
if (is_numeric($input)) {
return 0 != $input;
return $input != 0;
}
if (is_string($input)) {

View file

@ -162,6 +162,6 @@ final class NotEmoji extends AbstractRule
return false;
}
return 0 === preg_match('/'.implode('|', self::GROUPS).'/mu', $input);
return preg_match('/'.implode('|', self::GROUPS).'/mu', $input) === 0;
}
}

View file

@ -32,6 +32,6 @@ final class NotOptional extends AbstractRule
*/
public function validate($input): bool
{
return false === $this->isUndefined($input);
return $this->isUndefined($input) === false;
}
}

View file

@ -25,7 +25,7 @@ final class Nullable extends AbstractWrapper
*/
public function assert($input): void
{
if (null === $input) {
if ($input === null) {
return;
}
@ -37,7 +37,7 @@ final class Nullable extends AbstractWrapper
*/
public function check($input): void
{
if (null === $input) {
if ($input === null) {
return;
}
@ -49,7 +49,7 @@ final class Nullable extends AbstractWrapper
*/
public function validate($input): bool
{
if (null === $input) {
if ($input === null) {
return true;
}

View file

@ -38,6 +38,6 @@ final class Odd extends AbstractRule
return false;
}
return 0 !== (int) $input % 2;
return (int) $input % 2 !== 0;
}
}

View file

@ -54,7 +54,7 @@ class OneOf extends AbstractComposite
++$rulesPassedCount;
}
return 1 === $rulesPassedCount;
return $rulesPassedCount === 1;
}
/**
@ -74,7 +74,7 @@ class OneOf extends AbstractComposite
}
}
if (1 === $rulesPassedCount) {
if ($rulesPassedCount === 1) {
return;
}

View file

@ -37,7 +37,7 @@ final class Pis extends AbstractRule
}
$digits = preg_replace('/\D/', '', $input);
if (11 != mb_strlen($digits) || preg_match("/^{$digits[0]}{11}$/", $digits)) {
if (mb_strlen($digits) != 11 || preg_match("/^{$digits[0]}{11}$/", $digits)) {
return false;
}

View file

@ -37,12 +37,12 @@ final class PrimeNumber extends AbstractRule
return false;
}
if (2 != $input && 0 == ($input % 2)) {
if ($input != 2 && ($input % 2) == 0) {
return false;
}
for ($i = 3; $i <= ceil(sqrt((float) $input)); $i += 2) {
if (0 == ($input % $i)) {
if (($input % $i) == 0) {
return false;
}
}

View file

@ -58,11 +58,11 @@ final class Sf extends AbstractRule
{
/** @var ConstraintViolationList $violations */
$violations = $this->validator->validate($input, $this->constraint);
if (0 === $violations->count()) {
if ($violations->count() === 0) {
return;
}
if (1 === $violations->count()) {
if ($violations->count() === 1) {
throw $this->reportError($input, ['violations' => $violations[0]->getMessage()]);
}

View file

@ -81,11 +81,11 @@ class Size extends AbstractRule
private function isValidSize(float $size): bool
{
if (null !== $this->minValue && null !== $this->maxValue) {
if ($this->minValue !== null && $this->maxValue !== null) {
return $size >= $this->minValue && $size <= $this->maxValue;
}
if (null !== $this->minValue) {
if ($this->minValue !== null) {
return $size >= $this->minValue;
}

View file

@ -60,7 +60,7 @@ class StartsWith extends AbstractRule
return reset($input) == $this->startValue;
}
return 0 === mb_stripos($input, $this->startValue, 0, mb_detect_encoding($input));
return mb_stripos($input, $this->startValue, 0, mb_detect_encoding($input)) === 0;
}
/**
@ -72,6 +72,6 @@ class StartsWith extends AbstractRule
return reset($input) === $this->startValue;
}
return 0 === mb_strpos($input, $this->startValue, 0, mb_detect_encoding($input));
return mb_strpos($input, $this->startValue, 0, mb_detect_encoding($input)) === 0;
}
}

View file

@ -48,6 +48,6 @@ final class Subset extends AbstractRule
return false;
}
return [] === array_diff($input, $this->superset);
return array_diff($input, $this->superset) === [];
}
}

View file

@ -30,6 +30,6 @@ final class TrueVal extends AbstractRule
*/
public function validate($input): bool
{
return true === filter_var($input, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
return filter_var($input, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) === true;
}
}

View file

@ -80,7 +80,7 @@ final class Type extends AbstractRule
*/
public function validate($input): bool
{
if ('callable' === $this->type) {
if ($this->type === 'callable') {
return is_callable($input);
}

View file

@ -48,7 +48,7 @@ final class Uuid extends AbstractRule
*/
public function __construct(int $version = null)
{
if (null !== $version && !$this->isSupportedVersion($version)) {
if ($version !== null && !$this->isSupportedVersion($version)) {
throw new ComponentException(sprintf('Only versions 1, 3, 4, and 5 are supported: %d given', $version));
}
@ -69,12 +69,12 @@ final class Uuid extends AbstractRule
private function isSupportedVersion(int $version): bool
{
return $version >= 1 && $version <= 5 && 2 !== $version;
return $version >= 1 && $version <= 5 && $version !== 2;
}
private function getPattern(): string
{
if (null !== $this->version) {
if ($this->version !== null) {
return sprintf(self::PATTERN_FORMAT, $this->version);
}

View file

@ -50,7 +50,7 @@ final class VideoUrl extends AbstractRule
*/
public function __construct(string $service = null)
{
if (null !== $service && !$this->isSupportedService($service)) {
if ($service !== null && !$this->isSupportedService($service)) {
throw new ComponentException(sprintf('"%s" is not a recognized video service.', $service));
}
@ -66,7 +66,7 @@ final class VideoUrl extends AbstractRule
return false;
}
if (null !== $this->service) {
if ($this->service !== null) {
return $this->isValid($this->service, $input);
}

View file

@ -45,7 +45,7 @@ final class When extends AbstractRule
{
$this->when = $when;
$this->then = $then;
if (null === $else) {
if ($else === null) {
$else = new AlwaysInvalid();
$else->setTemplate(AlwaysInvalidException::SIMPLE);
}

View file

@ -59,7 +59,7 @@ class Zend extends AbstractRule
*/
private function createZendValidator(string $name, array $params): ZendValidator
{
$name = false === mb_stripos($name, 'Zend') ? "Zend\\Validator\\{$name}" : "\\{$name}";
$name = mb_stripos($name, 'Zend') === false ? "Zend\\Validator\\{$name}" : "\\{$name}";
$reflection = new ReflectionClass($name);

View file

@ -184,7 +184,7 @@ final class Validator extends AllOf
try {
parent::check($input);
} catch (ValidationException $exception) {
if (1 == count($this->getRules()) && $this->template) {
if (count($this->getRules()) == 1 && $this->template) {
$exception->updateTemplate($this->template);
}

View file

@ -54,6 +54,7 @@
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch" />
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison" />
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit" />
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses" />
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses" />

View file

@ -41,7 +41,7 @@ class CheckExceptionsTest extends TestCase
}
$ruleName = mb_substr($fileInfo->getBasename(), 0, -4);
if (('php' !== $fileInfo->getExtension())) {
if (($fileInfo->getExtension() !== 'php')) {
continue;
}

View file

@ -43,7 +43,7 @@ final class UploadedTest extends RuleTestCase
uopz_set_return(
'is_uploaded_file',
static function (string $filename): bool {
if (UploadedTest::UPLOADED_FILENAME === $filename) {
if ($filename === UploadedTest::UPLOADED_FILENAME) {
return true;
}