Passed
Pull Request — master (#1526)
by
unknown
02:49
created
src/Metadata/Driver/YamlDriver.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public function getAllClassNames(): array
72 72
     {
73
-        if (!$this->locator instanceof AdvancedFileLocatorInterface) {
73
+        if ( ! $this->locator instanceof AdvancedFileLocatorInterface) {
74 74
             throw new RuntimeException(
75 75
                 sprintf(
76 76
                     'Locator "%s" must be an instance of "AdvancedFileLocatorInterface".',
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     {
94 94
         $config = Yaml::parseFile($file, Yaml::PARSE_CONSTANT);
95 95
 
96
-        if (!isset($config[$name = $class->name])) {
96
+        if ( ! isset($config[$name = $class->name])) {
97 97
             throw new InvalidMetadataException(
98 98
                 sprintf('Expected metadata for class %s to be defined in %s.', $class->name, $file)
99 99
             );
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
                     );
131 131
                     unset($propertySettings['exp']);
132 132
                 } else {
133
-                    if (!$class->hasMethod($methodName)) {
133
+                    if ( ! $class->hasMethod($methodName)) {
134 134
                         throw new InvalidMetadataException(
135
-                            'The method ' . $methodName . ' not found in class ' . $class->name
135
+                            'The method '.$methodName.' not found in class '.$class->name
136 136
                         );
137 137
                     }
138 138
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
             }
145 145
         }
146 146
 
147
-        if (!$excludeAll) {
147
+        if ( ! $excludeAll) {
148 148
             foreach ($class->getProperties() as $property) {
149 149
                 if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) {
150 150
                     continue;
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 
153 153
                 $pName = $property->getName();
154 154
                 $propertiesMetadata[] = new PropertyMetadata($name, $pName);
155
-                $propertiesData[] =  !empty($config['properties']) && true === array_key_exists($pName, $config['properties'])
155
+                $propertiesData[] = ! empty($config['properties']) && true === array_key_exists($pName, $config['properties'])
156 156
                     ? (array) $config['properties'][$pName]
157 157
                     : null;
158 158
             }
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
                     || isset($propertiesData[$propertyKey]);
165 165
 
166 166
                 $pConfig = $propertiesData[$propertyKey];
167
-                if (!empty($pConfig)) {
167
+                if ( ! empty($pConfig)) {
168 168
                     if (isset($pConfig['exclude'])) {
169 169
                         $isExclude = (bool) $pConfig['exclude'];
170 170
                     }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
                     }
195 195
 
196 196
                     if (isset($pConfig['expose_if'])) {
197
-                        $pMetadata->excludeIf = $this->parseExpression('!(' . $pConfig['expose_if'] . ')');
197
+                        $pMetadata->excludeIf = $this->parseExpression('!('.$pConfig['expose_if'].')');
198 198
                     }
199 199
 
200 200
                     if (isset($pConfig['serialized_name'])) {
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
                     }
303 303
                 }
304 304
 
305
-                if (!$pMetadata->serializedName) {
305
+                if ( ! $pMetadata->serializedName) {
306 306
                     $pMetadata->serializedName = $this->namingStrategy->translateName($pMetadata);
307 307
                 }
308 308
 
@@ -311,12 +311,12 @@  discard block
 block discarded – undo
311 311
                     $metadata->isMap = $metadata->isMap || PropertyMetadata::isCollectionMap($pMetadata->type);
312 312
                 }
313 313
 
314
-                if (!empty($pConfig) && !empty($pConfig['name'])) {
314
+                if ( ! empty($pConfig) && ! empty($pConfig['name'])) {
315 315
                     $pMetadata->name = (string) $pConfig['name'];
316 316
                 }
317 317
 
318 318
                 if (
319
-                    (ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude)
319
+                    (ExclusionPolicy::NONE === $exclusionPolicy && ! $isExclude)
320 320
                     || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose)
321 321
                 ) {
322 322
                     $metadata->addPropertyMetadata($pMetadata);
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 
362 362
     private function addClassProperties(ClassMetadata $metadata, array $config): void
363 363
     {
364
-        if (isset($config['custom_accessor_order']) && !isset($config['accessor_order'])) {
364
+        if (isset($config['custom_accessor_order']) && ! isset($config['accessor_order'])) {
365 365
             $config['accessor_order'] = 'custom';
366 366
         }
367 367
 
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
             if (isset($config['discriminator']['disabled']) && true === $config['discriminator']['disabled']) {
392 392
                 $metadata->discriminatorDisabled = true;
393 393
             } else {
394
-                if (!isset($config['discriminator']['field_name'])) {
394
+                if ( ! isset($config['discriminator']['field_name'])) {
395 395
                     throw new InvalidMetadataException('The "field_name" attribute must be set for discriminators.');
396 396
                 }
397 397
 
398
-                if (!isset($config['discriminator']['map']) || !is_array($config['discriminator']['map'])) {
398
+                if ( ! isset($config['discriminator']['map']) || ! is_array($config['discriminator']['map'])) {
399 399
                     throw new InvalidMetadataException(
400 400
                         'The "map" attribute must be set, and be an array for discriminators.'
401 401
                     );
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
     {
433 433
         if (is_string($config)) {
434 434
             $config = [$config];
435
-        } elseif (!is_array($config)) {
435
+        } elseif ( ! is_array($config)) {
436 436
             throw new InvalidMetadataException(
437 437
                 sprintf(
438 438
                     'callback methods expects a string, or an array of strings that represent method names, but got %s.',
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 
444 444
         $methods = [];
445 445
         foreach ($config as $name) {
446
-            if (!$class->hasMethod($name)) {
446
+            if ( ! $class->hasMethod($name)) {
447 447
                 throw new InvalidMetadataException(
448 448
                     sprintf('The method %s does not exist in class %s.', $name, $class->name)
449 449
                 );
Please login to merge, or discard this patch.
src/Metadata/Driver/NullDriver.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     public function loadMetadataForClass(\ReflectionClass $class): ?BaseClassMetadata
26 26
     {
27 27
         $classMetadata = new ClassMetadata($name = $class->name);
28
-        $fileResource =  $class->getFilename();
28
+        $fileResource = $class->getFilename();
29 29
         if (false !== $fileResource) {
30 30
             $classMetadata->fileResources[] = $fileResource;
31 31
         }
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
             $propertyMetadata = new PropertyMetadata($name, $property->getName());
39 39
 
40
-            if (!$propertyMetadata->serializedName) {
40
+            if ( ! $propertyMetadata->serializedName) {
41 41
                 $propertyMetadata->serializedName = $this->namingStrategy->translateName($propertyMetadata);
42 42
             }
43 43
 
Please login to merge, or discard this patch.
src/Builder/DefaultDriverFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
          */
68 68
         $metadataDrivers = [new AnnotationOrAttributeDriver($this->propertyNamingStrategy, $this->typeParser, $this->expressionEvaluator, $annotationReader)];
69 69
 
70
-        if (!empty($metadataDirs)) {
70
+        if ( ! empty($metadataDirs)) {
71 71
             $fileLocator = new FileLocator($metadataDirs);
72 72
 
73 73
             array_unshift($metadataDrivers, new XmlDriver($fileLocator, $this->propertyNamingStrategy, $this->typeParser, $this->expressionEvaluator));
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
@@ -109,25 +109,25 @@  discard block
 block discarded – undo
109 109
         if ($type instanceof ArrayTypeNode) {
110 110
             $resolvedType = $this->resolveTypeFromTypeNode($type->type, $reflector);
111 111
 
112
-            return 'array<' . $resolvedType . '>';
112
+            return 'array<'.$resolvedType.'>';
113 113
         }
114 114
 
115 115
         // Generic array syntax: array<Product> | array<\Foo\Bar\Product> | array<int,Product>
116 116
         if ($type instanceof GenericTypeNode) {
117 117
             if ($this->isSimpleType($type->type, 'array')) {
118
-                $resolvedTypes = array_map(function (TypeNode $node) use ($reflector) {
118
+                $resolvedTypes = array_map(function(TypeNode $node) use ($reflector) {
119 119
                     return $this->resolveTypeFromTypeNode($node, $reflector);
120 120
                 }, $type->genericTypes);
121 121
 
122
-                return 'array<' . implode(',', $resolvedTypes) . '>';
122
+                return 'array<'.implode(',', $resolvedTypes).'>';
123 123
             }
124 124
 
125 125
             if ($this->isSimpleType($type->type, 'list')) {
126
-                $resolvedTypes = array_map(function (TypeNode $node) use ($reflector) {
126
+                $resolvedTypes = array_map(function(TypeNode $node) use ($reflector) {
127 127
                     return $this->resolveTypeFromTypeNode($node, $reflector);
128 128
                 }, $type->genericTypes);
129 129
 
130
-                return 'array<int, ' . implode(',', $resolvedTypes) . '>';
130
+                return 'array<int, '.implode(',', $resolvedTypes).'>';
131 131
             }
132 132
 
133 133
             throw new \InvalidArgumentException(sprintf("Can't use non-array generic type %s for collection in %s:%s", (string) $type->type, $reflector->getDeclaringClass()->getName(), $reflector->getName()));
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
             return [];
151 151
         }
152 152
 
153
-        return array_merge(...array_map(static function ($node) {
153
+        return array_merge(...array_map(static function($node) {
154 154
             if ($node->type instanceof UnionTypeNode) {
155 155
                 return $node->type->types;
156 156
             }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
      */
195 195
     private function filterNullFromTypes(array $types): array
196 196
     {
197
-        return array_values(array_filter(array_map(function (TypeNode $node) {
197
+        return array_values(array_filter(array_map(function(TypeNode $node) {
198 198
             return $this->isNullType($node) ? null : $node;
199 199
         }, $types)));
200 200
     }
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
      */
238 238
     private function resolveTypeFromTypeNode(TypeNode $typeNode, $reflector): string
239 239
     {
240
-        if (!($typeNode instanceof IdentifierTypeNode)) {
240
+        if ( ! ($typeNode instanceof IdentifierTypeNode)) {
241 241
             throw new \InvalidArgumentException(sprintf("Can't use unsupported type %s for collection in %s:%s", (string) $typeNode, $reflector->getDeclaringClass()->getName(), $reflector->getName()));
242 242
         }
243 243
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
      */
250 250
     private function expandClassNameUsingUseStatements(string $typeHint, \ReflectionClass $declaringClass, $reflector): string
251 251
     {
252
-        $expandedClassName = $declaringClass->getNamespaceName() . '\\' . $typeHint;
252
+        $expandedClassName = $declaringClass->getNamespaceName().'\\'.$typeHint;
253 253
         if ($this->isClassOrInterface($expandedClassName)) {
254 254
             return $expandedClassName;
255 255
         }
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 
288 288
     private function endsWith(string $statementClassToCheck, string $typeHintToSearchFor): bool
289 289
     {
290
-        $typeHintToSearchFor = '\\' . $typeHintToSearchFor;
290
+        $typeHintToSearchFor = '\\'.$typeHintToSearchFor;
291 291
 
292 292
         return substr($statementClassToCheck, -strlen($typeHintToSearchFor)) === $typeHintToSearchFor;
293 293
     }
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
         preg_match_all(self::GROUP_USE_STATEMENTS_REGEX, $classContents, $foundGroupUseStatements);
309 309
         for ($useStatementIndex = 0; $useStatementIndex < count($foundGroupUseStatements[0]); $useStatementIndex++) {
310 310
             foreach (explode(',', $foundGroupUseStatements[2][$useStatementIndex]) as $singleUseStatement) {
311
-                $foundUseStatements[] = trim($foundGroupUseStatements[1][$useStatementIndex]) . trim($singleUseStatement);
311
+                $foundUseStatements[] = trim($foundGroupUseStatements[1][$useStatementIndex]).trim($singleUseStatement);
312 312
             }
313 313
         }
314 314
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
      */
348 348
     private function resolveType(string $typeHint, $reflector): string
349 349
     {
350
-        if (!$this->hasGlobalNamespacePrefix($typeHint) && !$this->isPrimitiveType($typeHint)) {
350
+        if ( ! $this->hasGlobalNamespacePrefix($typeHint) && ! $this->isPrimitiveType($typeHint)) {
351 351
             $typeHint = $this->expandClassNameUsingUseStatements($typeHint, $this->getDeclaringClassOrTrait($reflector), $reflector);
352 352
         }
353 353
 
@@ -365,15 +365,15 @@  discard block
 block discarded – undo
365 365
     private function resolveTypeFromDocblock($reflector): array
366 366
     {
367 367
         $docComment = $reflector->getDocComment();
368
-        if (!$docComment && PHP_VERSION_ID >= 80000 && $reflector instanceof \ReflectionProperty && $reflector->isPromoted()) {
368
+        if ( ! $docComment && PHP_VERSION_ID >= 80000 && $reflector instanceof \ReflectionProperty && $reflector->isPromoted()) {
369 369
             $constructor = $reflector->getDeclaringClass()->getConstructor();
370
-            if (!$constructor) {
370
+            if ( ! $constructor) {
371 371
                 return [];
372 372
             }
373 373
 
374 374
             $docComment = $constructor->getDocComment();
375 375
 
376
-            if (!$docComment) {
376
+            if ( ! $docComment) {
377 377
                 return [];
378 378
             }
379 379
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
             return $this->flattenParamTagValueTypes($reflector->getName(), $phpDocNode->getParamTagValues());
384 384
         }
385 385
 
386
-        if (!$docComment) {
386
+        if ( ! $docComment) {
387 387
             return [];
388 388
         }
389 389
 
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 
428 428
                     return sprintf('array<%s>', implode(
429 429
                         ',',
430
-                        array_map(static function (string $type) use ($reflector, $self) {
430
+                        array_map(static function(string $type) use ($reflector, $self) {
431 431
                             return $self->resolveType(trim($type), $reflector);
432 432
                         }, $types)
433 433
                     ));
Please login to merge, or discard this patch.
src/Metadata/Driver/AttributeDriver.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
     protected function getClassAnnotations(\ReflectionClass $class): array
15 15
     {
16 16
         return array_map(
17
-            static function (\ReflectionAttribute $attribute): object {
17
+            static function(\ReflectionAttribute $attribute): object {
18 18
                 return $attribute->newInstance();
19 19
             },
20 20
             array_filter(
21 21
                 $class->getAttributes(),
22
-                static function (\ReflectionAttribute $attribute): bool {
22
+                static function(\ReflectionAttribute $attribute): bool {
23 23
                     return class_exists($attribute->getName());
24 24
                 }
25 25
             )
@@ -32,12 +32,12 @@  discard block
 block discarded – undo
32 32
     protected function getMethodAnnotations(\ReflectionMethod $method): array
33 33
     {
34 34
         return array_map(
35
-            static function (\ReflectionAttribute $attribute): object {
35
+            static function(\ReflectionAttribute $attribute): object {
36 36
                 return $attribute->newInstance();
37 37
             },
38 38
             array_filter(
39 39
                 $method->getAttributes(),
40
-                static function (\ReflectionAttribute $attribute): bool {
40
+                static function(\ReflectionAttribute $attribute): bool {
41 41
                     return class_exists($attribute->getName());
42 42
                 }
43 43
             )
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
     protected function getPropertyAnnotations(\ReflectionProperty $property): array
51 51
     {
52 52
         return array_map(
53
-            static function (\ReflectionAttribute $attribute): object {
53
+            static function(\ReflectionAttribute $attribute): object {
54 54
                 return $attribute->newInstance();
55 55
             },
56 56
             array_filter(
57 57
                 $property->getAttributes(),
58
-                static function (\ReflectionAttribute $attribute): bool {
58
+                static function(\ReflectionAttribute $attribute): bool {
59 59
                     return class_exists($attribute->getName());
60 60
                 }
61 61
             )
Please login to merge, or discard this patch.
src/Metadata/Driver/AnnotationOrAttributeDriver.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
         $configured = false;
83 83
 
84 84
         $classMetadata = new ClassMetadata($name = $class->name);
85
-        $fileResource =  $class->getFilename();
85
+        $fileResource = $class->getFilename();
86 86
 
87 87
         if (false !== $fileResource) {
88 88
             $classMetadata->fileResources[] = $fileResource;
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
             }
169 169
         }
170 170
 
171
-        if (!$excludeAll) {
171
+        if ( ! $excludeAll) {
172 172
             foreach ($class->getProperties() as $property) {
173 173
                 if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) {
174 174
                     continue;
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
                     } elseif ($annot instanceof Expose) {
203 203
                         $isExpose = true;
204 204
                         if (null !== $annot->if) {
205
-                            $propertyMetadata->excludeIf = $this->parseExpression('!(' . $annot->if . ')');
205
+                            $propertyMetadata->excludeIf = $this->parseExpression('!('.$annot->if.')');
206 206
                         }
207 207
                     } elseif ($annot instanceof Exclude) {
208 208
                         if (null !== $annot->if) {
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
                                 throw new InvalidMetadataException(sprintf(
250 250
                                     'Invalid group name "%s" on "%s", did you mean to create multiple groups?',
251 251
                                     implode(', ', $propertyMetadata->groups),
252
-                                    $propertyMetadata->class . '->' . $propertyMetadata->name
252
+                                    $propertyMetadata->class.'->'.$propertyMetadata->name
253 253
                                 ));
254 254
                             }
255 255
                         }
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
                     }
272 272
                 }
273 273
 
274
-                if (!$propertyMetadata->serializedName) {
274
+                if ( ! $propertyMetadata->serializedName) {
275 275
                     $propertyMetadata->serializedName = $this->namingStrategy->translateName($propertyMetadata);
276 276
                 }
277 277
 
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                 }
283 283
 
284 284
                 if (
285
-                    (ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude)
285
+                    (ExclusionPolicy::NONE === $exclusionPolicy && ! $isExclude)
286 286
                     || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose)
287 287
                 ) {
288 288
                     $propertyMetadata->setAccessor($accessType, $accessor[0], $accessor[1]);
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
             }
292 292
         }
293 293
 
294
-        if (!$configured) {
294
+        if ( ! $configured) {
295 295
             // return null;
296 296
             // uncomment the above line afetr a couple of months
297 297
         }
@@ -308,12 +308,12 @@  discard block
 block discarded – undo
308 308
 
309 309
         if (PHP_VERSION_ID >= 80000) {
310 310
             $annotations = array_map(
311
-                static function (\ReflectionAttribute $attribute): object {
311
+                static function(\ReflectionAttribute $attribute): object {
312 312
                     return $attribute->newInstance();
313 313
                 },
314 314
                 array_filter(
315 315
                     $class->getAttributes(),
316
-                    static function (\ReflectionAttribute $attribute): bool {
316
+                    static function(\ReflectionAttribute $attribute): bool {
317 317
                         return class_exists($attribute->getName());
318 318
                     }
319 319
                 )
@@ -336,12 +336,12 @@  discard block
 block discarded – undo
336 336
 
337 337
         if (PHP_VERSION_ID >= 80000) {
338 338
             $annotations = array_map(
339
-                static function (\ReflectionAttribute $attribute): object {
339
+                static function(\ReflectionAttribute $attribute): object {
340 340
                     return $attribute->newInstance();
341 341
                 },
342 342
                 array_filter(
343 343
                     $method->getAttributes(),
344
-                    static function (\ReflectionAttribute $attribute): bool {
344
+                    static function(\ReflectionAttribute $attribute): bool {
345 345
                         return class_exists($attribute->getName());
346 346
                     }
347 347
                 )
@@ -364,12 +364,12 @@  discard block
 block discarded – undo
364 364
 
365 365
         if (PHP_VERSION_ID >= 80000) {
366 366
             $annotations = array_map(
367
-                static function (\ReflectionAttribute $attribute): object {
367
+                static function(\ReflectionAttribute $attribute): object {
368 368
                     return $attribute->newInstance();
369 369
                 },
370 370
                 array_filter(
371 371
                     $property->getAttributes(),
372
-                    static function (\ReflectionAttribute $attribute): bool {
372
+                    static function(\ReflectionAttribute $attribute): bool {
373 373
                         return class_exists($attribute->getName());
374 374
                     }
375 375
                 )
Please login to merge, or discard this patch.