Passed
Pull Request — master (#1599)
by
unknown
04:08
created
src/Annotation/Type.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 
22 22
     public function __construct($values = [], $name = null)
23 23
     {
24
-        if ((null !== $name) && !is_string($name) && !(is_object($name) && method_exists($name, '__toString'))) {
24
+        if ((null !== $name) && ! is_string($name) && ! (is_object($name) && method_exists($name, '__toString'))) {
25 25
             throw new \RuntimeException(
26 26
                 'Type must be either string, null or object implements __toString() method.',
27 27
             );
Please login to merge, or discard this patch.
src/Metadata/Driver/AttributeDriver/AttributeReader.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
      */
73 73
     private function buildAnnotation(array $attributes): ?SerializerAttribute
74 74
     {
75
-        if (!isset($attributes[0])) {
75
+        if ( ! isset($attributes[0])) {
76 76
             return null;
77 77
         }
78 78
 
Please login to merge, or discard this patch.
src/Metadata/Driver/AnnotationOrAttributeDriver.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         $configured = false;
82 82
 
83 83
         $classMetadata = new ClassMetadata($name = $class->name);
84
-        $fileResource =  $class->getFilename();
84
+        $fileResource = $class->getFilename();
85 85
 
86 86
         if (false !== $fileResource) {
87 87
             $classMetadata->fileResources[] = $fileResource;
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
             }
168 168
         }
169 169
 
170
-        if (!$excludeAll) {
170
+        if ( ! $excludeAll) {
171 171
             foreach ($class->getProperties() as $property) {
172 172
                 if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) {
173 173
                     continue;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
                     } elseif ($annot instanceof Expose) {
202 202
                         $isExpose = true;
203 203
                         if (null !== $annot->if) {
204
-                            $propertyMetadata->excludeIf = $this->parseExpression('!(' . $annot->if . ')');
204
+                            $propertyMetadata->excludeIf = $this->parseExpression('!('.$annot->if.')');
205 205
                         }
206 206
                     } elseif ($annot instanceof Exclude) {
207 207
                         if (null !== $annot->if) {
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
                                 throw new InvalidMetadataException(sprintf(
249 249
                                     'Invalid group name "%s" on "%s", did you mean to create multiple groups?',
250 250
                                     implode(', ', $propertyMetadata->groups),
251
-                                    $propertyMetadata->class . '->' . $propertyMetadata->name,
251
+                                    $propertyMetadata->class.'->'.$propertyMetadata->name,
252 252
                                 ));
253 253
                             }
254 254
                         }
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
                     }
271 271
                 }
272 272
 
273
-                if (!$propertyMetadata->serializedName) {
273
+                if ( ! $propertyMetadata->serializedName) {
274 274
                     $propertyMetadata->serializedName = $this->namingStrategy->translateName($propertyMetadata);
275 275
                 }
276 276
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
                 }
282 282
 
283 283
                 if (
284
-                    (ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude)
284
+                    (ExclusionPolicy::NONE === $exclusionPolicy && ! $isExclude)
285 285
                     || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose)
286 286
                 ) {
287 287
                     $propertyMetadata->setAccessor($accessType, $accessor[0], $accessor[1]);
Please login to merge, or discard this patch.
src/Accessor/DefaultAccessorStrategy.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@
 block discarded – undo
132 132
 
133 133
         $accessor = $this->writeAccessors[$metadata->class] ?? null;
134 134
         if (null === $accessor) {
135
-            $accessor = \Closure::bind(static function ($o, $name, $value): void {
135
+            $accessor = \Closure::bind(static function($o, $name, $value): void {
136 136
                 $o->$name = $value;
137 137
             }, null, $metadata->class);
138 138
             $this->writeAccessors[$metadata->class] = $accessor;
Please login to merge, or discard this patch.
src/XmlSerializationVisitor.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
     public function createRoot(?ClassMetadata $metadata = null, ?string $rootName = null, ?string $rootNamespace = null, ?string $rootPrefix = null): \DOMElement
106 106
     {
107
-        if (null !== $metadata && !empty($metadata->xmlRootName)) {
107
+        if (null !== $metadata && ! empty($metadata->xmlRootName)) {
108 108
             $rootPrefix = $metadata->xmlRootPrefix;
109 109
             $rootName = $metadata->xmlRootName;
110 110
             $rootNamespace = $metadata->xmlRootNamespace ?: $this->getClassDefaultNamespace($metadata);
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
         $document = $this->getDocument();
118 118
         if ($rootNamespace) {
119
-            $rootNode = $document->createElementNS($rootNamespace, (null !== $rootPrefix ? $rootPrefix . ':' : '') . $rootName);
119
+            $rootNode = $document->createElementNS($rootNamespace, (null !== $rootPrefix ? $rootPrefix.':' : '').$rootName);
120 120
         } else {
121 121
             $rootNode = $document->createElement($rootName);
122 122
         }
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
         $decimalsNumbers = $type['params'][2] ?? null;
191 191
         if (null === $decimalsNumbers) {
192 192
             $parts = explode('.', (string) $dataResult);
193
-            if (count($parts) < 2 || !$parts[1]) {
193
+            if (count($parts) < 2 || ! $parts[1]) {
194 194
                 $decimalsNumbers = 1;
195 195
             }
196 196
         }
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
             $node = $this->navigator->accept($v, $metadata->type);
266 266
             $this->revertCurrentMetadata();
267 267
 
268
-            if (!$node instanceof \DOMCharacterData) {
268
+            if ( ! $node instanceof \DOMCharacterData) {
269 269
                 throw new RuntimeException(sprintf('Unsupported value for XML attribute for %s. Expected character data, but got %s.', $metadata->name, json_encode($v)));
270 270
             }
271 271
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 
277 277
         if (
278 278
             ($metadata->xmlValue && $this->currentNode->childNodes->length > 0)
279
-            || (!$metadata->xmlValue && $this->hasValue)
279
+            || ( ! $metadata->xmlValue && $this->hasValue)
280 280
         ) {
281 281
             throw new RuntimeException(sprintf('If you make use of @XmlValue, all other properties in the class must have the @XmlAttribute annotation. Invalid usage detected in class %s.', $metadata->class));
282 282
         }
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
             $node = $this->navigator->accept($v, $metadata->type);
289 289
             $this->revertCurrentMetadata();
290 290
 
291
-            if (!$node instanceof \DOMCharacterData) {
291
+            if ( ! $node instanceof \DOMCharacterData) {
292 292
                 throw new RuntimeException(sprintf('Unsupported value for property %s::$%s. Expected character data, but got %s.', $metadata->class, $metadata->name, \is_object($node) ? \get_class($node) : \gettype($node)));
293 293
             }
294 294
 
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
         }
299 299
 
300 300
         if ($metadata->xmlAttributeMap) {
301
-            if (!\is_array($v)) {
301
+            if ( ! \is_array($v)) {
302 302
                 throw new RuntimeException(sprintf('Unsupported value type for XML attribute map. Expected array but got %s.', \gettype($v)));
303 303
             }
304 304
 
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
                 $node = $this->navigator->accept($value, null);
308 308
                 $this->revertCurrentMetadata();
309 309
 
310
-                if (!$node instanceof \DOMCharacterData) {
310
+                if ( ! $node instanceof \DOMCharacterData) {
311 311
                     throw new RuntimeException(sprintf('Unsupported value for a XML attribute map value. Expected character data, but got %s.', json_encode($v)));
312 312
                 }
313 313
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
             return;
318 318
         }
319 319
 
320
-        if ($addEnclosingElement = !$this->isInLineCollection($metadata) && !$metadata->inline) {
320
+        if ($addEnclosingElement = ! $this->isInLineCollection($metadata) && ! $metadata->inline) {
321 321
             $namespace = $metadata->xmlNamespace ?? $this->getClassDefaultNamespace($this->objectMetadataStack->top());
322 322
 
323 323
             $element = $this->createElement($metadata->serializedName, $namespace);
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 
361 361
     private function isSkippableEmptyObject(?\DOMElement $node, PropertyMetadata $metadata): bool
362 362
     {
363
-        return null === $node && !$metadata->xmlCollection && $metadata->skipWhenEmpty;
363
+        return null === $node && ! $metadata->xmlCollection && $metadata->skipWhenEmpty;
364 364
     }
365 365
 
366 366
     private function isSkippableCollection(PropertyMetadata $metadata): bool
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 
371 371
     private function isElementEmpty(\DOMElement $element): bool
372 372
     {
373
-        return !$element->hasChildNodes() && !$element->hasAttributes();
373
+        return ! $element->hasChildNodes() && ! $element->hasAttributes();
374 374
     }
375 375
 
376 376
     public function endVisitingObject(ClassMetadata $metadata, object $data, array $type): void
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
         foreach ($metadata->xmlNamespaces as $prefix => $uri) {
476 476
             $attribute = 'xmlns';
477 477
             if ('' !== $prefix) {
478
-                $attribute .= ':' . $prefix;
478
+                $attribute .= ':'.$prefix;
479 479
             } elseif ($element->namespaceURI === $uri) {
480 480
                 continue;
481 481
             }
@@ -505,21 +505,21 @@  discard block
 block discarded – undo
505 505
             return $this->document->createElementNS($namespace, $tagName);
506 506
         }
507 507
 
508
-        if (!($prefix = $this->currentNode->lookupPrefix($namespace)) && !($prefix = $this->document->lookupPrefix($namespace))) {
509
-            $prefix = 'ns-' . substr(sha1($namespace), 0, 8);
508
+        if ( ! ($prefix = $this->currentNode->lookupPrefix($namespace)) && ! ($prefix = $this->document->lookupPrefix($namespace))) {
509
+            $prefix = 'ns-'.substr(sha1($namespace), 0, 8);
510 510
         }
511 511
 
512
-        return $this->document->createElementNS($namespace, $prefix . ':' . $tagName);
512
+        return $this->document->createElementNS($namespace, $prefix.':'.$tagName);
513 513
     }
514 514
 
515 515
     private function setAttributeOnNode(\DOMElement $node, string $name, string $value, ?string $namespace = null): void
516 516
     {
517 517
         if (null !== $namespace) {
518
-            if (!$prefix = $node->lookupPrefix($namespace)) {
519
-                $prefix = 'ns-' . substr(sha1($namespace), 0, 8);
518
+            if ( ! $prefix = $node->lookupPrefix($namespace)) {
519
+                $prefix = 'ns-'.substr(sha1($namespace), 0, 8);
520 520
             }
521 521
 
522
-            $node->setAttributeNS($namespace, $prefix . ':' . $name, $value);
522
+            $node->setAttributeNS($namespace, $prefix.':'.$name, $value);
523 523
         } else {
524 524
             $node->setAttribute($name, $value);
525 525
         }
Please login to merge, or discard this patch.
src/Handler/EnumHandler.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
         array $type,
45 45
         SerializationContext $context
46 46
     ) {
47
-        if ((isset($type['params'][1]) && 'value' === $type['params'][1]) || (!isset($type['params'][1]) && $enum instanceof \BackedEnum)) {
48
-            if (!$enum instanceof \BackedEnum) {
47
+        if ((isset($type['params'][1]) && 'value' === $type['params'][1]) || ( ! isset($type['params'][1]) && $enum instanceof \BackedEnum)) {
48
+            if ( ! $enum instanceof \BackedEnum) {
49 49
                 throw new InvalidMetadataException(sprintf('The type "%s" is not a backed enum, thus you can not use "value" as serialization mode for its value.', get_class($enum)));
50 50
             }
51 51
 
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
         $caseValue = (string) $data;
68 68
 
69 69
         $ref = new \ReflectionEnum($enumType);
70
-        if (isset($type['params'][1]) && 'value' === $type['params'][1] || (!isset($type['params'][1]) && is_a($enumType, \BackedEnum::class, true))) {
71
-            if (!is_a($enumType, \BackedEnum::class, true)) {
70
+        if (isset($type['params'][1]) && 'value' === $type['params'][1] || ( ! isset($type['params'][1]) && is_a($enumType, \BackedEnum::class, true))) {
71
+            if ( ! is_a($enumType, \BackedEnum::class, true)) {
72 72
                 throw new InvalidMetadataException(sprintf('The type "%s" is not a backed enum, thus you can not use "value" as serialization mode for its value.', $enumType));
73 73
             }
74 74
 
75 75
             if ('int' === $ref->getBackingType()->getName()) {
76
-                if (!is_numeric($caseValue)) {
76
+                if ( ! is_numeric($caseValue)) {
77 77
                     throw new RuntimeException(sprintf('"%s" is not a valid backing value for enum "%s"', $caseValue, $enumType));
78 78
                 }
79 79
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
             return $enumType::from($caseValue);
84 84
         } else {
85
-            if (!$ref->hasCase($caseValue)) {
85
+            if ( ! $ref->hasCase($caseValue)) {
86 86
                 throw new InvalidMetadataException(sprintf('The type "%s" does not have the case "%s"', $ref->getName(), $caseValue));
87 87
             }
88 88
 
Please login to merge, or discard this patch.
src/Builder/DefaultDriverFactory.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
     public function createDriver(array $metadataDirs, ?Reader $annotationReader = null): DriverInterface
60 60
     {
61
-        if (PHP_VERSION_ID < 80000 && empty($metadataDirs) && !interface_exists(Reader::class)) {
61
+        if (PHP_VERSION_ID < 80000 && empty($metadataDirs) && ! interface_exists(Reader::class)) {
62 62
             throw new RuntimeException(sprintf('To use "%s", either a list of metadata directories must be provided, the "doctrine/annotations" package installed, or use PHP 8.0 or later.', self::class));
63 63
         }
64 64
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             $metadataDrivers[] = new AnnotationOrAttributeDriver($this->propertyNamingStrategy, $this->typeParser, $this->expressionEvaluator, $annotationReader);
77 77
         }
78 78
 
79
-        if (!empty($metadataDirs)) {
79
+        if ( ! empty($metadataDirs)) {
80 80
             $fileLocator = new FileLocator($metadataDirs);
81 81
 
82 82
             array_unshift($metadataDrivers, new XmlDriver($fileLocator, $this->propertyNamingStrategy, $this->typeParser, $this->expressionEvaluator));
Please login to merge, or discard this patch.
src/Builder/CallbackDriverFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
     public function createDriver(array $metadataDirs, ?Reader $reader = null): DriverInterface
28 28
     {
29 29
         $driver = \call_user_func($this->callback, $metadataDirs, $reader);
30
-        if (!$driver instanceof DriverInterface) {
30
+        if ( ! $driver instanceof DriverInterface) {
31 31
             throw new LogicException('The callback must return an instance of DriverInterface.');
32 32
         }
33 33
 
Please login to merge, or discard this patch.
src/Context.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
             $this->addExclusionStrategy(new VersionExclusionStrategy($this->attributes['version']));
79 79
         }
80 80
 
81
-        if (!empty($this->attributes['max_depth_checks'])) {
81
+        if ( ! empty($this->attributes['max_depth_checks'])) {
82 82
             $this->addExclusionStrategy(new DepthExclusionStrategy());
83 83
         }
84 84
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
     final protected function assertMutable(): void
135 135
     {
136
-        if (!$this->initialized) {
136
+        if ( ! $this->initialized) {
137 137
             return;
138 138
         }
139 139
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     {
223 223
         $metadata = $this->metadataStack->pop();
224 224
 
225
-        if (!$metadata instanceof PropertyMetadata) {
225
+        if ( ! $metadata instanceof PropertyMetadata) {
226 226
             throw new RuntimeException('Context metadataStack not working well');
227 227
         }
228 228
     }
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
     {
232 232
         $metadata = $this->metadataStack->pop();
233 233
 
234
-        if (!$metadata instanceof ClassMetadata) {
234
+        if ( ! $metadata instanceof ClassMetadata) {
235 235
             throw new RuntimeException('Context metadataStack not working well');
236 236
         }
237 237
     }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
     public function getCurrentPath(): array
245 245
     {
246
-        if (!$this->metadataStack) {
246
+        if ( ! $this->metadataStack) {
247 247
             return [];
248 248
         }
249 249
 
Please login to merge, or discard this patch.