Skip to content

Commit 00b17c4

Browse files
Merge branch '3.4'
* 3.4: [CS][2.7] yoda_style, no_unneeded_curly_braces, no_unneeded_final_method, semicolon_after_instruction Reset stopwatch. [Filesystem] mirror - fix copying content with same name as source/target. Removed unnecessary getDefinition() call. .php_cs.dist - simplify config [WebProfilerBundle] fixed TemplateManager when using Twig 2 without compat interfaces
2 parents a9d7f57 + ebb41ae commit 00b17c4

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

Encoder/XmlEncoder.php

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

104104
$rootNode = null;
105105
foreach ($dom->childNodes as $child) {
106-
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
106+
if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
107107
throw new UnexpectedValueException('Document types are not allowed.');
108108
}
109-
if (!$rootNode && $child->nodeType !== XML_PI_NODE) {
109+
if (!$rootNode && XML_PI_NODE !== $child->nodeType) {
110110
$rootNode = $child;
111111
}
112112
}
@@ -349,7 +349,7 @@ private function parseXmlValue(\DOMNode $node, array $context = array())
349349
$value = array();
350350

351351
foreach ($node->childNodes as $subnode) {
352-
if ($subnode->nodeType === XML_PI_NODE) {
352+
if (XML_PI_NODE === $subnode->nodeType) {
353353
continue;
354354
}
355355

@@ -398,7 +398,7 @@ private function buildXml(\DOMNode $parentNode, $data, $xmlRootNodeName = null)
398398
$data = $this->serializer->normalize($data, $this->format, $this->context);
399399
}
400400
$parentNode->setAttribute($attributeName, $data);
401-
} elseif ($key === '#') {
401+
} elseif ('#' === $key) {
402402
$append = $this->selectNodeType($parentNode, $data);
403403
} elseif (is_array($data) && false === is_numeric($key)) {
404404
// Is this array fully numeric keys?

Normalizer/AbstractNormalizer.php

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

330-
$allowed = $allowedAttributes === false || in_array($paramName, $allowedAttributes);
330+
$allowed = false === $allowedAttributes || in_array($paramName, $allowedAttributes);
331331
$ignored = !$this->isAllowedAttribute($class, $paramName, $format, $context);
332332
if ($constructorParameter->isVariadic()) {
333333
if ($allowed && !$ignored && (isset($data[$key]) || array_key_exists($key, $data))) {

Normalizer/AbstractObjectNormalizer.php

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

190-
if (($allowedAttributes !== false && !in_array($attribute, $allowedAttributes)) || !$this->isAllowedAttribute($class, $attribute, $format, $context)) {
190+
if ((false !== $allowedAttributes && !in_array($attribute, $allowedAttributes)) || !$this->isAllowedAttribute($class, $attribute, $format, $context)) {
191191
if (isset($context[self::ALLOW_EXTRA_ATTRIBUTES]) && !$context[self::ALLOW_EXTRA_ATTRIBUTES]) {
192192
$extraAttributes[] = $attribute;
193193
}

Normalizer/ArrayDenormalizer.php

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

@@ -66,7 +66,7 @@ public function denormalize($data, $class, $format = null, array $context = arra
6666
*/
6767
public function supportsDenormalization($data, $type, $format = null, array $context = array())
6868
{
69-
return substr($type, -2) === '[]'
69+
return '[]' === substr($type, -2)
7070
&& $this->serializer->supportsDenormalization($data, substr($type, 0, -2), $format, $context);
7171
}
7272

Normalizer/ObjectNormalizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function extractAttributes($object, $format = null, array $context = a
4949
$reflClass = new \ReflectionClass($object);
5050
foreach ($reflClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflMethod) {
5151
if (
52-
$reflMethod->getNumberOfRequiredParameters() !== 0 ||
52+
0 !== $reflMethod->getNumberOfRequiredParameters() ||
5353
$reflMethod->isStatic() ||
5454
$reflMethod->isConstructor() ||
5555
$reflMethod->isDestructor()
@@ -67,7 +67,7 @@ protected function extractAttributes($object, $format = null, array $context = a
6767
if (!$reflClass->hasProperty($attributeName)) {
6868
$attributeName = lcfirst($attributeName);
6969
}
70-
} elseif (strpos($name, 'is') === 0) {
70+
} elseif (0 === strpos($name, 'is')) {
7171
// issers
7272
$attributeName = substr($name, 2);
7373

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)