@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | if ($this->nestedGroups) { |
55 | 55 | $groups = $this->getGroupsFor($navigatorContext); |
56 | 56 | |
57 | - if (!$property->groups) { |
|
58 | - return !in_array(self::DEFAULT_GROUP, $groups); |
|
57 | + if ( ! $property->groups) { |
|
58 | + return ! in_array(self::DEFAULT_GROUP, $groups); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | return $this->shouldSkipUsingGroups($property, $groups); |
62 | 62 | } else { |
63 | - if (!$property->groups) { |
|
64 | - return !isset($this->groups[self::DEFAULT_GROUP]); |
|
63 | + if ( ! $property->groups) { |
|
64 | + return ! isset($this->groups[self::DEFAULT_GROUP]); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | foreach ($property->groups as $group) { |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | |
88 | 88 | public function getGroupsFor(Context $navigatorContext): array |
89 | 89 | { |
90 | - if (!$this->nestedGroups) { |
|
90 | + if ( ! $this->nestedGroups) { |
|
91 | 91 | return array_keys($this->groups); |
92 | 92 | } |
93 | 93 | |
94 | 94 | $paths = $navigatorContext->getCurrentPath(); |
95 | 95 | $groups = $this->groups; |
96 | 96 | foreach ($paths as $index => $path) { |
97 | - if (!array_key_exists($path, $groups)) { |
|
97 | + if ( ! array_key_exists($path, $groups)) { |
|
98 | 98 | if ($index > 0) { |
99 | 99 | $groups = [self::DEFAULT_GROUP]; |
100 | 100 | } else { |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | $groups = $groups[$path]; |
108 | - if (!array_filter($groups, 'is_string')) { |
|
108 | + if ( ! array_filter($groups, 'is_string')) { |
|
109 | 109 | $groups += [self::DEFAULT_GROUP]; |
110 | 110 | } |
111 | 111 | } |
@@ -53,7 +53,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | switch ($type['name']) { |
141 | 141 | case 'NULL': |
142 | - if (!$this->shouldSerializeNull && !$this->isRootNullAllowed()) { |
|
142 | + if ( ! $this->shouldSerializeNull && ! $this->isRootNullAllowed()) { |
|
143 | 143 | throw new NotAcceptableException(); |
144 | 144 | } |
145 | 145 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | case 'resource': |
170 | 170 | $msg = 'Resources are not supported in serialized data.'; |
171 | 171 | if (null !== $path = $this->context->getPath()) { |
172 | - $msg .= ' Path: ' . $path; |
|
172 | + $msg .= ' Path: '.$path; |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | throw new RuntimeException($msg); |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | throw new ExcludedClassException(); |
236 | 236 | } |
237 | 237 | |
238 | - if (!is_object($data)) { |
|
239 | - throw new InvalidArgumentException('Value at ' . $this->context->getPath() . ' is expected to be an object of class ' . $type['name'] . ' but is of type ' . gettype($data)); |
|
238 | + if ( ! is_object($data)) { |
|
239 | + throw new InvalidArgumentException('Value at '.$this->context->getPath().' is expected to be an object of class '.$type['name'].' but is of type '.gettype($data)); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | $this->context->pushClassMetadata($metadata); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | private function getAccessorStrategy(): AccessorStrategyInterface |
211 | 211 | { |
212 | - if (!$this->accessorStrategy) { |
|
212 | + if ( ! $this->accessorStrategy) { |
|
213 | 213 | $this->accessorStrategy = new DefaultAccessorStrategy($this->expressionEvaluator); |
214 | 214 | } |
215 | 215 | |
@@ -246,11 +246,11 @@ discard block |
||
246 | 246 | |
247 | 247 | public function setCacheDir(string $dir): self |
248 | 248 | { |
249 | - if (!is_dir($dir)) { |
|
249 | + if ( ! is_dir($dir)) { |
|
250 | 250 | $this->createDir($dir); |
251 | 251 | } |
252 | 252 | |
253 | - if (!is_writable($dir)) { |
|
253 | + if ( ! is_writable($dir)) { |
|
254 | 254 | throw new InvalidArgumentException(sprintf('The cache directory "%s" is not writable.', $dir)); |
255 | 255 | } |
256 | 256 | |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | public function setMetadataDirs(array $namespacePrefixToDirMap): self |
373 | 373 | { |
374 | 374 | foreach ($namespacePrefixToDirMap as $dir) { |
375 | - if (!is_dir($dir)) { |
|
375 | + if ( ! is_dir($dir)) { |
|
376 | 376 | throw new InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir)); |
377 | 377 | } |
378 | 378 | } |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | */ |
411 | 411 | public function addMetadataDir(string $dir, string $namespacePrefix = ''): self |
412 | 412 | { |
413 | - if (!is_dir($dir)) { |
|
413 | + if ( ! is_dir($dir)) { |
|
414 | 414 | throw new InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir)); |
415 | 415 | } |
416 | 416 | |
@@ -449,11 +449,11 @@ discard block |
||
449 | 449 | */ |
450 | 450 | public function replaceMetadataDir(string $dir, string $namespacePrefix = ''): self |
451 | 451 | { |
452 | - if (!is_dir($dir)) { |
|
452 | + if ( ! is_dir($dir)) { |
|
453 | 453 | throw new InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir)); |
454 | 454 | } |
455 | 455 | |
456 | - if (!isset($this->metadataDirs[$namespacePrefix])) { |
|
456 | + if ( ! isset($this->metadataDirs[$namespacePrefix])) { |
|
457 | 457 | throw new InvalidArgumentException(sprintf('There is no directory configured for namespace prefix "%s". Please use addMetadataDir() for adding new directories.', $namespacePrefix)); |
458 | 458 | } |
459 | 459 | |
@@ -526,12 +526,12 @@ discard block |
||
526 | 526 | $annotationReader = new AnnotationReader(); |
527 | 527 | |
528 | 528 | if (null !== $this->cacheDir) { |
529 | - $this->createDir($this->cacheDir . '/annotations'); |
|
529 | + $this->createDir($this->cacheDir.'/annotations'); |
|
530 | 530 | if (class_exists(FilesystemAdapter::class)) { |
531 | - $annotationsCache = new FilesystemAdapter('', 0, $this->cacheDir . '/annotations'); |
|
531 | + $annotationsCache = new FilesystemAdapter('', 0, $this->cacheDir.'/annotations'); |
|
532 | 532 | $annotationReader = new PsrCachedReader($annotationReader, $annotationsCache, $this->debug); |
533 | 533 | } else { |
534 | - $annotationsCache = new FilesystemCache($this->cacheDir . '/annotations'); |
|
534 | + $annotationsCache = new FilesystemCache($this->cacheDir.'/annotations'); |
|
535 | 535 | $annotationReader = new CachedReader($annotationReader, $annotationsCache, $this->debug); |
536 | 536 | } |
537 | 537 | } |
@@ -558,19 +558,19 @@ discard block |
||
558 | 558 | if (null !== $this->metadataCache) { |
559 | 559 | $metadataFactory->setCache($this->metadataCache); |
560 | 560 | } elseif (null !== $this->cacheDir) { |
561 | - $this->createDir($this->cacheDir . '/metadata'); |
|
562 | - $metadataFactory->setCache(new FileCache($this->cacheDir . '/metadata')); |
|
561 | + $this->createDir($this->cacheDir.'/metadata'); |
|
562 | + $metadataFactory->setCache(new FileCache($this->cacheDir.'/metadata')); |
|
563 | 563 | } |
564 | 564 | |
565 | - if (!$this->handlersConfigured) { |
|
565 | + if ( ! $this->handlersConfigured) { |
|
566 | 566 | $this->addDefaultHandlers(); |
567 | 567 | } |
568 | 568 | |
569 | - if (!$this->listenersConfigured) { |
|
569 | + if ( ! $this->listenersConfigured) { |
|
570 | 570 | $this->addDefaultListeners(); |
571 | 571 | } |
572 | 572 | |
573 | - if (!$this->visitorsAdded) { |
|
573 | + if ( ! $this->visitorsAdded) { |
|
574 | 574 | $this->addDefaultSerializationVisitors(); |
575 | 575 | $this->addDefaultDeserializationVisitors(); |
576 | 576 | } |