Passed
Pull Request — master (#1469)
by Asmir
10:45 queued 08:33
created
src/Construction/DoctrineObjectConstructor.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     {
69 69
         $objectManager = $this->managerRegistry->getManagerForClass($metadata->name);
70 70
 
71
-        if (!$objectManager) {
71
+        if ( ! $objectManager) {
72 72
             // No ObjectManager found, proceed with normal deserialization
73 73
             return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
74 74
         }
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
         }
83 83
 
84 84
         // Managed entity, check for proxy load
85
-        if (!is_array($data) && !(is_object($data) && 'SimpleXMLElement' === get_class($data))) {
85
+        if ( ! is_array($data) && ! (is_object($data) && 'SimpleXMLElement' === get_class($data))) {
86 86
             \assert($objectManager instanceof EntityManagerInterface || $objectManager instanceof DocumentManagerInterface);
87 87
 
88 88
             // Single identifier, load proxy
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
         foreach ($classMetadata->getIdentifierFieldNames() as $name) {
97 97
             // Avoid calling objectManager->find if some identification properties are excluded
98
-            if (!isset($metadata->propertyMetadata[$name])) {
98
+            if ( ! isset($metadata->propertyMetadata[$name])) {
99 99
                 return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
100 100
             }
101 101
 
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
                 return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
107 107
             }
108 108
 
109
-            if (is_array($data) && !array_key_exists($propertyMetadata->serializedName, $data)) {
109
+            if (is_array($data) && ! array_key_exists($propertyMetadata->serializedName, $data)) {
110 110
                 return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
111
-            } elseif (is_object($data) && !property_exists($data, $propertyMetadata->serializedName)) {
111
+            } elseif (is_object($data) && ! property_exists($data, $propertyMetadata->serializedName)) {
112 112
                 return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
113 113
             }
114 114
 
Please login to merge, or discard this patch.
src/XmlDeserializationVisitor.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
         if (false !== stripos($data, '<!doctype')) {
87 87
             $internalSubset = $this->getDomDocumentTypeEntitySubset($data);
88
-            if (!in_array($internalSubset, $this->doctypeAllowList, true)) {
88
+            if ( ! in_array($internalSubset, $this->doctypeAllowList, true)) {
89 89
                 throw new InvalidArgumentException(sprintf(
90 90
                     'The document type "%s" is not allowed. If it is safe, you may add it to the allowlist configuration.',
91 91
                     $internalSubset
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
             $nodes = $data->xpath($entryName);
220 220
         }
221 221
 
222
-        if (null === $nodes || !\count($nodes)) {
222
+        if (null === $nodes || ! \count($nodes)) {
223 223
             return [];
224 224
         }
225 225
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
                 $nodes = $data->children($namespace)->$entryName;
248 248
                 foreach ($nodes as $v) {
249 249
                     $attrs = $v->attributes();
250
-                    if (!isset($attrs[$this->currentMetadata->xmlKeyAttribute])) {
250
+                    if ( ! isset($attrs[$this->currentMetadata->xmlKeyAttribute])) {
251 251
                         throw new RuntimeException(sprintf('The key attribute "%s" must be set for each entry of the map.', $this->currentMetadata->xmlKeyAttribute));
252 252
                     }
253 253
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                 return (string) $data->attributes($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName};
278 278
 
279 279
             // Check XML element with namespace for discriminatorFieldName
280
-            case !$metadata->xmlDiscriminatorAttribute && null !== $metadata->xmlDiscriminatorNamespace && isset($data->children($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName}):
280
+            case ! $metadata->xmlDiscriminatorAttribute && null !== $metadata->xmlDiscriminatorNamespace && isset($data->children($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName}):
281 281
                 return (string) $data->children($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName};
282 282
 
283 283
             // Check XML element for discriminatorFieldName
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
         $name = $metadata->serializedName;
308 308
 
309 309
         if (true === $metadata->inline) {
310
-            if (!$metadata->type) {
310
+            if ( ! $metadata->type) {
311 311
                 throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name);
312 312
             }
313 313
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
         if ($metadata->xmlAttribute) {
318 318
             $attributes = $data->attributes($metadata->xmlNamespace);
319 319
             if (isset($attributes[$name])) {
320
-                if (!$metadata->type) {
320
+                if ( ! $metadata->type) {
321 321
                     throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name);
322 322
                 }
323 323
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
         }
329 329
 
330 330
         if ($metadata->xmlValue) {
331
-            if (!$metadata->type) {
331
+            if ( ! $metadata->type) {
332 332
                 throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name);
333 333
             }
334 334
 
@@ -337,12 +337,12 @@  discard block
 block discarded – undo
337 337
 
338 338
         if ($metadata->xmlCollection) {
339 339
             $enclosingElem = $data;
340
-            if (!$metadata->xmlCollectionInline) {
340
+            if ( ! $metadata->xmlCollectionInline) {
341 341
                 $enclosingElem = $data->children($metadata->xmlNamespace)->$name;
342 342
             }
343 343
 
344 344
             $this->setCurrentMetadata($metadata);
345
-            if (!$metadata->type) {
345
+            if ( ! $metadata->type) {
346 346
                 throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name);
347 347
             }
348 348
 
@@ -354,13 +354,13 @@  discard block
 block discarded – undo
354 354
 
355 355
         if ($metadata->xmlNamespace) {
356 356
             $node = $data->children($metadata->xmlNamespace)->$name;
357
-            if (!$node->count()) {
357
+            if ( ! $node->count()) {
358 358
                 throw new NotAcceptableException();
359 359
             }
360 360
         } elseif ('' === $metadata->xmlNamespace) {
361 361
             // See #1087 - element must be like: <element xmlns="" /> - https://www.w3.org/TR/REC-xml-names/#iri-use
362 362
             // Use of an empty string in a namespace declaration turns it into an "undeclaration".
363
-            $nodes = $data->xpath('./' . $name);
363
+            $nodes = $data->xpath('./'.$name);
364 364
             if (empty($nodes)) {
365 365
                 throw new NotAcceptableException();
366 366
             }
@@ -371,9 +371,9 @@  discard block
 block discarded – undo
371 371
             if (isset($namespaces[''])) {
372 372
                 $prefix = uniqid('ns-');
373 373
                 $data->registerXPathNamespace($prefix, $namespaces['']);
374
-                $nodes = $data->xpath('./' . $prefix . ':' . $name);
374
+                $nodes = $data->xpath('./'.$prefix.':'.$name);
375 375
             } else {
376
-                $nodes = $data->xpath('./' . $name);
376
+                $nodes = $data->xpath('./'.$name);
377 377
             }
378 378
 
379 379
             if (empty($nodes)) {
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
             $this->setCurrentMetadata($metadata);
388 388
         }
389 389
 
390
-        if (!$metadata->type) {
390
+        if ( ! $metadata->type) {
391 391
             throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name);
392 392
         }
393 393
 
Please login to merge, or discard this patch.
src/Metadata/Driver/DocBlockDriver/DocBlockTypeResolver.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -84,25 +84,25 @@  discard block
 block discarded – undo
84 84
         if ($type instanceof ArrayTypeNode) {
85 85
             $resolvedType = $this->resolveTypeFromTypeNode($type->type, $reflectionProperty);
86 86
 
87
-            return 'array<' . $resolvedType . '>';
87
+            return 'array<'.$resolvedType.'>';
88 88
         }
89 89
 
90 90
         // Generic array syntax: array<Product> | array<\Foo\Bar\Product> | array<int,Product>
91 91
         if ($type instanceof GenericTypeNode) {
92 92
             if ($this->isSimpleType($type->type, 'array')) {
93
-                $resolvedTypes = array_map(function (TypeNode $node) use ($reflectionProperty) {
93
+                $resolvedTypes = array_map(function(TypeNode $node) use ($reflectionProperty) {
94 94
                     return $this->resolveTypeFromTypeNode($node, $reflectionProperty);
95 95
                 }, $type->genericTypes);
96 96
 
97
-                return 'array<' . implode(',', $resolvedTypes) . '>';
97
+                return 'array<'.implode(',', $resolvedTypes).'>';
98 98
             }
99 99
 
100 100
             if ($this->isSimpleType($type->type, 'list')) {
101
-                $resolvedTypes = array_map(function (TypeNode $node) use ($reflectionProperty) {
101
+                $resolvedTypes = array_map(function(TypeNode $node) use ($reflectionProperty) {
102 102
                     return $this->resolveTypeFromTypeNode($node, $reflectionProperty);
103 103
                 }, $type->genericTypes);
104 104
 
105
-                return 'array<int, ' . implode(',', $resolvedTypes) . '>';
105
+                return 'array<int, '.implode(',', $resolvedTypes).'>';
106 106
             }
107 107
 
108 108
             throw new \InvalidArgumentException(sprintf("Can't use non-array generic type %s for collection in %s:%s", (string) $type->type, $reflectionProperty->getDeclaringClass()->getName(), $reflectionProperty->getName()));
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
             return [];
126 126
         }
127 127
 
128
-        return array_merge(...array_map(static function (VarTagValueNode $node) {
128
+        return array_merge(...array_map(static function(VarTagValueNode $node) {
129 129
             if ($node->type instanceof UnionTypeNode) {
130 130
                 return $node->type->types;
131 131
             }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      */
170 170
     private function filterNullFromTypes(array $types): array
171 171
     {
172
-        return array_values(array_filter(array_map(function (TypeNode $node) {
172
+        return array_values(array_filter(array_map(function(TypeNode $node) {
173 173
             return $this->isNullType($node) ? null : $node;
174 174
         }, $types)));
175 175
     }
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
      */
213 213
     private function resolveTypeFromTypeNode(TypeNode $typeNode, \ReflectionProperty $reflectionProperty): string
214 214
     {
215
-        if (!($typeNode instanceof IdentifierTypeNode)) {
215
+        if ( ! ($typeNode instanceof IdentifierTypeNode)) {
216 216
             throw new \InvalidArgumentException(sprintf("Can't use unsupported type %s for collection in %s:%s", (string) $typeNode, $reflectionProperty->getDeclaringClass()->getName(), $reflectionProperty->getName()));
217 217
         }
218 218
 
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
             return $typeHint;
226 226
         }
227 227
 
228
-        $expandedClassName = $declaringClass->getNamespaceName() . '\\' . $typeHint;
228
+        $expandedClassName = $declaringClass->getNamespaceName().'\\'.$typeHint;
229 229
         if ($this->isClassOrInterface($expandedClassName)) {
230 230
             return $expandedClassName;
231 231
         }
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 
260 260
     private function endsWith(string $statementClassToCheck, string $typeHintToSearchFor): bool
261 261
     {
262
-        $typeHintToSearchFor = '\\' . $typeHintToSearchFor;
262
+        $typeHintToSearchFor = '\\'.$typeHintToSearchFor;
263 263
 
264 264
         return substr($statementClassToCheck, -strlen($typeHintToSearchFor)) === $typeHintToSearchFor;
265 265
     }
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         preg_match_all(self::GROUP_USE_STATEMENTS_REGEX, $classContents, $foundGroupUseStatements);
281 281
         for ($useStatementIndex = 0; $useStatementIndex < count($foundGroupUseStatements[0]); $useStatementIndex++) {
282 282
             foreach (explode(',', $foundGroupUseStatements[2][$useStatementIndex]) as $singleUseStatement) {
283
-                $foundUseStatements[] = trim($foundGroupUseStatements[1][$useStatementIndex]) . trim($singleUseStatement);
283
+                $foundUseStatements[] = trim($foundGroupUseStatements[1][$useStatementIndex]).trim($singleUseStatement);
284 284
             }
285 285
         }
286 286
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 
314 314
     private function resolveType(string $typeHint, \ReflectionProperty $reflectionProperty): string
315 315
     {
316
-        if (!$this->hasGlobalNamespacePrefix($typeHint) && !$this->isPrimitiveType($typeHint)) {
316
+        if ( ! $this->hasGlobalNamespacePrefix($typeHint) && ! $this->isPrimitiveType($typeHint)) {
317 317
             $typeHint = $this->expandClassNameUsingUseStatements($typeHint, $this->getDeclaringClassOrTrait($reflectionProperty), $reflectionProperty);
318 318
         }
319 319
 
@@ -328,15 +328,15 @@  discard block
 block discarded – undo
328 328
     private function resolveTypeFromDocblock(\ReflectionProperty $reflectionProperty): array
329 329
     {
330 330
         $docComment = $reflectionProperty->getDocComment();
331
-        if (!$docComment && PHP_VERSION_ID >= 80000 && $reflectionProperty->isPromoted()) {
331
+        if ( ! $docComment && PHP_VERSION_ID >= 80000 && $reflectionProperty->isPromoted()) {
332 332
             $constructor = $reflectionProperty->getDeclaringClass()->getConstructor();
333
-            if (!$constructor) {
333
+            if ( ! $constructor) {
334 334
                 return [];
335 335
             }
336 336
 
337 337
             $docComment = $constructor->getDocComment();
338 338
 
339
-            if (!$docComment) {
339
+            if ( ! $docComment) {
340 340
                 return [];
341 341
             }
342 342
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
             return $this->flattenParamTagValueTypes($reflectionProperty->getName(), $phpDocNode->getParamTagValues());
347 347
         }
348 348
 
349
-        if (!$docComment) {
349
+        if ( ! $docComment) {
350 350
             return [];
351 351
         }
352 352
 
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 
382 382
                     return sprintf('array<%s>', implode(
383 383
                         ',',
384
-                        array_map(static function (string $type) use ($reflectionProperty, $self) {
384
+                        array_map(static function(string $type) use ($reflectionProperty, $self) {
385 385
                             return $self->resolveType(trim($type), $reflectionProperty);
386 386
                         }, $types)
387 387
                     ));
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
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     public function loadMetadataForClass(\ReflectionClass $class): ?BaseClassMetadata
72 72
     {
73 73
         $classMetadata = new ClassMetadata($name = $class->name);
74
-        $fileResource =  $class->getFilename();
74
+        $fileResource = $class->getFilename();
75 75
 
76 76
         if (false !== $fileResource) {
77 77
             $classMetadata->fileResources[] = $fileResource;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             }
154 154
         }
155 155
 
156
-        if (!$excludeAll) {
156
+        if ( ! $excludeAll) {
157 157
             foreach ($class->getProperties() as $property) {
158 158
                 if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) {
159 159
                     continue;
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
                     } elseif ($annot instanceof Expose) {
186 186
                         $isExpose = true;
187 187
                         if (null !== $annot->if) {
188
-                            $propertyMetadata->excludeIf = $this->parseExpression('!(' . $annot->if . ')');
188
+                            $propertyMetadata->excludeIf = $this->parseExpression('!('.$annot->if.')');
189 189
                         }
190 190
                     } elseif ($annot instanceof Exclude) {
191 191
                         if (null !== $annot->if) {
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
                                 throw new InvalidMetadataException(sprintf(
233 233
                                     'Invalid group name "%s" on "%s", did you mean to create multiple groups?',
234 234
                                     implode(', ', $propertyMetadata->groups),
235
-                                    $propertyMetadata->class . '->' . $propertyMetadata->name
235
+                                    $propertyMetadata->class.'->'.$propertyMetadata->name
236 236
                                 ));
237 237
                             }
238 238
                         }
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
                     }
255 255
                 }
256 256
 
257
-                if (!$propertyMetadata->serializedName) {
257
+                if ( ! $propertyMetadata->serializedName) {
258 258
                     $propertyMetadata->serializedName = $this->namingStrategy->translateName($propertyMetadata);
259 259
                 }
260 260
 
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
                 }
266 266
 
267 267
                 if (
268
-                    (ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude)
268
+                    (ExclusionPolicy::NONE === $exclusionPolicy && ! $isExclude)
269 269
                     || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose)
270 270
                 ) {
271 271
                     $propertyMetadata->setAccessor($accessType, $accessor[0], $accessor[1]);
Please login to merge, or discard this patch.
src/Metadata/Driver/AttributeDriver.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     protected function getClassAnnotations(\ReflectionClass $class): array
13 13
     {
14 14
         return array_map(
15
-            static function (\ReflectionAttribute $attribute): object {
15
+            static function(\ReflectionAttribute $attribute): object {
16 16
                 return $attribute->newInstance();
17 17
             },
18 18
             $class->getAttributes()
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     protected function getMethodAnnotations(\ReflectionMethod $method): array
26 26
     {
27 27
         return array_map(
28
-            static function (\ReflectionAttribute $attribute): object {
28
+            static function(\ReflectionAttribute $attribute): object {
29 29
                 return $attribute->newInstance();
30 30
             },
31 31
             $method->getAttributes()
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     protected function getPropertyAnnotations(\ReflectionProperty $property): array
39 39
     {
40 40
         return array_map(
41
-            static function (\ReflectionAttribute $attribute): object {
41
+            static function(\ReflectionAttribute $attribute): object {
42 42
                 return $attribute->newInstance();
43 43
             },
44 44
             $property->getAttributes()
Please login to merge, or discard this patch.