Skip to content

Commit 213239a

Browse files
SpacePossumnicolas-grekas
authored andcommitted
[CS][2.7] yoda_style, no_unneeded_curly_braces, no_unneeded_final_method, semicolon_after_instruction
1 parent 86dc240 commit 213239a

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

Encoder/XmlEncoder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ public function decode($data, $format, array $context = array())
9494

9595
$rootNode = null;
9696
foreach ($dom->childNodes as $child) {
97-
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
97+
if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
9898
throw new UnexpectedValueException('Document types are not allowed.');
9999
}
100-
if (!$rootNode && $child->nodeType !== XML_PI_NODE) {
100+
if (!$rootNode && XML_PI_NODE !== $child->nodeType) {
101101
$rootNode = $child;
102102
}
103103
}
@@ -339,7 +339,7 @@ private function parseXmlValue(\DOMNode $node)
339339
$value = array();
340340

341341
foreach ($node->childNodes as $subnode) {
342-
if ($subnode->nodeType === XML_PI_NODE) {
342+
if (XML_PI_NODE === $subnode->nodeType) {
343343
continue;
344344
}
345345

@@ -388,7 +388,7 @@ private function buildXml(\DOMNode $parentNode, $data, $xmlRootNodeName = null)
388388
$data = $this->serializer->normalize($data, $this->format, $this->context);
389389
}
390390
$parentNode->setAttribute($attributeName, $data);
391-
} elseif ($key === '#') {
391+
} elseif ('#' === $key) {
392392
$append = $this->selectNodeType($parentNode, $data);
393393
} elseif (is_array($data) && false === is_numeric($key)) {
394394
// Is this array fully numeric keys?

Normalizer/AbstractNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ protected function instantiateObject(array &$data, $class, array &$context, \Ref
325325
$paramName = $constructorParameter->name;
326326
$key = $this->nameConverter ? $this->nameConverter->normalize($paramName) : $paramName;
327327

328-
$allowed = $allowedAttributes === false || in_array($paramName, $allowedAttributes);
328+
$allowed = false === $allowedAttributes || in_array($paramName, $allowedAttributes);
329329
$ignored = in_array($paramName, $this->ignoredAttributes);
330330
if (method_exists($constructorParameter, 'isVariadic') && $constructorParameter->isVariadic()) {
331331
if ($allowed && !$ignored && (isset($data[$key]) || array_key_exists($key, $data))) {

Normalizer/GetSetMethodNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function denormalize($data, $class, $format = null, array $context = arra
108108
$attribute = $this->nameConverter->denormalize($attribute);
109109
}
110110

111-
$allowed = $allowedAttributes === false || in_array($attribute, $allowedAttributes);
111+
$allowed = false === $allowedAttributes || in_array($attribute, $allowedAttributes);
112112
$ignored = in_array($attribute, $this->ignoredAttributes);
113113

114114
if ($allowed && !$ignored) {

Normalizer/ObjectNormalizer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ public function normalize($object, $format = null, array $context = array())
7575
) {
7676
$name = $reflMethod->getName();
7777

78-
if (strpos($name, 'get') === 0 || strpos($name, 'has') === 0) {
78+
if (0 === strpos($name, 'get') || 0 === strpos($name, 'has')) {
7979
// getters and hassers
8080
$attributes[lcfirst(substr($name, 3))] = true;
81-
} elseif (strpos($name, 'is') === 0) {
81+
} elseif (0 === strpos($name, 'is')) {
8282
// issers
8383
$attributes[lcfirst(substr($name, 2))] = true;
8484
}
@@ -148,7 +148,7 @@ public function denormalize($data, $class, $format = null, array $context = arra
148148
$attribute = $this->nameConverter->denormalize($attribute);
149149
}
150150

151-
$allowed = $allowedAttributes === false || in_array($attribute, $allowedAttributes);
151+
$allowed = false === $allowedAttributes || in_array($attribute, $allowedAttributes);
152152
$ignored = in_array($attribute, $this->ignoredAttributes);
153153

154154
if ($allowed && !$ignored) {

Normalizer/PropertyNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function denormalize($data, $class, $format = null, array $context = arra
105105
$propertyName = $this->nameConverter->denormalize($propertyName);
106106
}
107107

108-
$allowed = $allowedAttributes === false || in_array($propertyName, $allowedAttributes);
108+
$allowed = false === $allowedAttributes || in_array($propertyName, $allowedAttributes);
109109
$ignored = in_array($propertyName, $this->ignoredAttributes);
110110
if ($allowed && !$ignored && $reflectionClass->hasProperty($propertyName)) {
111111
$property = $reflectionClass->getProperty($propertyName);

Tests/Fixtures/ScalarDummy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ class ScalarDummy implements NormalizableInterface, DenormalizableInterface
2323

2424
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = array())
2525
{
26-
return $format === 'xml' ? $this->xmlFoo : $this->foo;
26+
return 'xml' === $format ? $this->xmlFoo : $this->foo;
2727
}
2828

2929
public function denormalize(DenormalizerInterface $denormalizer, $data, $format = null, array $context = array())
3030
{
31-
if ($format === 'xml') {
31+
if ('xml' === $format) {
3232
$this->xmlFoo = $data;
3333
} else {
3434
$this->foo = $data;

0 commit comments

Comments
 (0)