Passed
Pull Request — master (#1354)
by
unknown
10:12
created
src/Metadata/Driver/DocBlockDriver/DocBlockTypeResolver.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function getPropertyDocblockTypeHint(\ReflectionProperty $reflectionProperty): ?string
58 58
     {
59
-        if (!$reflectionProperty->getDocComment()) {
59
+        if ( ! $reflectionProperty->getDocComment()) {
60 60
             return null;
61 61
         }
62 62
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 
77 77
         // The PhpDoc contains multiple non-null types which produces ambiguity when deserializing.
78 78
         if (count($typesWithoutNull) > 1) {
79
-            $typeHint = implode('|', array_map(static function (TypeNode $type) {
79
+            $typeHint = implode('|', array_map(static function(TypeNode $type) {
80 80
                 return (string) $type;
81 81
             }, $types));
82 82
 
@@ -95,25 +95,25 @@  discard block
 block discarded – undo
95 95
         if ($type instanceof ArrayTypeNode) {
96 96
             $resolvedType = $this->resolveTypeFromTypeNode($type->type, $reflectionProperty);
97 97
 
98
-            return 'array<' . $resolvedType . '>';
98
+            return 'array<'.$resolvedType.'>';
99 99
         }
100 100
 
101 101
         // Generic array syntax: array<Product> | array<\Foo\Bar\Product> | array<int,Product>
102 102
         if ($type instanceof GenericTypeNode) {
103 103
             if ($this->isSimpleType($type->type, 'array')) {
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
             if ($this->isSimpleType($type->type, 'list')) {
112
-                $resolvedTypes = array_map(function (TypeNode $node) use ($reflectionProperty) {
112
+                $resolvedTypes = array_map(function(TypeNode $node) use ($reflectionProperty) {
113 113
                     return $this->resolveTypeFromTypeNode($node, $reflectionProperty);
114 114
                 }, $type->genericTypes);
115 115
 
116
-                return 'array<int, ' . implode(',', $resolvedTypes) . '>';
116
+                return 'array<int, '.implode(',', $resolvedTypes).'>';
117 117
             }
118 118
 
119 119
             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()));
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
             return [];
137 137
         }
138 138
 
139
-        return array_merge(...array_map(static function (VarTagValueNode $node) {
139
+        return array_merge(...array_map(static function(VarTagValueNode $node) {
140 140
             if ($node->type instanceof UnionTypeNode) {
141 141
                 return $node->type->types;
142 142
             }
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
      */
155 155
     private function filterNullFromTypes(array $types): array
156 156
     {
157
-        return array_values(array_filter(array_map(function (TypeNode $node) {
157
+        return array_values(array_filter(array_map(function(TypeNode $node) {
158 158
             return $this->isNullType($node) ? null : $node;
159 159
         }, $types)));
160 160
     }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
      */
198 198
     private function resolveTypeFromTypeNode(TypeNode $typeNode, \ReflectionProperty $reflectionProperty): string
199 199
     {
200
-        if (!($typeNode instanceof IdentifierTypeNode)) {
200
+        if ( ! ($typeNode instanceof IdentifierTypeNode)) {
201 201
             throw new \InvalidArgumentException(sprintf("Can't use unsupported type %s for collection in %s:%s", (string) $typeNode, $reflectionProperty->getDeclaringClass()->getName(), $reflectionProperty->getName()));
202 202
         }
203 203
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
             return $typeHint;
211 211
         }
212 212
 
213
-        $expandedClassName = $declaringClass->getNamespaceName() . '\\' . $typeHint;
213
+        $expandedClassName = $declaringClass->getNamespaceName().'\\'.$typeHint;
214 214
         if ($this->isClassOrInterface($expandedClassName)) {
215 215
             return $expandedClassName;
216 216
         }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
     private function endsWith(string $statementClassToCheck, string $typeHintToSearchFor): bool
238 238
     {
239
-        $typeHintToSearchFor = '\\' . $typeHintToSearchFor;
239
+        $typeHintToSearchFor = '\\'.$typeHintToSearchFor;
240 240
 
241 241
         return substr($statementClassToCheck, -strlen($typeHintToSearchFor)) === $typeHintToSearchFor;
242 242
     }
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
         preg_match_all(self::GROUP_USE_STATEMENTS_REGEX, $classContents, $foundGroupUseStatements);
258 258
         for ($useStatementIndex = 0; $useStatementIndex < count($foundGroupUseStatements[0]); $useStatementIndex++) {
259 259
             foreach (explode(',', $foundGroupUseStatements[2][$useStatementIndex]) as $singleUseStatement) {
260
-                $foundUseStatements[] = trim($foundGroupUseStatements[1][$useStatementIndex]) . trim($singleUseStatement);
260
+                $foundUseStatements[] = trim($foundGroupUseStatements[1][$useStatementIndex]).trim($singleUseStatement);
261 261
             }
262 262
         }
263 263
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 
291 291
     private function resolveType(string $typeHint, \ReflectionProperty $reflectionProperty): string
292 292
     {
293
-        if (!$this->hasGlobalNamespacePrefix($typeHint) && !$this->isPrimitiveType($typeHint)) {
293
+        if ( ! $this->hasGlobalNamespacePrefix($typeHint) && ! $this->isPrimitiveType($typeHint)) {
294 294
             $typeHint = $this->expandClassNameUsingUseStatements($typeHint, $this->getDeclaringClassOrTrait($reflectionProperty), $reflectionProperty);
295 295
         }
296 296
 
Please login to merge, or discard this patch.