Skip to content

Commit 4070c1a

Browse files
Merge branch '2.7' into 2.8
* 2.7: [CS][2.7] yoda_style, no_unneeded_curly_braces, no_unneeded_final_method, semicolon_after_instruction
2 parents b24e3c7 + 213239a commit 4070c1a

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
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/ArrayDenormalizer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ class ArrayDenormalizer implements DenormalizerInterface, SerializerAwareInterfa
3333
*/
3434
public function denormalize($data, $class, $format = null, array $context = array())
3535
{
36-
if ($this->serializer === null) {
36+
if (null === $this->serializer) {
3737
throw new BadMethodCallException('Please set a serializer before calling denormalize()!');
3838
}
3939
if (!is_array($data)) {
4040
throw new InvalidArgumentException('Data expected to be an array, '.gettype($data).' given.');
4141
}
42-
if (substr($class, -2) !== '[]') {
42+
if ('[]' !== substr($class, -2)) {
4343
throw new InvalidArgumentException('Unsupported class: '.$class);
4444
}
4545

@@ -59,7 +59,7 @@ function ($data) use ($serializer, $class, $format, $context) {
5959
*/
6060
public function supportsDenormalization($data, $type, $format = null)
6161
{
62-
return substr($type, -2) === '[]'
62+
return '[]' === substr($type, -2)
6363
&& $this->serializer->supportsDenormalization($data, substr($type, 0, -2), $format);
6464
}
6565

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
@@ -121,7 +121,7 @@ public function denormalize($data, $class, $format = null, array $context = arra
121121
$attribute = $this->nameConverter->denormalize($attribute);
122122
}
123123

124-
$allowed = $allowedAttributes === false || in_array($attribute, $allowedAttributes);
124+
$allowed = false === $allowedAttributes || in_array($attribute, $allowedAttributes);
125125
$ignored = in_array($attribute, $this->ignoredAttributes);
126126

127127
if ($allowed && !$ignored) {
@@ -196,7 +196,7 @@ private function extractAttributes($object)
196196
$reflClass = new \ReflectionClass($object);
197197
foreach ($reflClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflMethod) {
198198
if (
199-
$reflMethod->getNumberOfRequiredParameters() !== 0 ||
199+
0 !== $reflMethod->getNumberOfRequiredParameters() ||
200200
$reflMethod->isStatic() ||
201201
$reflMethod->isConstructor() ||
202202
$reflMethod->isDestructor()
@@ -215,7 +215,7 @@ private function extractAttributes($object)
215215
}
216216

217217
$attributes[$propertyName] = true;
218-
} elseif (strpos($name, 'is') === 0) {
218+
} elseif (0 === strpos($name, 'is')) {
219219
// issers
220220
$propertyName = substr($name, 2);
221221

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)