@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | public function __construct($skipVirtualTypeInit = true, $initializeExcluded = false) |
| 43 | 43 | { |
| 44 | - $this->skipVirtualTypeInit = (bool)$skipVirtualTypeInit; |
|
| 45 | - $this->initializeExcluded = (bool)$initializeExcluded; |
|
| 44 | + $this->skipVirtualTypeInit = (bool) $skipVirtualTypeInit; |
|
| 45 | + $this->initializeExcluded = (bool) $initializeExcluded; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | public function onPreSerialize(PreSerializeEvent $event) |
@@ -53,13 +53,13 @@ discard block |
||
| 53 | 53 | // If the set type name is not an actual class, but a faked type for which a custom handler exists, we do not |
| 54 | 54 | // modify it with this subscriber. Also, we forgo autoloading here as an instance of this type is already created, |
| 55 | 55 | // so it must be loaded if its a real class. |
| 56 | - $virtualType = !class_exists($type['name'], false); |
|
| 56 | + $virtualType = ! class_exists($type['name'], false); |
|
| 57 | 57 | |
| 58 | 58 | if ($object instanceof PersistentCollection |
| 59 | 59 | || $object instanceof MongoDBPersistentCollection |
| 60 | 60 | || $object instanceof PHPCRPersistentCollection |
| 61 | 61 | ) { |
| 62 | - if (!$virtualType) { |
|
| 62 | + if ( ! $virtualType) { |
|
| 63 | 63 | $event->setType('ArrayCollection'); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | if (($this->skipVirtualTypeInit && $virtualType) || |
| 70 | - (!$object instanceof Proxy && !$object instanceof ORMProxy) |
|
| 70 | + ( ! $object instanceof Proxy && ! $object instanceof ORMProxy) |
|
| 71 | 71 | ) { |
| 72 | 72 | return; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // do not initialize the proxy if is going to be excluded by-class by some exclusion strategy |
| 76 | - if ($this->initializeExcluded === false && !$virtualType) { |
|
| 76 | + if ($this->initializeExcluded === false && ! $virtualType) { |
|
| 77 | 77 | $context = $event->getContext(); |
| 78 | 78 | $exclusionStrategy = $context->getExclusionStrategy(); |
| 79 | 79 | $metadata = $context->getMetadataFactory()->getMetadataForClass(get_parent_class($object)); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | $object->__load(); |
| 86 | 86 | |
| 87 | - if (!$virtualType) { |
|
| 87 | + if ( ! $virtualType) { |
|
| 88 | 88 | $event->setType(get_parent_class($object), $type['params']); |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | { |
| 94 | 94 | $type = $event->getType(); |
| 95 | 95 | // is a virtual type? then there is no need to change the event name |
| 96 | - if (!class_exists($type['name'], false)) { |
|
| 96 | + if ( ! class_exists($type['name'], false)) { |
|
| 97 | 97 | return; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | $classMetadata->setDiscriminator($annot->field, $annot->map, $annot->groups); |
| 113 | 113 | } |
| 114 | 114 | } elseif ($annot instanceof XmlDiscriminator) { |
| 115 | - $classMetadata->xmlDiscriminatorAttribute = (bool)$annot->attribute; |
|
| 116 | - $classMetadata->xmlDiscriminatorCData = (bool)$annot->cdata; |
|
| 117 | - $classMetadata->xmlDiscriminatorNamespace = $annot->namespace ? (string)$annot->namespace : null; |
|
| 115 | + $classMetadata->xmlDiscriminatorAttribute = (bool) $annot->attribute; |
|
| 116 | + $classMetadata->xmlDiscriminatorCData = (bool) $annot->cdata; |
|
| 117 | + $classMetadata->xmlDiscriminatorNamespace = $annot->namespace ? (string) $annot->namespace : null; |
|
| 118 | 118 | } elseif ($annot instanceof VirtualProperty) { |
| 119 | 119 | $virtualPropertyMetadata = new ExpressionPropertyMetadata($name, $annot->name, $annot->exp); |
| 120 | 120 | $propertiesMetadata[] = $virtualPropertyMetadata; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - if (!$excludeAll) { |
|
| 151 | + if ( ! $excludeAll) { |
|
| 152 | 152 | foreach ($class->getProperties() as $property) { |
| 153 | 153 | if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) { |
| 154 | 154 | continue; |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | } elseif ($annot instanceof Expose) { |
| 180 | 180 | $isExpose = true; |
| 181 | 181 | if (null !== $annot->if) { |
| 182 | - $propertyMetadata->excludeIf = "!(" . $annot->if . ")"; |
|
| 182 | + $propertyMetadata->excludeIf = "!(".$annot->if.")"; |
|
| 183 | 183 | } |
| 184 | 184 | } elseif ($annot instanceof Exclude) { |
| 185 | 185 | if (null !== $annot->if) { |
@@ -223,12 +223,12 @@ discard block |
||
| 223 | 223 | $accessor = array($annot->getter, $annot->setter); |
| 224 | 224 | } elseif ($annot instanceof Groups) { |
| 225 | 225 | $propertyMetadata->groups = $annot->groups; |
| 226 | - foreach ((array)$propertyMetadata->groups as $groupName) { |
|
| 226 | + foreach ((array) $propertyMetadata->groups as $groupName) { |
|
| 227 | 227 | if (false !== strpos($groupName, ',')) { |
| 228 | 228 | throw new InvalidArgumentException(sprintf( |
| 229 | 229 | 'Invalid group name "%s" on "%s", did you mean to create multiple groups?', |
| 230 | 230 | implode(', ', $propertyMetadata->groups), |
| 231 | - $propertyMetadata->class . '->' . $propertyMetadata->name |
|
| 231 | + $propertyMetadata->class.'->'.$propertyMetadata->name |
|
| 232 | 232 | )); |
| 233 | 233 | } |
| 234 | 234 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - if (!$propertyMetadata->serializedName) { |
|
| 244 | + if ( ! $propertyMetadata->serializedName) { |
|
| 245 | 245 | $propertyMetadata->serializedName = $this->namingStrategy->translateName($propertyMetadata); |
| 246 | 246 | } |
| 247 | 247 | |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - if ((ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude) |
|
| 254 | + if ((ExclusionPolicy::NONE === $exclusionPolicy && ! $isExclude) |
|
| 255 | 255 | || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose) |
| 256 | 256 | ) { |
| 257 | 257 | $propertyMetadata->setAccessor($accessType, $accessor[0], $accessor[1]); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | public function startVisiting($object): void |
| 54 | 54 | { |
| 55 | - if (!\is_object($object)) { |
|
| 55 | + if ( ! \is_object($object)) { |
|
| 56 | 56 | return; |
| 57 | 57 | } |
| 58 | 58 | $this->visitingSet->attach($object); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | public function stopVisiting($object): void |
| 63 | 63 | { |
| 64 | - if (!\is_object($object)) { |
|
| 64 | + if ( ! \is_object($object)) { |
|
| 65 | 65 | return; |
| 66 | 66 | } |
| 67 | 67 | $this->visitingSet->detach($object); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | public function isVisiting($object): bool |
| 76 | 76 | { |
| 77 | - if (!\is_object($object)) { |
|
| 77 | + if ( ! \is_object($object)) { |
|
| 78 | 78 | return false; |
| 79 | 79 | } |
| 80 | 80 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | $path[] = \get_class($obj); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - if (!$path) { |
|
| 91 | + if ( ! $path) { |
|
| 92 | 92 | return null; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | public function getObject() |
| 109 | 109 | { |
| 110 | - return !$this->visitingStack->isEmpty() ? $this->visitingStack->top() : null; |
|
| 110 | + return ! $this->visitingStack->isEmpty() ? $this->visitingStack->top() : null; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | public function getVisitingStack() |
@@ -95,8 +95,7 @@ |
||
| 95 | 95 | ExpressionEvaluatorInterface $expressionEvaluator = null, |
| 96 | 96 | SerializationContextFactoryInterface $serializationContextFactory = null, |
| 97 | 97 | DeserializationContextFactoryInterface $deserializationContextFactory = null |
| 98 | - ) |
|
| 99 | - { |
|
| 98 | + ) { |
|
| 100 | 99 | $this->factory = $factory; |
| 101 | 100 | $this->handlerRegistry = $handlerRegistry; |
| 102 | 101 | $this->objectConstructor = $objectConstructor; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | $context = $this->serializationContextFactory->createSerializationContext(); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if (!isset($this->serializationVisitors[$format])) { |
|
| 165 | + if ( ! isset($this->serializationVisitors[$format])) { |
|
| 166 | 166 | throw new UnsupportedFormatException(sprintf('The format "%s" is not supported for serialization.', $format)); |
| 167 | 167 | } |
| 168 | 168 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $context = $this->deserializationContextFactory->createDeserializationContext(); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if (!isset($this->deserializationVisitors[$format])) { |
|
| 184 | + if ( ! isset($this->deserializationVisitors[$format])) { |
|
| 185 | 185 | throw new UnsupportedFormatException(sprintf('The format "%s" is not supported for deserialization.', $format)); |
| 186 | 186 | } |
| 187 | 187 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $context = $this->serializationContextFactory->createSerializationContext(); |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - if (!isset($this->serializationVisitors['json'])) { |
|
| 205 | + if ( ! isset($this->serializationVisitors['json'])) { |
|
| 206 | 206 | throw new UnsupportedFormatException(sprintf('The format "%s" is not supported for fromArray.', 'json')); |
| 207 | 207 | } |
| 208 | 208 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | $result = $this->visit($navigator, $visitor, $context, $data, 'json', $type); |
| 215 | 215 | $result = $this->convertArrayObjects($result); |
| 216 | 216 | |
| 217 | - if (!\is_array($result)) { |
|
| 217 | + if ( ! \is_array($result)) { |
|
| 218 | 218 | throw new RuntimeException(sprintf( |
| 219 | 219 | 'The input data of type "%s" did not convert to an array, but got a result of type "%s".', |
| 220 | 220 | \is_object($data) ? \get_class($data) : \gettype($data), |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | $context = $this->deserializationContextFactory->createDeserializationContext(); |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - if (!isset($this->deserializationVisitors['json'])) { |
|
| 237 | + if ( ! isset($this->deserializationVisitors['json'])) { |
|
| 238 | 238 | throw new UnsupportedFormatException(sprintf('The format "%s" is not supported for fromArray.', 'json')); |
| 239 | 239 | } |
| 240 | 240 | |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | private function convertArrayObjects($data) |
| 266 | 266 | { |
| 267 | 267 | if ($data instanceof \ArrayObject || $data instanceof \stdClass) { |
| 268 | - $data = (array)$data; |
|
| 268 | + $data = (array) $data; |
|
| 269 | 269 | } |
| 270 | 270 | if (\is_array($data)) { |
| 271 | 271 | foreach ($data as $k => $v) { |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | public function translateName(PropertyMetadata $property):string |
| 43 | 43 | { |
| 44 | - $name = preg_replace('/[A-Z]+/', $this->separator . '\\0', $property->name); |
|
| 44 | + $name = preg_replace('/[A-Z]+/', $this->separator.'\\0', $property->name); |
|
| 45 | 45 | |
| 46 | 46 | if ($this->lowerCase) { |
| 47 | 47 | return strtolower($name); |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | $classMetadata = $context->getMetadataFactory()->getMetadataForClass('stdClass'); |
| 51 | 51 | $visitor->startVisitingObject($classMetadata, $stdClass, array('name' => 'stdClass'), $context); |
| 52 | 52 | |
| 53 | - foreach ((array)$stdClass as $name => $value) { |
|
| 53 | + foreach ((array) $stdClass as $name => $value) { |
|
| 54 | 54 | $metadata = new StaticPropertyMetadata('stdClass', $name, $value); |
| 55 | 55 | $visitor->visitProperty($metadata, $value); |
| 56 | 56 | } |
@@ -35,10 +35,10 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | switch ($direction) { |
| 37 | 37 | case GraphNavigatorInterface::DIRECTION_DESERIALIZATION: |
| 38 | - return 'deserialize' . $type . 'From' . $format; |
|
| 38 | + return 'deserialize'.$type.'From'.$format; |
|
| 39 | 39 | |
| 40 | 40 | case GraphNavigatorInterface::DIRECTION_SERIALIZATION: |
| 41 | - return 'serialize' . $type . 'To' . $format; |
|
| 41 | + return 'serialize'.$type.'To'.$format; |
|
| 42 | 42 | |
| 43 | 43 | default: |
| 44 | 44 | throw new LogicException(sprintf('The direction %s does not exist; see GraphNavigatorInterface::DIRECTION_??? constants.', json_encode($direction))); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | public function registerSubscribingHandler(SubscribingHandlerInterface $handler):void |
| 54 | 54 | { |
| 55 | 55 | foreach ($handler->getSubscribingMethods() as $methodData) { |
| 56 | - if (!isset($methodData['type'], $methodData['format'])) { |
|
| 56 | + if ( ! isset($methodData['type'], $methodData['format'])) { |
|
| 57 | 57 | 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))); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | public function getHandler(int $direction, string $typeName, string $format) |
| 82 | 82 | { |
| 83 | - if (!isset($this->handlers[$direction][$typeName][$format])) { |
|
| 83 | + if ( ! isset($this->handlers[$direction][$typeName][$format])) { |
|
| 84 | 84 | return null; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | $rs = isset($type['params'][1]) ? new \ArrayObject() : array(); |
| 87 | 87 | |
| 88 | - $isList = isset($type['params'][0]) && !isset($type['params'][1]); |
|
| 88 | + $isList = isset($type['params'][0]) && ! isset($type['params'][1]); |
|
| 89 | 89 | |
| 90 | 90 | $elType = $this->getElementType($type); |
| 91 | 91 | foreach ($data as $k => $v) { |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | if ($metadata->inline) { |
| 152 | 152 | if (\is_array($v) || ($v instanceof \ArrayObject)) { |
| 153 | - $this->data = array_merge($this->data, (array)$v); |
|
| 153 | + $this->data = array_merge($this->data, (array) $v); |
|
| 154 | 154 | } |
| 155 | 155 | } else { |
| 156 | 156 | $this->data[$metadata->serializedName] = $v; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | private function getAccessorStrategy() |
| 117 | 117 | { |
| 118 | - if (!$this->accessorStrategy) { |
|
| 118 | + if ( ! $this->accessorStrategy) { |
|
| 119 | 119 | $this->accessorStrategy = new DefaultAccessorStrategy(); |
| 120 | 120 | |
| 121 | 121 | if ($this->expressionEvaluator) { |
@@ -148,17 +148,17 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | public function setDebug($bool) |
| 150 | 150 | { |
| 151 | - $this->debug = (boolean)$bool; |
|
| 151 | + $this->debug = (boolean) $bool; |
|
| 152 | 152 | |
| 153 | 153 | return $this; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | public function setCacheDir($dir) |
| 157 | 157 | { |
| 158 | - if (!is_dir($dir)) { |
|
| 158 | + if ( ! is_dir($dir)) { |
|
| 159 | 159 | $this->createDir($dir); |
| 160 | 160 | } |
| 161 | - if (!is_writable($dir)) { |
|
| 161 | + if ( ! is_writable($dir)) { |
|
| 162 | 162 | throw new InvalidArgumentException(sprintf('The cache directory "%s" is not writable.', $dir)); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | public function includeInterfaceMetadata($include) |
| 262 | 262 | { |
| 263 | - $this->includeInterfaceMetadata = (Boolean)$include; |
|
| 263 | + $this->includeInterfaceMetadata = (Boolean) $include; |
|
| 264 | 264 | |
| 265 | 265 | return $this; |
| 266 | 266 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | public function setMetadataDirs(array $namespacePrefixToDirMap) |
| 280 | 280 | { |
| 281 | 281 | foreach ($namespacePrefixToDirMap as $dir) { |
| 282 | - if (!is_dir($dir)) { |
|
| 282 | + if ( ! is_dir($dir)) { |
|
| 283 | 283 | throw new InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir)); |
| 284 | 284 | } |
| 285 | 285 | } |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | */ |
| 318 | 318 | public function addMetadataDir($dir, $namespacePrefix = '') |
| 319 | 319 | { |
| 320 | - if (!is_dir($dir)) { |
|
| 320 | + if ( ! is_dir($dir)) { |
|
| 321 | 321 | throw new InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir)); |
| 322 | 322 | } |
| 323 | 323 | |
@@ -359,11 +359,11 @@ discard block |
||
| 359 | 359 | */ |
| 360 | 360 | public function replaceMetadataDir($dir, $namespacePrefix = '') |
| 361 | 361 | { |
| 362 | - if (!is_dir($dir)) { |
|
| 362 | + if ( ! is_dir($dir)) { |
|
| 363 | 363 | throw new InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir)); |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - if (!isset($this->metadataDirs[$namespacePrefix])) { |
|
| 366 | + if ( ! isset($this->metadataDirs[$namespacePrefix])) { |
|
| 367 | 367 | throw new InvalidArgumentException(sprintf('There is no directory configured for namespace prefix "%s". Please use addMetadataDir() for adding new directories.', $namespacePrefix)); |
| 368 | 368 | } |
| 369 | 369 | |
@@ -426,8 +426,8 @@ discard block |
||
| 426 | 426 | $annotationReader = new AnnotationReader(); |
| 427 | 427 | |
| 428 | 428 | if (null !== $this->cacheDir) { |
| 429 | - $this->createDir($this->cacheDir . '/annotations'); |
|
| 430 | - $annotationsCache = new FilesystemCache($this->cacheDir . '/annotations'); |
|
| 429 | + $this->createDir($this->cacheDir.'/annotations'); |
|
| 430 | + $annotationsCache = new FilesystemCache($this->cacheDir.'/annotations'); |
|
| 431 | 431 | $annotationReader = new CachedReader($annotationReader, $annotationsCache, $this->debug); |
| 432 | 432 | } |
| 433 | 433 | } |
@@ -443,19 +443,19 @@ discard block |
||
| 443 | 443 | $metadataFactory->setIncludeInterfaces($this->includeInterfaceMetadata); |
| 444 | 444 | |
| 445 | 445 | if (null !== $this->cacheDir) { |
| 446 | - $this->createDir($this->cacheDir . '/metadata'); |
|
| 447 | - $metadataFactory->setCache(new FileCache($this->cacheDir . '/metadata')); |
|
| 446 | + $this->createDir($this->cacheDir.'/metadata'); |
|
| 447 | + $metadataFactory->setCache(new FileCache($this->cacheDir.'/metadata')); |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - if (!$this->handlersConfigured) { |
|
| 450 | + if ( ! $this->handlersConfigured) { |
|
| 451 | 451 | $this->addDefaultHandlers(); |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | - if (!$this->listenersConfigured) { |
|
| 454 | + if ( ! $this->listenersConfigured) { |
|
| 455 | 455 | $this->addDefaultListeners(); |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - if (!$this->visitorsAdded) { |
|
| 458 | + if ( ! $this->visitorsAdded) { |
|
| 459 | 459 | $this->addDefaultSerializationVisitors(); |
| 460 | 460 | $this->addDefaultDeserializationVisitors(); |
| 461 | 461 | } |