Skip to content

Commit ebb41ae

Browse files
Merge branch '3.3' into 3.4
* 3.3: [CS][2.7] yoda_style, no_unneeded_curly_braces, no_unneeded_final_method, semicolon_after_instruction [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 e1d646e + e64ad61 commit ebb41ae

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
@@ -99,10 +99,10 @@ public function decode($data, $format, array $context = array())
9999

100100
$rootNode = null;
101101
foreach ($dom->childNodes as $child) {
102-
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
102+
if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
103103
throw new UnexpectedValueException('Document types are not allowed.');
104104
}
105-
if (!$rootNode && $child->nodeType !== XML_PI_NODE) {
105+
if (!$rootNode && XML_PI_NODE !== $child->nodeType) {
106106
$rootNode = $child;
107107
}
108108
}
@@ -345,7 +345,7 @@ private function parseXmlValue(\DOMNode $node, array $context = array())
345345
$value = array();
346346

347347
foreach ($node->childNodes as $subnode) {
348-
if ($subnode->nodeType === XML_PI_NODE) {
348+
if (XML_PI_NODE === $subnode->nodeType) {
349349
continue;
350350
}
351351

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

Normalizer/AbstractNormalizer.php

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

340-
$allowed = $allowedAttributes === false || in_array($paramName, $allowedAttributes);
340+
$allowed = false === $allowedAttributes || in_array($paramName, $allowedAttributes);
341341
$ignored = !$this->isAllowedAttribute($class, $paramName, $format, $context);
342342
if (method_exists($constructorParameter, 'isVariadic') && $constructorParameter->isVariadic()) {
343343
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 DenormalizerInterface, SerializerAwareInterfa
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

@@ -68,7 +68,7 @@ public function supportsDenormalization($data, $type, $format = null/*, array $c
6868
{
6969
$context = func_num_args() > 3 ? func_get_arg(3) : array();
7070

71-
return substr($type, -2) === '[]'
71+
return '[]' === substr($type, -2)
7272
&& $this->serializer->supportsDenormalization($data, substr($type, 0, -2), $format, $context);
7373
}
7474

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)