Skip to content

Commit 9c29356

Browse files
SpacePossumnicolas-grekas
authored andcommitted
[CS][2.7] yoda_style, no_unneeded_curly_braces, no_unneeded_final_method, semicolon_after_instruction
1 parent 3c3bc0b commit 9c29356

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

Constraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function __construct($options = null)
141141
$invalidOptions[] = $option;
142142
}
143143
}
144-
} elseif (null !== $options && !(is_array($options) && count($options) === 0)) {
144+
} elseif (null !== $options && !(is_array($options) && 0 === count($options))) {
145145
$option = $this->getDefaultOption();
146146

147147
if (null === $option) {

Constraints/ChoiceValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function validate($value, Constraint $constraint)
8181

8282
$count = count($value);
8383

84-
if ($constraint->min !== null && $count < $constraint->min) {
84+
if (null !== $constraint->min && $count < $constraint->min) {
8585
if ($this->context instanceof ExecutionContextInterface) {
8686
$this->context->buildViolation($constraint->minMessage)
8787
->setParameter('{{ limit }}', $constraint->min)
@@ -99,7 +99,7 @@ public function validate($value, Constraint $constraint)
9999
return;
100100
}
101101

102-
if ($constraint->max !== null && $count > $constraint->max) {
102+
if (null !== $constraint->max && $count > $constraint->max) {
103103
if ($this->context instanceof ExecutionContextInterface) {
104104
$this->context->buildViolation($constraint->maxMessage)
105105
->setParameter('{{ limit }}', $constraint->max)

Constraints/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected function initializeNestedConstraints()
6363
foreach ($this->fields as $fieldName => $field) {
6464
// the XmlFileLoader and YamlFileLoader pass the field Optional
6565
// and Required constraint as an array with exactly one element
66-
if (is_array($field) && count($field) == 1) {
66+
if (is_array($field) && 1 == count($field)) {
6767
$this->fields[$fieldName] = $field = $field[0];
6868
}
6969

Constraints/ImageValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function validate($value, Constraint $constraint)
5353

5454
$size = @getimagesize($value);
5555

56-
if (empty($size) || ($size[0] === 0) || ($size[1] === 0)) {
56+
if (empty($size) || (0 === $size[0]) || (0 === $size[1])) {
5757
if ($this->context instanceof ExecutionContextInterface) {
5858
$this->context->buildViolation($constraint->sizeNotDetectedMessage)
5959
->setCode(Image::SIZE_NOT_DETECTED_ERROR)

Constraints/TypeValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function validate($value, Constraint $constraint)
3535
}
3636

3737
$type = strtolower($constraint->type);
38-
$type = $type == 'boolean' ? 'bool' : $constraint->type;
38+
$type = 'boolean' == $type ? 'bool' : $constraint->type;
3939
$isFunction = 'is_'.$type;
4040
$ctypeFunction = 'ctype_'.$type;
4141

Constraints/UuidValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ private function validateStrict($value, Uuid $constraint)
327327
// 0b10xx
328328
// & 0b1100 (12)
329329
// = 0b1000 (8)
330-
if ((hexdec($value[self::STRICT_VARIANT_POSITION]) & 12) !== 8) {
330+
if (8 !== (hexdec($value[self::STRICT_VARIANT_POSITION]) & 12)) {
331331
if ($this->context instanceof ExecutionContextInterface) {
332332
$this->context->buildViolation($constraint->message)
333333
->setParameter('{{ value }}', $this->formatValue($value))

Mapping/Loader/AbstractLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ protected function addNamespaceAlias($alias, $namespace)
7272
*/
7373
protected function newConstraint($name, $options = null)
7474
{
75-
if (strpos($name, '\\') !== false && class_exists($name)) {
75+
if (false !== strpos($name, '\\') && class_exists($name)) {
7676
$className = (string) $name;
77-
} elseif (strpos($name, ':') !== false) {
77+
} elseif (false !== strpos($name, ':')) {
7878
list($prefix, $className) = explode(':', $name, 2);
7979

8080
if (!isset($this->namespaces[$prefix])) {

0 commit comments

Comments
 (0)