@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function __construct($container) |
22 | 22 | { |
23 | - if (!$container instanceof PsrContainerInterface && !$container instanceof ContainerInterface) { |
|
23 | + if ( ! $container instanceof PsrContainerInterface && ! $container instanceof ContainerInterface) { |
|
24 | 24 | throw new InvalidArgumentException(sprintf('The container must be an instance of %s or %s (%s given).', PsrContainerInterface::class, ContainerInterface::class, \is_object($container) ? \get_class($container) : \gettype($container))); |
25 | 25 | } |
26 | 26 | |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | $listeners = parent::initializeListeners($eventName, $loweredClass, $format); |
36 | 36 | |
37 | 37 | foreach ($listeners as &$listener) { |
38 | - if (!\is_array($listener[0]) || !\is_string($listener[0][0])) { |
|
38 | + if ( ! \is_array($listener[0]) || ! \is_string($listener[0][0])) { |
|
39 | 39 | continue; |
40 | 40 | } |
41 | 41 | |
42 | - if (!$this->container->has($listener[0][0])) { |
|
42 | + if ( ! $this->container->has($listener[0][0])) { |
|
43 | 43 | continue; |
44 | 44 | } |
45 | 45 |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function startVisiting($object): void |
64 | 64 | { |
65 | - if (!\is_object($object)) { |
|
65 | + if ( ! \is_object($object)) { |
|
66 | 66 | return; |
67 | 67 | } |
68 | 68 | $this->visitingSet->attach($object); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function stopVisiting($object): void |
76 | 76 | { |
77 | - if (!\is_object($object)) { |
|
77 | + if ( ! \is_object($object)) { |
|
78 | 78 | return; |
79 | 79 | } |
80 | 80 | $this->visitingSet->detach($object); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function isVisiting($object): bool |
92 | 92 | { |
93 | - if (!\is_object($object)) { |
|
93 | + if ( ! \is_object($object)) { |
|
94 | 94 | return false; |
95 | 95 | } |
96 | 96 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $path[] = \get_class($obj); |
105 | 105 | } |
106 | 106 | |
107 | - if (!$path) { |
|
107 | + if ( ! $path) { |
|
108 | 108 | return null; |
109 | 109 | } |
110 | 110 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | public function getObject(): ?object |
125 | 125 | { |
126 | - return !$this->visitingStack->isEmpty() ? $this->visitingStack->top() : null; |
|
126 | + return ! $this->visitingStack->isEmpty() ? $this->visitingStack->top() : null; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | public function getVisitingStack(): \SplStack |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function visitArray($data, array $type): array |
88 | 88 | { |
89 | - if (!\is_array($data)) { |
|
89 | + if ( ! \is_array($data)) { |
|
90 | 90 | throw new RuntimeException(sprintf('Expected array, but got %s: %s', \gettype($data), json_encode($data))); |
91 | 91 | } |
92 | 92 | |
93 | 93 | // If no further parameters were given, keys/values are just passed as is. |
94 | - if (!$type['params']) { |
|
94 | + if ( ! $type['params']) { |
|
95 | 95 | return $data; |
96 | 96 | } |
97 | 97 | |
@@ -158,22 +158,22 @@ discard block |
||
158 | 158 | return; |
159 | 159 | } |
160 | 160 | |
161 | - if (!\is_array($data)) { |
|
161 | + if ( ! \is_array($data)) { |
|
162 | 162 | throw new RuntimeException(sprintf('Invalid data %s (%s), expected "%s".', json_encode($data), $metadata->type['name'], $metadata->class)); |
163 | 163 | } |
164 | 164 | |
165 | 165 | if (true === $metadata->inline) { |
166 | - if (!$metadata->type) { |
|
166 | + if ( ! $metadata->type) { |
|
167 | 167 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
168 | 168 | } |
169 | 169 | return $this->navigator->accept($data, $metadata->type); |
170 | 170 | } |
171 | 171 | |
172 | - if (!array_key_exists($name, $data)) { |
|
172 | + if ( ! array_key_exists($name, $data)) { |
|
173 | 173 | throw new NotAcceptableException(); |
174 | 174 | } |
175 | 175 | |
176 | - if (!$metadata->type) { |
|
176 | + if ( ! $metadata->type) { |
|
177 | 177 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
178 | 178 | } |
179 | 179 |
@@ -153,7 +153,7 @@ |
||
153 | 153 | array $type, |
154 | 154 | DeserializationContext $context |
155 | 155 | ): Generator { |
156 | - return (static function () use (&$visitor, &$data, &$type): Generator { |
|
156 | + return (static function() use (&$visitor, &$data, &$type): Generator { |
|
157 | 157 | $type['name'] = 'array'; |
158 | 158 | yield from $visitor->visitArray($data, $type); |
159 | 159 | })(); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | 'type' => $type, |
53 | 53 | 'format' => $format, |
54 | 54 | 'direction' => GraphNavigatorInterface::DIRECTION_SERIALIZATION, |
55 | - 'method' => 'serialize' . $type, |
|
55 | + 'method' => 'serialize'.$type, |
|
56 | 56 | ]; |
57 | 57 | } |
58 | 58 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | */ |
222 | 222 | private function parseDateTime($data, array $type, bool $immutable = false): \DateTimeInterface |
223 | 223 | { |
224 | - $timezone = !empty($type['params'][1]) ? new \DateTimeZone($type['params'][1]) : $this->defaultTimezone; |
|
224 | + $timezone = ! empty($type['params'][1]) ? new \DateTimeZone($type['params'][1]) : $this->defaultTimezone; |
|
225 | 225 | $format = $this->getDeserializationFormat($type); |
226 | 226 | |
227 | 227 | if ($immutable) { |
@@ -280,15 +280,15 @@ discard block |
||
280 | 280 | $format = 'P'; |
281 | 281 | |
282 | 282 | if (0 < $dateInterval->y) { |
283 | - $format .= $dateInterval->y . 'Y'; |
|
283 | + $format .= $dateInterval->y.'Y'; |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | if (0 < $dateInterval->m) { |
287 | - $format .= $dateInterval->m . 'M'; |
|
287 | + $format .= $dateInterval->m.'M'; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | if (0 < $dateInterval->d) { |
291 | - $format .= $dateInterval->d . 'D'; |
|
291 | + $format .= $dateInterval->d.'D'; |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | if (0 < $dateInterval->h || 0 < $dateInterval->i || 0 < $dateInterval->s) { |
@@ -296,15 +296,15 @@ discard block |
||
296 | 296 | } |
297 | 297 | |
298 | 298 | if (0 < $dateInterval->h) { |
299 | - $format .= $dateInterval->h . 'H'; |
|
299 | + $format .= $dateInterval->h.'H'; |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | if (0 < $dateInterval->i) { |
303 | - $format .= $dateInterval->i . 'M'; |
|
303 | + $format .= $dateInterval->i.'M'; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | if (0 < $dateInterval->s) { |
307 | - $format .= $dateInterval->s . 'S'; |
|
307 | + $format .= $dateInterval->s.'S'; |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | if ('P' === $format) { |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | |
24 | 24 | switch ($direction) { |
25 | 25 | case GraphNavigatorInterface::DIRECTION_DESERIALIZATION: |
26 | - return 'deserialize' . $type . 'From' . $format; |
|
26 | + return 'deserialize'.$type.'From'.$format; |
|
27 | 27 | |
28 | 28 | case GraphNavigatorInterface::DIRECTION_SERIALIZATION: |
29 | - return 'serialize' . $type . 'To' . $format; |
|
29 | + return 'serialize'.$type.'To'.$format; |
|
30 | 30 | |
31 | 31 | default: |
32 | 32 | throw new LogicException(sprintf('The direction %s does not exist; see GraphNavigatorInterface::DIRECTION_??? constants.', json_encode($direction))); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void |
42 | 42 | { |
43 | 43 | foreach ($handler->getSubscribingMethods() as $methodData) { |
44 | - if (!isset($methodData['type'], $methodData['format'])) { |
|
44 | + if ( ! isset($methodData['type'], $methodData['format'])) { |
|
45 | 45 | throw new RuntimeException(sprintf('For each subscribing method a "type" and "format" attribute must be given, but only got "%s" for %s.', implode('" and "', array_keys($methodData)), \get_class($handler))); |
46 | 46 | } |
47 | 47 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function getHandler(int $direction, string $typeName, string $format) |
72 | 72 | { |
73 | - if (!isset($this->handlers[$direction][$typeName][$format])) { |
|
73 | + if ( ! isset($this->handlers[$direction][$typeName][$format])) { |
|
74 | 74 | return null; |
75 | 75 | } |
76 | 76 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function __construct($container, array $handlers = []) |
28 | 28 | { |
29 | - if (!$container instanceof PsrContainerInterface && !$container instanceof ContainerInterface) { |
|
29 | + if ( ! $container instanceof PsrContainerInterface && ! $container instanceof ContainerInterface) { |
|
30 | 30 | throw new InvalidArgumentException(sprintf('The container must be an instance of %s or %s (%s given).', PsrContainerInterface::class, ContainerInterface::class, \is_object($container) ? \get_class($container) : \gettype($container))); |
31 | 31 | } |
32 | 32 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | return $this->initializedHandlers[$direction][$typeName][$format]; |
53 | 53 | } |
54 | 54 | |
55 | - if (!isset($this->handlers[$direction][$typeName][$format])) { |
|
55 | + if ( ! isset($this->handlers[$direction][$typeName][$format])) { |
|
56 | 56 | return null; |
57 | 57 | } |
58 | 58 |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function setAccessorOrder(string $order, array $customOrder = []): void |
161 | 161 | { |
162 | - if (!in_array($order, [self::ACCESSOR_ORDER_UNDEFINED, self::ACCESSOR_ORDER_ALPHABETICAL, self::ACCESSOR_ORDER_CUSTOM], true)) { |
|
162 | + if ( ! in_array($order, [self::ACCESSOR_ORDER_UNDEFINED, self::ACCESSOR_ORDER_ALPHABETICAL, self::ACCESSOR_ORDER_CUSTOM], true)) { |
|
163 | 163 | throw new InvalidMetadataException(sprintf('The accessor order "%s" is invalid.', $order)); |
164 | 164 | } |
165 | 165 | |
166 | 166 | foreach ($customOrder as $name) { |
167 | - if (!\is_string($name)) { |
|
167 | + if ( ! \is_string($name)) { |
|
168 | 168 | throw new InvalidMetadataException(sprintf('$customOrder is expected to be a list of strings, but got element of value %s.', json_encode($name))); |
169 | 169 | } |
170 | 170 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | |
201 | 201 | public function merge(MergeableInterface $object): void |
202 | 202 | { |
203 | - if (!$object instanceof ClassMetadata) { |
|
203 | + if ( ! $object instanceof ClassMetadata) { |
|
204 | 204 | throw new InvalidMetadataException('$object must be an instance of ClassMetadata.'); |
205 | 205 | } |
206 | 206 | parent::merge($object); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $this->discriminatorBaseClass, |
225 | 225 | $this->discriminatorBaseClass |
226 | 226 | )); |
227 | - } elseif (!$this->discriminatorFieldName && $object->discriminatorFieldName) { |
|
227 | + } elseif ( ! $this->discriminatorFieldName && $object->discriminatorFieldName) { |
|
228 | 228 | $this->discriminatorFieldName = $object->discriminatorFieldName; |
229 | 229 | $this->discriminatorMap = $object->discriminatorMap; |
230 | 230 | } |
@@ -246,12 +246,12 @@ discard block |
||
246 | 246 | |
247 | 247 | public function registerNamespace(string $uri, ?string $prefix = null): void |
248 | 248 | { |
249 | - if (!\is_string($uri)) { |
|
249 | + if ( ! \is_string($uri)) { |
|
250 | 250 | throw new InvalidMetadataException(sprintf('$uri is expected to be a strings, but got value %s.', json_encode($uri))); |
251 | 251 | } |
252 | 252 | |
253 | 253 | if (null !== $prefix) { |
254 | - if (!\is_string($prefix)) { |
|
254 | + if ( ! \is_string($prefix)) { |
|
255 | 255 | throw new InvalidMetadataException(sprintf('$prefix is expected to be a strings, but got value %s.', json_encode($prefix))); |
256 | 256 | } |
257 | 257 | } else { |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | private function handleDiscriminatorProperty(): void |
368 | 368 | { |
369 | 369 | if ($this->discriminatorMap |
370 | - && !$this->getReflection()->isAbstract() |
|
371 | - && !$this->getReflection()->isInterface() |
|
370 | + && ! $this->getReflection()->isAbstract() |
|
371 | + && ! $this->getReflection()->isInterface() |
|
372 | 372 | ) { |
373 | 373 | if (false === $typeValue = array_search($this->name, $this->discriminatorMap, true)) { |
374 | 374 | throw new InvalidMetadataException(sprintf( |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | $this->discriminatorValue = $typeValue; |
382 | 382 | |
383 | 383 | if (isset($this->propertyMetadata[$this->discriminatorFieldName]) |
384 | - && !$this->propertyMetadata[$this->discriminatorFieldName] instanceof StaticPropertyMetadata |
|
384 | + && ! $this->propertyMetadata[$this->discriminatorFieldName] instanceof StaticPropertyMetadata |
|
385 | 385 | ) { |
386 | 386 | throw new InvalidMetadataException(sprintf( |
387 | 387 | 'The discriminator field name "%s" of the base-class "%s" conflicts with a regular property of the sub-class "%s".', |
@@ -157,22 +157,22 @@ discard block |
||
157 | 157 | $class = $this->getReflection()->getDeclaringClass(); |
158 | 158 | |
159 | 159 | if (empty($getter)) { |
160 | - if ($class->hasMethod('get' . $this->name) && $class->getMethod('get' . $this->name)->isPublic()) { |
|
161 | - $getter = 'get' . $this->name; |
|
162 | - } elseif ($class->hasMethod('is' . $this->name) && $class->getMethod('is' . $this->name)->isPublic()) { |
|
163 | - $getter = 'is' . $this->name; |
|
164 | - } elseif ($class->hasMethod('has' . $this->name) && $class->getMethod('has' . $this->name)->isPublic()) { |
|
165 | - $getter = 'has' . $this->name; |
|
160 | + if ($class->hasMethod('get'.$this->name) && $class->getMethod('get'.$this->name)->isPublic()) { |
|
161 | + $getter = 'get'.$this->name; |
|
162 | + } elseif ($class->hasMethod('is'.$this->name) && $class->getMethod('is'.$this->name)->isPublic()) { |
|
163 | + $getter = 'is'.$this->name; |
|
164 | + } elseif ($class->hasMethod('has'.$this->name) && $class->getMethod('has'.$this->name)->isPublic()) { |
|
165 | + $getter = 'has'.$this->name; |
|
166 | 166 | } else { |
167 | - throw new InvalidMetadataException(sprintf('There is neither a public %s method, nor a public %s method, nor a public %s method in class %s. Please specify which public method should be used for retrieving the value of the property %s.', 'get' . ucfirst($this->name), 'is' . ucfirst($this->name), 'has' . ucfirst($this->name), $this->class, $this->name)); |
|
167 | + throw new InvalidMetadataException(sprintf('There is neither a public %s method, nor a public %s method, nor a public %s method in class %s. Please specify which public method should be used for retrieving the value of the property %s.', 'get'.ucfirst($this->name), 'is'.ucfirst($this->name), 'has'.ucfirst($this->name), $this->class, $this->name)); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | - if (empty($setter) && !$this->readOnly) { |
|
172 | - if ($class->hasMethod('set' . $this->name) && $class->getMethod('set' . $this->name)->isPublic()) { |
|
173 | - $setter = 'set' . $this->name; |
|
171 | + if (empty($setter) && ! $this->readOnly) { |
|
172 | + if ($class->hasMethod('set'.$this->name) && $class->getMethod('set'.$this->name)->isPublic()) { |
|
173 | + $setter = 'set'.$this->name; |
|
174 | 174 | } else { |
175 | - throw new InvalidMetadataException(sprintf('There is no public %s method in class %s. Please specify which public method should be used for setting the value of the property %s.', 'set' . ucfirst($this->name), $this->class, $this->name)); |
|
175 | + throw new InvalidMetadataException(sprintf('There is no public %s method in class %s. Please specify which public method should be used for setting the value of the property %s.', 'set'.ucfirst($this->name), $this->class, $this->name)); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | return is_array($type) |
192 | 192 | && 'array' === $type['name'] |
193 | 193 | && isset($type['params'][0]) |
194 | - && !isset($type['params'][1]); |
|
194 | + && ! isset($type['params'][1]); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | public static function isCollectionMap(?array $type = null): bool |