@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | if (false !== stripos($data, '<!doctype')) { |
83 | 83 | $internalSubset = $this->getDomDocumentTypeEntitySubset($data); |
84 | - if (!in_array($internalSubset, $this->doctypeWhitelist, true)) { |
|
84 | + if ( ! in_array($internalSubset, $this->doctypeWhitelist, true)) { |
|
85 | 85 | throw new InvalidArgumentException(sprintf( |
86 | 86 | 'The document type "%s" is not allowed. If it is safe, you may add it to the whitelist configuration.', |
87 | 87 | $internalSubset |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | $nodes = $data->xpath($entryName); |
198 | 198 | } |
199 | 199 | |
200 | - if (!\count($nodes)) { |
|
200 | + if ( ! \count($nodes)) { |
|
201 | 201 | return []; |
202 | 202 | } |
203 | 203 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $nodes = $data->children($namespace)->$entryName; |
226 | 226 | foreach ($nodes as $v) { |
227 | 227 | $attrs = $v->attributes(); |
228 | - if (!isset($attrs[$this->currentMetadata->xmlKeyAttribute])) { |
|
228 | + if ( ! isset($attrs[$this->currentMetadata->xmlKeyAttribute])) { |
|
229 | 229 | throw new RuntimeException(sprintf('The key attribute "%s" must be set for each entry of the map.', $this->currentMetadata->xmlKeyAttribute)); |
230 | 230 | } |
231 | 231 | |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | return (string) $data->attributes($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName}; |
255 | 255 | |
256 | 256 | // Check XML element with namespace for discriminatorFieldName |
257 | - case !$metadata->xmlDiscriminatorAttribute && null !== $metadata->xmlDiscriminatorNamespace && isset($data->children($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName}): |
|
257 | + case ! $metadata->xmlDiscriminatorAttribute && null !== $metadata->xmlDiscriminatorNamespace && isset($data->children($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName}): |
|
258 | 258 | return (string) $data->children($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName}; |
259 | 259 | // Check XML element for discriminatorFieldName |
260 | 260 | case isset($data->{$metadata->discriminatorFieldName}): |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | $name = $metadata->serializedName; |
283 | 283 | |
284 | 284 | if (true === $metadata->inline) { |
285 | - if (!$metadata->type) { |
|
285 | + if ( ! $metadata->type) { |
|
286 | 286 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
287 | 287 | } |
288 | 288 | return $this->navigator->accept($data, $metadata->type); |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | if ($metadata->xmlAttribute) { |
291 | 291 | $attributes = $data->attributes($metadata->xmlNamespace); |
292 | 292 | if (isset($attributes[$name])) { |
293 | - if (!$metadata->type) { |
|
293 | + if ( ! $metadata->type) { |
|
294 | 294 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
295 | 295 | } |
296 | 296 | return $this->navigator->accept($attributes[$name], $metadata->type); |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | if ($metadata->xmlValue) { |
303 | - if (!$metadata->type) { |
|
303 | + if ( ! $metadata->type) { |
|
304 | 304 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
305 | 305 | } |
306 | 306 | return $this->navigator->accept($data, $metadata->type); |
@@ -308,12 +308,12 @@ discard block |
||
308 | 308 | |
309 | 309 | if ($metadata->xmlCollection) { |
310 | 310 | $enclosingElem = $data; |
311 | - if (!$metadata->xmlCollectionInline) { |
|
311 | + if ( ! $metadata->xmlCollectionInline) { |
|
312 | 312 | $enclosingElem = $data->children($metadata->xmlNamespace)->$name; |
313 | 313 | } |
314 | 314 | |
315 | 315 | $this->setCurrentMetadata($metadata); |
316 | - if (!$metadata->type) { |
|
316 | + if ( ! $metadata->type) { |
|
317 | 317 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
318 | 318 | } |
319 | 319 | $v = $this->navigator->accept($enclosingElem, $metadata->type); |
@@ -323,13 +323,13 @@ discard block |
||
323 | 323 | |
324 | 324 | if ($metadata->xmlNamespace) { |
325 | 325 | $node = $data->children($metadata->xmlNamespace)->$name; |
326 | - if (!$node->count()) { |
|
326 | + if ( ! $node->count()) { |
|
327 | 327 | throw new NotAcceptableException(); |
328 | 328 | } |
329 | 329 | } elseif ('' === $metadata->xmlNamespace) { |
330 | 330 | // See #1087 - element must be like: <element xmlns="" /> - https://www.w3.org/TR/REC-xml-names/#iri-use |
331 | 331 | // Use of an empty string in a namespace declaration turns it into an "undeclaration". |
332 | - $nodes = $data->xpath('./' . $name); |
|
332 | + $nodes = $data->xpath('./'.$name); |
|
333 | 333 | if (empty($nodes)) { |
334 | 334 | throw new NotAcceptableException(); |
335 | 335 | } |
@@ -339,9 +339,9 @@ discard block |
||
339 | 339 | if (isset($namespaces[''])) { |
340 | 340 | $prefix = uniqid('ns-'); |
341 | 341 | $data->registerXPathNamespace($prefix, $namespaces['']); |
342 | - $nodes = $data->xpath('./' . $prefix . ':' . $name); |
|
342 | + $nodes = $data->xpath('./'.$prefix.':'.$name); |
|
343 | 343 | } else { |
344 | - $nodes = $data->xpath('./' . $name); |
|
344 | + $nodes = $data->xpath('./'.$name); |
|
345 | 345 | } |
346 | 346 | if (empty($nodes)) { |
347 | 347 | throw new NotAcceptableException(); |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | $this->setCurrentMetadata($metadata); |
354 | 354 | } |
355 | 355 | |
356 | - if (!$metadata->type) { |
|
356 | + if ( ! $metadata->type) { |
|
357 | 357 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
358 | 358 | } |
359 | 359 | return $this->navigator->accept($node, $metadata->type); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | public static function getDefaultMethodName(string $eventName): string |
32 | 32 | { |
33 | - return 'on' . str_replace(['_', '.'], '', $eventName); |
|
33 | + return 'on'.str_replace(['_', '.'], '', $eventName); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | public function addSubscriber(EventSubscriberInterface $subscriber): void |
57 | 57 | { |
58 | 58 | foreach ($subscriber->getSubscribedEvents() as $eventData) { |
59 | - if (!isset($eventData['event'])) { |
|
59 | + if ( ! isset($eventData['event'])) { |
|
60 | 60 | throw new InvalidArgumentException(sprintf('Each event must have a "event" key.')); |
61 | 61 | } |
62 | 62 | |
@@ -71,33 +71,33 @@ discard block |
||
71 | 71 | |
72 | 72 | public function hasListeners(string $eventName, string $class, string $format): bool |
73 | 73 | { |
74 | - if (!isset($this->listeners[$eventName])) { |
|
74 | + if ( ! isset($this->listeners[$eventName])) { |
|
75 | 75 | return false; |
76 | 76 | } |
77 | 77 | |
78 | - if (!isset($this->classListeners[$eventName][$class][$format])) { |
|
78 | + if ( ! isset($this->classListeners[$eventName][$class][$format])) { |
|
79 | 79 | $this->classListeners[$eventName][$class][$format] = $this->initializeListeners($eventName, $class, $format); |
80 | 80 | } |
81 | 81 | |
82 | - return !!$this->classListeners[$eventName][$class][$format]; |
|
82 | + return ! ! $this->classListeners[$eventName][$class][$format]; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | public function dispatch(string $eventName, string $class, string $format, Event $event): void |
86 | 86 | { |
87 | - if (!isset($this->listeners[$eventName])) { |
|
87 | + if ( ! isset($this->listeners[$eventName])) { |
|
88 | 88 | return; |
89 | 89 | } |
90 | 90 | |
91 | 91 | $object = $event instanceof ObjectEvent ? $event->getObject() : null; |
92 | 92 | $realClass = is_object($object) ? get_class($object) : ''; |
93 | - $objectClass = $realClass !== $class ? ($realClass . $class) : $class; |
|
93 | + $objectClass = $realClass !== $class ? ($realClass.$class) : $class; |
|
94 | 94 | |
95 | - if (!isset($this->classListeners[$eventName][$objectClass][$format])) { |
|
95 | + if ( ! isset($this->classListeners[$eventName][$objectClass][$format])) { |
|
96 | 96 | $this->classListeners[$eventName][$objectClass][$format] = $this->initializeListeners($eventName, $class, $format); |
97 | 97 | } |
98 | 98 | |
99 | 99 | foreach ($this->classListeners[$eventName][$objectClass][$format] as $listener) { |
100 | - if (!empty($listener[3]) && !($object instanceof $listener[3])) { |
|
100 | + if ( ! empty($listener[3]) && ! ($object instanceof $listener[3])) { |
|
101 | 101 | continue; |
102 | 102 | } |
103 | 103 |
@@ -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 | })(); |
@@ -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".', |