Completed
Pull Request — master (#1303)
by Ayrton
04:48
created
src/Metadata/Driver/DocBlockTypeResolver.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function getPropertyDocblockTypeHint(\ReflectionProperty $reflectionProperty): ?string
55 55
     {
56
-        if (!$reflectionProperty->getDocComment()) {
56
+        if ( ! $reflectionProperty->getDocComment()) {
57 57
             return null;
58 58
         }
59 59
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 
74 74
         // The PhpDoc contains multiple non-null types which produces ambiguity when deserializing.
75 75
         if (count($typesWithoutNull) > 1) {
76
-            $typeHint = implode('|', array_map(static function (TypeNode $type) {
76
+            $typeHint = implode('|', array_map(static function(TypeNode $type) {
77 77
                 return (string) $type;
78 78
             }, $types));
79 79
 
@@ -92,20 +92,20 @@  discard block
 block discarded – undo
92 92
         if ($type instanceof ArrayTypeNode) {
93 93
             $resolvedType = $this->resolveTypeFromTypeNode($type->type, $reflectionProperty);
94 94
 
95
-            return 'array<' . $resolvedType . '>';
95
+            return 'array<'.$resolvedType.'>';
96 96
         }
97 97
 
98 98
         // Generic array syntax: array<Product> | array<\Foo\Bar\Product> | array<int,Product>
99 99
         if ($type instanceof GenericTypeNode) {
100
-            if (!$this->isSimpleType($type->type, 'array')) {
100
+            if ( ! $this->isSimpleType($type->type, 'array')) {
101 101
                 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()));
102 102
             }
103 103
 
104
-            $resolvedTypes = array_map(function (TypeNode $node) use ($reflectionProperty) {
104
+            $resolvedTypes = array_map(function(TypeNode $node) use ($reflectionProperty) {
105 105
                 return $this->resolveTypeFromTypeNode($node, $reflectionProperty);
106 106
             }, $type->genericTypes);
107 107
 
108
-            return 'array<' . implode(',', $resolvedTypes) . '>';
108
+            return 'array<'.implode(',', $resolvedTypes).'>';
109 109
         }
110 110
 
111 111
         // Primitives and class names: Collection | \Foo\Bar\Product | string
@@ -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
             }
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
      */
144 144
     private function filterNullFromTypes(array $types): array
145 145
     {
146
-        return array_values(array_filter(array_map(function (TypeNode $node) {
146
+        return array_values(array_filter(array_map(function(TypeNode $node) {
147 147
             return $this->isNullType($node) ? null : $node;
148 148
         }, $types)));
149 149
     }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
      */
187 187
     private function resolveTypeFromTypeNode(TypeNode $typeNode, \ReflectionProperty $reflectionProperty): string
188 188
     {
189
-        if (!($typeNode instanceof IdentifierTypeNode)) {
189
+        if ( ! ($typeNode instanceof IdentifierTypeNode)) {
190 190
             throw new \InvalidArgumentException(sprintf("Can't use unsupported type %s for collection in %s:%s", (string) $typeNode, $reflectionProperty->getDeclaringClass()->getName(), $reflectionProperty->getName()));
191 191
         }
192 192
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
             return $typeHint;
200 200
         }
201 201
 
202
-        $expandedClassName = $declaringClass->getNamespaceName() . '\\' . $typeHint;
202
+        $expandedClassName = $declaringClass->getNamespaceName().'\\'.$typeHint;
203 203
         if ($this->isClassOrInterface($expandedClassName)) {
204 204
             return $expandedClassName;
205 205
         }
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
     private function endsWith(string $statementClassToCheck, string $typeHintToSearchFor): bool
227 227
     {
228
-        $typeHintToSearchFor = '\\' . $typeHintToSearchFor;
228
+        $typeHintToSearchFor = '\\'.$typeHintToSearchFor;
229 229
 
230 230
         return substr($statementClassToCheck, -strlen($typeHintToSearchFor)) === $typeHintToSearchFor;
231 231
     }
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
         preg_match_all(self::GROUP_USE_STATEMENTS_REGEX, $classContents, $foundGroupUseStatements);
247 247
         for ($useStatementIndex = 0; $useStatementIndex < count($foundGroupUseStatements[0]); $useStatementIndex++) {
248 248
             foreach (explode(',', $foundGroupUseStatements[2][$useStatementIndex]) as $singleUseStatement) {
249
-                $foundUseStatements[] = trim($foundGroupUseStatements[1][$useStatementIndex]) . trim($singleUseStatement);
249
+                $foundUseStatements[] = trim($foundGroupUseStatements[1][$useStatementIndex]).trim($singleUseStatement);
250 250
             }
251 251
         }
252 252
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 
280 280
     private function resolveType(string $typeHint, \ReflectionProperty $reflectionProperty): string
281 281
     {
282
-        if (!$this->hasGlobalNamespacePrefix($typeHint) && !$this->isPrimitiveType($typeHint)) {
282
+        if ( ! $this->hasGlobalNamespacePrefix($typeHint) && ! $this->isPrimitiveType($typeHint)) {
283 283
             $typeHint = $this->expandClassNameUsingUseStatements($typeHint, $this->getDeclaringClassOrTrait($reflectionProperty), $reflectionProperty);
284 284
         }
285 285
 
Please login to merge, or discard this patch.
src/GraphNavigator/DeserializationGraphNavigator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
                 $metadata = $this->metadataFactory->getMetadataForClass($type['name']);
172 172
                 \assert($metadata instanceof ClassMetadata);
173 173
 
174
-                if ($metadata->usingExpression && !$this->expressionExclusionStrategy) {
174
+                if ($metadata->usingExpression && ! $this->expressionExclusionStrategy) {
175 175
                     throw new ExpressionLanguageRequiredException(sprintf('To use conditional exclude/expose in %s you must configure the expression language.', $metadata->name));
176 176
                 }
177 177
 
178
-                if (!empty($metadata->discriminatorMap) && $type['name'] === $metadata->discriminatorBaseClass) {
178
+                if ( ! empty($metadata->discriminatorMap) && $type['name'] === $metadata->discriminatorBaseClass) {
179 179
                     $nullOnUnknown = $metadata->discriminatorNullOnUnknown;
180 180
                     $metadata = $this->resolveMetadata($data, $metadata);
181 181
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
     {
240 240
         $typeValue = $this->visitor->visitDiscriminatorMapProperty($data, $metadata);
241 241
 
242
-        if (!isset($metadata->discriminatorMap[$typeValue])) {
242
+        if ( ! isset($metadata->discriminatorMap[$typeValue])) {
243 243
             if ($metadata->discriminatorNullOnUnknown) {
244 244
                 return null;
245 245
             }
Please login to merge, or discard this patch.
src/Metadata/ClassMetadata.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
      */
171 171
     public function setAccessorOrder(string $order, array $customOrder = []): void
172 172
     {
173
-        if (!in_array($order, [self::ACCESSOR_ORDER_UNDEFINED, self::ACCESSOR_ORDER_ALPHABETICAL, self::ACCESSOR_ORDER_CUSTOM], true)) {
173
+        if ( ! in_array($order, [self::ACCESSOR_ORDER_UNDEFINED, self::ACCESSOR_ORDER_ALPHABETICAL, self::ACCESSOR_ORDER_CUSTOM], true)) {
174 174
             throw new InvalidMetadataException(sprintf('The accessor order "%s" is invalid.', $order));
175 175
         }
176 176
 
177 177
         foreach ($customOrder as $name) {
178
-            if (!\is_string($name)) {
178
+            if ( ! \is_string($name)) {
179 179
                 throw new InvalidMetadataException(sprintf('$customOrder is expected to be a list of strings, but got element of value %s.', json_encode($name)));
180 180
             }
181 181
         }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 
212 212
     public function merge(MergeableInterface $object): void
213 213
     {
214
-        if (!$object instanceof ClassMetadata) {
214
+        if ( ! $object instanceof ClassMetadata) {
215 215
             throw new InvalidMetadataException('$object must be an instance of ClassMetadata.');
216 216
         }
217 217
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
                 $this->discriminatorBaseClass,
241 241
                 $this->discriminatorBaseClass
242 242
             ));
243
-        } elseif (!$this->discriminatorFieldName && $object->discriminatorFieldName) {
243
+        } elseif ( ! $this->discriminatorFieldName && $object->discriminatorFieldName) {
244 244
             $this->discriminatorFieldName = $object->discriminatorFieldName;
245 245
             $this->discriminatorMap = $object->discriminatorMap;
246 246
         }
@@ -264,12 +264,12 @@  discard block
 block discarded – undo
264 264
 
265 265
     public function registerNamespace(string $uri, ?string $prefix = null): void
266 266
     {
267
-        if (!\is_string($uri)) {
267
+        if ( ! \is_string($uri)) {
268 268
             throw new InvalidMetadataException(sprintf('$uri is expected to be a strings, but got value %s.', json_encode($uri)));
269 269
         }
270 270
 
271 271
         if (null !== $prefix) {
272
-            if (!\is_string($prefix)) {
272
+            if ( ! \is_string($prefix)) {
273 273
                 throw new InvalidMetadataException(sprintf('$prefix is expected to be a strings, but got value %s.', json_encode($prefix)));
274 274
             }
275 275
         } else {
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
     {
395 395
         if (
396 396
             $this->discriminatorMap
397
-            && !$this->getReflection()->isAbstract()
398
-            && !$this->getReflection()->isInterface()
397
+            && ! $this->getReflection()->isAbstract()
398
+            && ! $this->getReflection()->isInterface()
399 399
         ) {
400 400
             if (false === $typeValue = array_search($this->name, $this->discriminatorMap, true)) {
401 401
                 if ($this->discriminatorNullOnUnknown) {
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 
413 413
             if (
414 414
                 isset($this->propertyMetadata[$this->discriminatorFieldName])
415
-                && !$this->propertyMetadata[$this->discriminatorFieldName] instanceof StaticPropertyMetadata
415
+                && ! $this->propertyMetadata[$this->discriminatorFieldName] instanceof StaticPropertyMetadata
416 416
             ) {
417 417
                 throw new InvalidMetadataException(sprintf(
418 418
                     'The discriminator field name "%s" of the base-class "%s" conflicts with a regular property of the sub-class "%s".',
Please login to merge, or discard this patch.