@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | private $namingStrategy; |
| 44 | 44 | |
| 45 | - public function __construct(FileLocatorInterface $locator, PropertyNamingStrategyInterface $namingStrategy, ParserInterface $typeParser = null) |
|
| 45 | + public function __construct(FileLocatorInterface $locator, PropertyNamingStrategyInterface $namingStrategy, ParserInterface $typeParser = null) |
|
| 46 | 46 | { |
| 47 | 47 | parent::__construct($locator); |
| 48 | 48 | $this->typeParser = $typeParser ?: new Parser(); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | { |
| 54 | 54 | $config = Yaml::parse(file_get_contents($file)); |
| 55 | 55 | |
| 56 | - if (!isset($config[$name = $class->name])) { |
|
| 56 | + if ( ! isset($config[$name = $class->name])) { |
|
| 57 | 57 | throw new RuntimeException(sprintf('Expected metadata for class %s to be defined in %s.', $class->name, $file)); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | $metadata->fileResources[] = $file; |
| 63 | 63 | $metadata->fileResources[] = $class->getFileName(); |
| 64 | 64 | $exclusionPolicy = isset($config['exclusion_policy']) ? strtoupper($config['exclusion_policy']) : 'NONE'; |
| 65 | - $excludeAll = isset($config['exclude']) ? (Boolean)$config['exclude'] : false; |
|
| 65 | + $excludeAll = isset($config['exclude']) ? (Boolean) $config['exclude'] : false; |
|
| 66 | 66 | $classAccessType = isset($config['access_type']) ? $config['access_type'] : PropertyMetadata::ACCESS_TYPE_PROPERTY; |
| 67 | - $readOnlyClass = isset($config['read_only']) ? (Boolean)$config['read_only'] : false; |
|
| 67 | + $readOnlyClass = isset($config['read_only']) ? (Boolean) $config['read_only'] : false; |
|
| 68 | 68 | $this->addClassProperties($metadata, $config); |
| 69 | 69 | |
| 70 | 70 | $propertiesMetadata = array(); |
@@ -76,20 +76,20 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | } else { |
| 78 | 78 | |
| 79 | - if (!$class->hasMethod($methodName)) { |
|
| 80 | - throw new RuntimeException('The method ' . $methodName . ' not found in class ' . $class->name); |
|
| 79 | + if ( ! $class->hasMethod($methodName)) { |
|
| 80 | + throw new RuntimeException('The method '.$methodName.' not found in class '.$class->name); |
|
| 81 | 81 | } |
| 82 | 82 | $virtualPropertyMetadata = new VirtualPropertyMetadata($name, $methodName); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - $pName = !empty($propertySettings["name"]) ? $propertySettings["name"] : $virtualPropertyMetadata->name; |
|
| 85 | + $pName = ! empty($propertySettings["name"]) ? $propertySettings["name"] : $virtualPropertyMetadata->name; |
|
| 86 | 86 | |
| 87 | 87 | $propertiesMetadata[$pName] = $virtualPropertyMetadata; |
| 88 | 88 | $config['properties'][$pName] = $propertySettings; |
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if (!$excludeAll) { |
|
| 92 | + if ( ! $excludeAll) { |
|
| 93 | 93 | foreach ($class->getProperties() as $property) { |
| 94 | 94 | if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) { |
| 95 | 95 | continue; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $pConfig = $config['properties'][$pName]; |
| 110 | 110 | |
| 111 | 111 | if (isset($pConfig['exclude'])) { |
| 112 | - $isExclude = (Boolean)$pConfig['exclude']; |
|
| 112 | + $isExclude = (Boolean) $pConfig['exclude']; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | if ($isExclude) { |
@@ -117,35 +117,35 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | if (isset($pConfig['expose'])) { |
| 120 | - $isExpose = (Boolean)$pConfig['expose']; |
|
| 120 | + $isExpose = (Boolean) $pConfig['expose']; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | if (isset($pConfig['skip_when_empty'])) { |
| 124 | - $pMetadata->skipWhenEmpty = (Boolean)$pConfig['skip_when_empty']; |
|
| 124 | + $pMetadata->skipWhenEmpty = (Boolean) $pConfig['skip_when_empty']; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | if (isset($pConfig['since_version'])) { |
| 128 | - $pMetadata->sinceVersion = (string)$pConfig['since_version']; |
|
| 128 | + $pMetadata->sinceVersion = (string) $pConfig['since_version']; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | if (isset($pConfig['until_version'])) { |
| 132 | - $pMetadata->untilVersion = (string)$pConfig['until_version']; |
|
| 132 | + $pMetadata->untilVersion = (string) $pConfig['until_version']; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | if (isset($pConfig['exclude_if'])) { |
| 136 | - $pMetadata->excludeIf = (string)$pConfig['exclude_if']; |
|
| 136 | + $pMetadata->excludeIf = (string) $pConfig['exclude_if']; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | if (isset($pConfig['expose_if'])) { |
| 140 | - $pMetadata->excludeIf = "!(" . $pConfig['expose_if'] . ")"; |
|
| 140 | + $pMetadata->excludeIf = "!(".$pConfig['expose_if'].")"; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | if (isset($pConfig['serialized_name'])) { |
| 144 | - $pMetadata->serializedName = (string)$pConfig['serialized_name']; |
|
| 144 | + $pMetadata->serializedName = (string) $pConfig['serialized_name']; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | if (isset($pConfig['type'])) { |
| 148 | - $pMetadata->setType($this->typeParser->parse((string)$pConfig['type'])); |
|
| 148 | + $pMetadata->setType($this->typeParser->parse((string) $pConfig['type'])); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | if (isset($pConfig['groups'])) { |
@@ -157,21 +157,21 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | $colConfig = $pConfig['xml_list']; |
| 159 | 159 | if (isset($colConfig['inline'])) { |
| 160 | - $pMetadata->xmlCollectionInline = (Boolean)$colConfig['inline']; |
|
| 160 | + $pMetadata->xmlCollectionInline = (Boolean) $colConfig['inline']; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | if (isset($colConfig['entry_name'])) { |
| 164 | - $pMetadata->xmlEntryName = (string)$colConfig['entry_name']; |
|
| 164 | + $pMetadata->xmlEntryName = (string) $colConfig['entry_name']; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | if (isset($colConfig['skip_when_empty'])) { |
| 168 | - $pMetadata->xmlCollectionSkipWhenEmpty = (Boolean)$colConfig['skip_when_empty']; |
|
| 168 | + $pMetadata->xmlCollectionSkipWhenEmpty = (Boolean) $colConfig['skip_when_empty']; |
|
| 169 | 169 | } else { |
| 170 | 170 | $pMetadata->xmlCollectionSkipWhenEmpty = true; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | if (isset($colConfig['namespace'])) { |
| 174 | - $pMetadata->xmlEntryNamespace = (string)$colConfig['namespace']; |
|
| 174 | + $pMetadata->xmlEntryNamespace = (string) $colConfig['namespace']; |
|
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | |
@@ -180,15 +180,15 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | $colConfig = $pConfig['xml_map']; |
| 182 | 182 | if (isset($colConfig['inline'])) { |
| 183 | - $pMetadata->xmlCollectionInline = (Boolean)$colConfig['inline']; |
|
| 183 | + $pMetadata->xmlCollectionInline = (Boolean) $colConfig['inline']; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | if (isset($colConfig['entry_name'])) { |
| 187 | - $pMetadata->xmlEntryName = (string)$colConfig['entry_name']; |
|
| 187 | + $pMetadata->xmlEntryName = (string) $colConfig['entry_name']; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | if (isset($colConfig['namespace'])) { |
| 191 | - $pMetadata->xmlEntryNamespace = (string)$colConfig['namespace']; |
|
| 191 | + $pMetadata->xmlEntryNamespace = (string) $colConfig['namespace']; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | if (isset($colConfig['key_attribute_name'])) { |
@@ -200,33 +200,33 @@ discard block |
||
| 200 | 200 | if (isset($pConfig['xml_element'])) { |
| 201 | 201 | $colConfig = $pConfig['xml_element']; |
| 202 | 202 | if (isset($colConfig['cdata'])) { |
| 203 | - $pMetadata->xmlElementCData = (Boolean)$colConfig['cdata']; |
|
| 203 | + $pMetadata->xmlElementCData = (Boolean) $colConfig['cdata']; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | if (isset($colConfig['namespace'])) { |
| 207 | - $pMetadata->xmlNamespace = (string)$colConfig['namespace']; |
|
| 207 | + $pMetadata->xmlNamespace = (string) $colConfig['namespace']; |
|
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | if (isset($pConfig['xml_attribute'])) { |
| 212 | - $pMetadata->xmlAttribute = (Boolean)$pConfig['xml_attribute']; |
|
| 212 | + $pMetadata->xmlAttribute = (Boolean) $pConfig['xml_attribute']; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | if (isset($pConfig['xml_attribute_map'])) { |
| 216 | - $pMetadata->xmlAttributeMap = (Boolean)$pConfig['xml_attribute_map']; |
|
| 216 | + $pMetadata->xmlAttributeMap = (Boolean) $pConfig['xml_attribute_map']; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | if (isset($pConfig['xml_value'])) { |
| 220 | - $pMetadata->xmlValue = (Boolean)$pConfig['xml_value']; |
|
| 220 | + $pMetadata->xmlValue = (Boolean) $pConfig['xml_value']; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | if (isset($pConfig['xml_key_value_pairs'])) { |
| 224 | - $pMetadata->xmlKeyValuePairs = (Boolean)$pConfig['xml_key_value_pairs']; |
|
| 224 | + $pMetadata->xmlKeyValuePairs = (Boolean) $pConfig['xml_key_value_pairs']; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | //we need read_only before setter and getter set, because that method depends on flag being set |
| 228 | 228 | if (isset($pConfig['read_only'])) { |
| 229 | - $pMetadata->readOnly = (Boolean)$pConfig['read_only']; |
|
| 229 | + $pMetadata->readOnly = (Boolean) $pConfig['read_only']; |
|
| 230 | 230 | } else { |
| 231 | 231 | $pMetadata->readOnly = $pMetadata->readOnly || $readOnlyClass; |
| 232 | 232 | } |
@@ -238,15 +238,15 @@ discard block |
||
| 238 | 238 | ); |
| 239 | 239 | |
| 240 | 240 | if (isset($pConfig['inline'])) { |
| 241 | - $pMetadata->inline = (Boolean)$pConfig['inline']; |
|
| 241 | + $pMetadata->inline = (Boolean) $pConfig['inline']; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | if (isset($pConfig['max_depth'])) { |
| 245 | - $pMetadata->maxDepth = (int)$pConfig['max_depth']; |
|
| 245 | + $pMetadata->maxDepth = (int) $pConfig['max_depth']; |
|
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - if (!$pMetadata->serializedName) { |
|
| 249 | + if ( ! $pMetadata->serializedName) { |
|
| 250 | 250 | $pMetadata->serializedName = $this->namingStrategy->translateName($pMetadata); |
| 251 | 251 | } |
| 252 | 252 | |
@@ -254,11 +254,11 @@ discard block |
||
| 254 | 254 | $pConfig = $config['properties'][$pName]; |
| 255 | 255 | |
| 256 | 256 | if (isset($pConfig['name'])) { |
| 257 | - $pMetadata->name = (string)$pConfig['name']; |
|
| 257 | + $pMetadata->name = (string) $pConfig['name']; |
|
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - if ((ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude) |
|
| 261 | + if ((ExclusionPolicy::NONE === $exclusionPolicy && ! $isExclude) |
|
| 262 | 262 | || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose) |
| 263 | 263 | ) { |
| 264 | 264 | $metadata->addPropertyMetadata($pMetadata); |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | |
| 291 | 291 | private function addClassProperties(ClassMetadata $metadata, array $config) |
| 292 | 292 | { |
| 293 | - if (isset($config['custom_accessor_order']) && !isset($config['accessor_order'])) { |
|
| 293 | + if (isset($config['custom_accessor_order']) && ! isset($config['accessor_order'])) { |
|
| 294 | 294 | $config['accessor_order'] = 'custom'; |
| 295 | 295 | } |
| 296 | 296 | |
@@ -299,11 +299,11 @@ discard block |
||
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | if (isset($config['xml_root_name'])) { |
| 302 | - $metadata->xmlRootName = (string)$config['xml_root_name']; |
|
| 302 | + $metadata->xmlRootName = (string) $config['xml_root_name']; |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | if (isset($config['xml_root_namespace'])) { |
| 306 | - $metadata->xmlRootNamespace = (string)$config['xml_root_namespace']; |
|
| 306 | + $metadata->xmlRootNamespace = (string) $config['xml_root_namespace']; |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | if (array_key_exists('xml_namespaces', $config)) { |
@@ -318,25 +318,25 @@ discard block |
||
| 318 | 318 | if (isset($config['discriminator']['disabled']) && true === $config['discriminator']['disabled']) { |
| 319 | 319 | $metadata->discriminatorDisabled = true; |
| 320 | 320 | } else { |
| 321 | - if (!isset($config['discriminator']['field_name'])) { |
|
| 321 | + if ( ! isset($config['discriminator']['field_name'])) { |
|
| 322 | 322 | throw new RuntimeException('The "field_name" attribute must be set for discriminators.'); |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - if (!isset($config['discriminator']['map']) || !\is_array($config['discriminator']['map'])) { |
|
| 325 | + if ( ! isset($config['discriminator']['map']) || ! \is_array($config['discriminator']['map'])) { |
|
| 326 | 326 | throw new RuntimeException('The "map" attribute must be set, and be an array for discriminators.'); |
| 327 | 327 | } |
| 328 | 328 | $groups = isset($config['discriminator']['groups']) ? $config['discriminator']['groups'] : array(); |
| 329 | 329 | $metadata->setDiscriminator($config['discriminator']['field_name'], $config['discriminator']['map'], $groups); |
| 330 | 330 | |
| 331 | 331 | if (isset($config['discriminator']['xml_attribute'])) { |
| 332 | - $metadata->xmlDiscriminatorAttribute = (bool)$config['discriminator']['xml_attribute']; |
|
| 332 | + $metadata->xmlDiscriminatorAttribute = (bool) $config['discriminator']['xml_attribute']; |
|
| 333 | 333 | } |
| 334 | 334 | if (isset($config['discriminator']['xml_element'])) { |
| 335 | 335 | if (isset($config['discriminator']['xml_element']['cdata'])) { |
| 336 | - $metadata->xmlDiscriminatorCData = (bool)$config['discriminator']['xml_element']['cdata']; |
|
| 336 | + $metadata->xmlDiscriminatorCData = (bool) $config['discriminator']['xml_element']['cdata']; |
|
| 337 | 337 | } |
| 338 | 338 | if (isset($config['discriminator']['xml_element']['namespace'])) { |
| 339 | - $metadata->xmlDiscriminatorNamespace = (string)$config['discriminator']['xml_element']['namespace']; |
|
| 339 | + $metadata->xmlDiscriminatorNamespace = (string) $config['discriminator']['xml_element']['namespace']; |
|
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
@@ -348,13 +348,13 @@ discard block |
||
| 348 | 348 | { |
| 349 | 349 | if (\is_string($config)) { |
| 350 | 350 | $config = array($config); |
| 351 | - } elseif (!\is_array($config)) { |
|
| 351 | + } elseif ( ! \is_array($config)) { |
|
| 352 | 352 | throw new RuntimeException(sprintf('callback methods expects a string, or an array of strings that represent method names, but got %s.', json_encode($config['pre_serialize']))); |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | $methods = array(); |
| 356 | 356 | foreach ($config as $name) { |
| 357 | - if (!$class->hasMethod($name)) { |
|
| 357 | + if ( ! $class->hasMethod($name)) { |
|
| 358 | 358 | throw new RuntimeException(sprintf('The method %s does not exist in class %s.', $name, $class->name)); |
| 359 | 359 | } |
| 360 | 360 | |
@@ -53,32 +53,32 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | public function visitString($data, array $type): string |
| 55 | 55 | { |
| 56 | - return (string)$data; |
|
| 56 | + return (string) $data; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public function visitBoolean($data, array $type): bool |
| 60 | 60 | { |
| 61 | - return (bool)$data; |
|
| 61 | + return (bool) $data; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | public function visitInteger($data, array $type): int |
| 65 | 65 | { |
| 66 | - return (int)$data; |
|
| 66 | + return (int) $data; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public function visitDouble($data, array $type): float |
| 70 | 70 | { |
| 71 | - return (double)$data; |
|
| 71 | + return (double) $data; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | public function visitArray($data, array $type): array |
| 75 | 75 | { |
| 76 | - if (!\is_array($data)) { |
|
| 76 | + if ( ! \is_array($data)) { |
|
| 77 | 77 | throw new RuntimeException(sprintf('Expected array, but got %s: %s', \gettype($data), json_encode($data))); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // If no further parameters were given, keys/values are just passed as is. |
| 81 | - if (!$type['params']) { |
|
| 81 | + if ( ! $type['params']) { |
|
| 82 | 82 | return $data; |
| 83 | 83 | } |
| 84 | 84 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | public function visitDiscriminatorMapProperty($data, ClassMetadata $metadata): string |
| 114 | 114 | { |
| 115 | 115 | if (isset($data[$metadata->discriminatorFieldName])) { |
| 116 | - return (string)$data[$metadata->discriminatorFieldName]; |
|
| 116 | + return (string) $data[$metadata->discriminatorFieldName]; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | throw new LogicException(sprintf( |
@@ -136,15 +136,15 @@ discard block |
||
| 136 | 136 | return; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - if (!\is_array($data)) { |
|
| 139 | + if ( ! \is_array($data)) { |
|
| 140 | 140 | throw new RuntimeException(sprintf('Invalid data "%s"(%s), expected "%s".', $data, $metadata->type['name'], $metadata->reflection->class)); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - if (!array_key_exists($name, $data)) { |
|
| 143 | + if ( ! array_key_exists($name, $data)) { |
|
| 144 | 144 | return; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - if (!$metadata->type) { |
|
| 147 | + if ( ! $metadata->type) { |
|
| 148 | 148 | throw new RuntimeException(sprintf('You must define a type for %s::$%s.', $metadata->reflection->class, $metadata->name)); |
| 149 | 149 | } |
| 150 | 150 | |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $groups = $this->getGroupsFor($navigatorContext); |
| 57 | 57 | |
| 58 | - if (!$property->groups) { |
|
| 59 | - return !in_array(self::DEFAULT_GROUP, $groups); |
|
| 58 | + if ( ! $property->groups) { |
|
| 59 | + return ! in_array(self::DEFAULT_GROUP, $groups); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | return $this->shouldSkipUsingGroups($property, $groups); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | $groups = $this->groups; |
| 81 | 81 | foreach ($paths as $index => $path) { |
| 82 | - if (!array_key_exists($path, $groups)) { |
|
| 82 | + if ( ! array_key_exists($path, $groups)) { |
|
| 83 | 83 | if ($index > 0) { |
| 84 | 84 | $groups = array(self::DEFAULT_GROUP); |
| 85 | 85 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | break; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if (!is_array($groups[$path])) { |
|
| 90 | + if ( ! is_array($groups[$path])) { |
|
| 91 | 91 | throw new RuntimeException(sprintf('The group value for the property path "%s" should be an array, "%s" given', $index, gettype($groups[$path]))); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $this->addExclusionStrategy(new VersionExclusionStrategy($this->attributes['version'])); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if (!empty($this->attributes['max_depth_checks'])) { |
|
| 92 | + if ( ! empty($this->attributes['max_depth_checks'])) { |
|
| 93 | 93 | $this->addExclusionStrategy(new DepthExclusionStrategy()); |
| 94 | 94 | } |
| 95 | 95 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | private function assertMutable(): void |
| 138 | 138 | { |
| 139 | - if (!$this->initialized) { |
|
| 139 | + if ( ! $this->initialized) { |
|
| 140 | 140 | return; |
| 141 | 141 | } |
| 142 | 142 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | throw new LogicException('The groups must not be empty.'); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - $this->attributes['groups'] = (array)$groups; |
|
| 171 | + $this->attributes['groups'] = (array) $groups; |
|
| 172 | 172 | |
| 173 | 173 | return $this; |
| 174 | 174 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | { |
| 226 | 226 | $metadata = $this->metadataStack->pop(); |
| 227 | 227 | |
| 228 | - if (!$metadata instanceof PropertyMetadata) { |
|
| 228 | + if ( ! $metadata instanceof PropertyMetadata) { |
|
| 229 | 229 | throw new RuntimeException('Context metadataStack not working well'); |
| 230 | 230 | } |
| 231 | 231 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | { |
| 235 | 235 | $metadata = $this->metadataStack->pop(); |
| 236 | 236 | |
| 237 | - if (!$metadata instanceof ClassMetadata) { |
|
| 237 | + if ( ! $metadata instanceof ClassMetadata) { |
|
| 238 | 238 | throw new RuntimeException('Context metadataStack not working well'); |
| 239 | 239 | } |
| 240 | 240 | } |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | public function getCurrentPath() |
| 251 | 251 | { |
| 252 | - if (!$this->metadataStack) { |
|
| 252 | + if ( ! $this->metadataStack) { |
|
| 253 | 253 | return array(); |
| 254 | 254 | } |
| 255 | 255 | |
@@ -68,8 +68,7 @@ |
||
| 68 | 68 | AccessorStrategyInterface $accessor, |
| 69 | 69 | EventDispatcherInterface $dispatcher = null, |
| 70 | 70 | ExpressionEvaluatorInterface $expressionEvaluator = null |
| 71 | - ) |
|
| 72 | - { |
|
| 71 | + ) { |
|
| 73 | 72 | $this->dispatcher = $dispatcher ?: new EventDispatcher(); |
| 74 | 73 | $this->metadataFactory = $metadataFactory; |
| 75 | 74 | $this->handlerRegistry = $handlerRegistry; |
@@ -130,33 +130,33 @@ |
||
| 130 | 130 | |
| 131 | 131 | switch ($type['name']) { |
| 132 | 132 | case 'NULL': |
| 133 | - if (!$this->shouldSerializeNull) { |
|
| 133 | + if ( ! $this->shouldSerializeNull) { |
|
| 134 | 134 | throw new NotAcceptableException(); |
| 135 | 135 | } |
| 136 | 136 | return $this->visitor->visitNull($data, $type); |
| 137 | 137 | |
| 138 | 138 | case 'string': |
| 139 | - return $this->visitor->visitString((string)$data, $type); |
|
| 139 | + return $this->visitor->visitString((string) $data, $type); |
|
| 140 | 140 | |
| 141 | 141 | case 'int': |
| 142 | 142 | case 'integer': |
| 143 | - return $this->visitor->visitInteger((int)$data, $type); |
|
| 143 | + return $this->visitor->visitInteger((int) $data, $type); |
|
| 144 | 144 | |
| 145 | 145 | case 'bool': |
| 146 | 146 | case 'boolean': |
| 147 | - return $this->visitor->visitBoolean((bool)$data, $type); |
|
| 147 | + return $this->visitor->visitBoolean((bool) $data, $type); |
|
| 148 | 148 | |
| 149 | 149 | case 'double': |
| 150 | 150 | case 'float': |
| 151 | - return $this->visitor->visitDouble((float)$data, $type); |
|
| 151 | + return $this->visitor->visitDouble((float) $data, $type); |
|
| 152 | 152 | |
| 153 | 153 | case 'array': |
| 154 | - return $this->visitor->visitArray((array)$data, $type); |
|
| 154 | + return $this->visitor->visitArray((array) $data, $type); |
|
| 155 | 155 | |
| 156 | 156 | case 'resource': |
| 157 | 157 | $msg = 'Resources are not supported in serialized data.'; |
| 158 | 158 | if (null !== $path = $this->context->getPath()) { |
| 159 | - $msg .= ' Path: ' . $path; |
|
| 159 | + $msg .= ' Path: '.$path; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | throw new RuntimeException($msg); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | public static function getDefaultMethodName($eventName) |
| 39 | 39 | { |
| 40 | - return 'on' . str_replace(array('_', '.'), '', $eventName); |
|
| 40 | + return 'on'.str_replace(array('_', '.'), '', $eventName); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | public function addSubscriber(EventSubscriberInterface $subscriber) |
| 61 | 61 | { |
| 62 | 62 | foreach ($subscriber->getSubscribedEvents() as $eventData) { |
| 63 | - if (!isset($eventData['event'])) { |
|
| 63 | + if ( ! isset($eventData['event'])) { |
|
| 64 | 64 | throw new InvalidArgumentException(sprintf('Each event must have a "event" key.')); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -75,30 +75,30 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | public function hasListeners($eventName, $class, $format) |
| 77 | 77 | { |
| 78 | - if (!isset($this->listeners[$eventName])) { |
|
| 78 | + if ( ! isset($this->listeners[$eventName])) { |
|
| 79 | 79 | return false; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if (!isset($this->classListeners[$eventName][$class][$format])) { |
|
| 82 | + if ( ! isset($this->classListeners[$eventName][$class][$format])) { |
|
| 83 | 83 | $this->classListeners[$eventName][$class][$format] = $this->initializeListeners($eventName, $class, $format); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - return !!$this->classListeners[$eventName][$class][$format]; |
|
| 86 | + return ! ! $this->classListeners[$eventName][$class][$format]; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | public function dispatch($eventName, $class, $format, Event $event) |
| 90 | 90 | { |
| 91 | - if (!isset($this->listeners[$eventName])) { |
|
| 91 | + if ( ! isset($this->listeners[$eventName])) { |
|
| 92 | 92 | return; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $object = $event instanceof ObjectEvent ? $event->getObject() : null; |
| 96 | - $objectClass = $object ? (get_class($object) . $class) : $class; |
|
| 96 | + $objectClass = $object ? (get_class($object).$class) : $class; |
|
| 97 | 97 | |
| 98 | - if (!isset($this->classListeners[$eventName][$objectClass][$format])) { |
|
| 98 | + if ( ! isset($this->classListeners[$eventName][$objectClass][$format])) { |
|
| 99 | 99 | $this->classListeners[$eventName][$objectClass][$format] = array(); |
| 100 | 100 | foreach ($this->initializeListeners($eventName, $class, $format) as $listener) { |
| 101 | - if ($listener[3] !== null && !($object instanceof $listener[3])) { |
|
| 101 | + if ($listener[3] !== null && ! ($object instanceof $listener[3])) { |
|
| 102 | 102 | continue; |
| 103 | 103 | } |
| 104 | 104 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | public function __construct($container) |
| 32 | 32 | { |
| 33 | - if (!$container instanceof PsrContainerInterface && !$container instanceof ContainerInterface) { |
|
| 33 | + if ( ! $container instanceof PsrContainerInterface && ! $container instanceof ContainerInterface) { |
|
| 34 | 34 | 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))); |
| 35 | 35 | } |
| 36 | 36 | |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | $listeners = parent::initializeListeners($eventName, $loweredClass, $format); |
| 46 | 46 | |
| 47 | 47 | foreach ($listeners as &$listener) { |
| 48 | - if (!\is_array($listener[0]) || !\is_string($listener[0][0])) { |
|
| 48 | + if ( ! \is_array($listener[0]) || ! \is_string($listener[0][0])) { |
|
| 49 | 49 | continue; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - if (!$this->container->has($listener[0][0])) { |
|
| 52 | + if ( ! $this->container->has($listener[0][0])) { |
|
| 53 | 53 | continue; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | public function createRoot(ClassMetadata $metadata = null, $rootName = null, $rootNamespace = null) |
| 80 | 80 | { |
| 81 | - if ($metadata !== null && !empty($metadata->xmlRootName)) { |
|
| 81 | + if ($metadata !== null && ! empty($metadata->xmlRootName)) { |
|
| 82 | 82 | $rootName = $metadata->xmlRootName; |
| 83 | 83 | $rootNamespace = $metadata->xmlRootNamespace ?: $this->getClassDefaultNamespace($metadata); |
| 84 | 84 | } else { |
@@ -111,12 +111,12 @@ discard block |
||
| 111 | 111 | { |
| 112 | 112 | $doCData = null !== $this->currentMetadata ? $this->currentMetadata->xmlElementCData : true; |
| 113 | 113 | |
| 114 | - return $doCData ? $this->document->createCDATASection($data) : $this->document->createTextNode((string)$data); |
|
| 114 | + return $doCData ? $this->document->createCDATASection($data) : $this->document->createTextNode((string) $data); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | public function visitSimpleString($data, array $type) |
| 118 | 118 | { |
| 119 | - return $this->document->createTextNode((string)$data); |
|
| 119 | + return $this->document->createTextNode((string) $data); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | public function visitBoolean(bool $data, array $type) |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | public function visitInteger(int $data, array $type) |
| 128 | 128 | { |
| 129 | - return $this->document->createTextNode((string)$data); |
|
| 129 | + return $this->document->createTextNode((string) $data); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | public function visitDouble(float $data, array $type) |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | if (floor($data) === $data) { |
| 135 | 135 | return $this->document->createTextNode($data.".0"); |
| 136 | 136 | } else { |
| 137 | - return $this->document->createTextNode((string)$data); |
|
| 137 | + return $this->document->createTextNode((string) $data); |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
@@ -151,14 +151,14 @@ discard block |
||
| 151 | 151 | $elType = $this->getElementType($type); |
| 152 | 152 | foreach ($data as $k => $v) { |
| 153 | 153 | |
| 154 | - $tagName = (null !== $this->currentMetadata && $this->currentMetadata->xmlKeyValuePairs && $this->isElementNameValid((string)$k)) ? $k : $entryName; |
|
| 154 | + $tagName = (null !== $this->currentMetadata && $this->currentMetadata->xmlKeyValuePairs && $this->isElementNameValid((string) $k)) ? $k : $entryName; |
|
| 155 | 155 | |
| 156 | 156 | $entryNode = $this->createElement($tagName, $namespace); |
| 157 | 157 | $this->currentNode->appendChild($entryNode); |
| 158 | 158 | $this->setCurrentNode($entryNode); |
| 159 | 159 | |
| 160 | 160 | if (null !== $keyAttributeName) { |
| 161 | - $entryNode->setAttribute($keyAttributeName, (string)$k); |
|
| 161 | + $entryNode->setAttribute($keyAttributeName, (string) $k); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | try { |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | $node = $this->navigator->accept($v, $metadata->type); |
| 194 | 194 | $this->revertCurrentMetadata(); |
| 195 | 195 | |
| 196 | - if (!$node instanceof \DOMCharacterData) { |
|
| 196 | + if ( ! $node instanceof \DOMCharacterData) { |
|
| 197 | 197 | throw new RuntimeException(sprintf('Unsupported value for XML attribute for %s. Expected character data, but got %s.', $metadata->name, json_encode($v))); |
| 198 | 198 | } |
| 199 | 199 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | if (($metadata->xmlValue && $this->currentNode->childNodes->length > 0) |
| 206 | - || (!$metadata->xmlValue && $this->hasValue) |
|
| 206 | + || ( ! $metadata->xmlValue && $this->hasValue) |
|
| 207 | 207 | ) { |
| 208 | 208 | throw new RuntimeException(sprintf('If you make use of @XmlValue, all other properties in the class must have the @XmlAttribute annotation. Invalid usage detected in class %s.', $metadata->class)); |
| 209 | 209 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | $node = $this->navigator->accept($v, $metadata->type); |
| 216 | 216 | $this->revertCurrentMetadata(); |
| 217 | 217 | |
| 218 | - if (!$node instanceof \DOMCharacterData) { |
|
| 218 | + if ( ! $node instanceof \DOMCharacterData) { |
|
| 219 | 219 | throw new RuntimeException(sprintf('Unsupported value for property %s::$%s. Expected character data, but got %s.', $metadata->reflection->class, $metadata->reflection->name, \is_object($node) ? \get_class($node) : \gettype($node))); |
| 220 | 220 | } |
| 221 | 221 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | if ($metadata->xmlAttributeMap) { |
| 228 | - if (!\is_array($v)) { |
|
| 228 | + if ( ! \is_array($v)) { |
|
| 229 | 229 | throw new RuntimeException(sprintf('Unsupported value type for XML attribute map. Expected array but got %s.', \gettype($v))); |
| 230 | 230 | } |
| 231 | 231 | |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | $node = $this->navigator->accept($value, null); |
| 235 | 235 | $this->revertCurrentMetadata(); |
| 236 | 236 | |
| 237 | - if (!$node instanceof \DOMCharacterData) { |
|
| 237 | + if ( ! $node instanceof \DOMCharacterData) { |
|
| 238 | 238 | throw new RuntimeException(sprintf('Unsupported value for a XML attribute map value. Expected character data, but got %s.', json_encode($v))); |
| 239 | 239 | } |
| 240 | 240 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | return; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - if ($addEnclosingElement = !$this->isInLineCollection($metadata) && !$metadata->inline) { |
|
| 247 | + if ($addEnclosingElement = ! $this->isInLineCollection($metadata) && ! $metadata->inline) { |
|
| 248 | 248 | |
| 249 | 249 | $namespace = null !== $metadata->xmlNamespace |
| 250 | 250 | ? $metadata->xmlNamespace |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | |
| 295 | 295 | private function isSkippableEmptyObject($node, PropertyMetadata $metadata) |
| 296 | 296 | { |
| 297 | - return $node === null && !$metadata->xmlCollection && $metadata->skipWhenEmpty; |
|
| 297 | + return $node === null && ! $metadata->xmlCollection && $metadata->skipWhenEmpty; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | private function isSkippableCollection(PropertyMetadata $metadata) |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | |
| 305 | 305 | private function isElementEmpty(\DOMElement $element) |
| 306 | 306 | { |
| 307 | - return !$element->hasChildNodes() && !$element->hasAttributes(); |
|
| 307 | + return ! $element->hasChildNodes() && ! $element->hasAttributes(); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | public function endVisitingObject(ClassMetadata $metadata, object $data, array $type) |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | foreach ($metadata->xmlNamespaces as $prefix => $uri) { |
| 412 | 412 | $attribute = 'xmlns'; |
| 413 | 413 | if ($prefix !== '') { |
| 414 | - $attribute .= ':' . $prefix; |
|
| 414 | + $attribute .= ':'.$prefix; |
|
| 415 | 415 | } elseif ($element->namespaceURI === $uri) { |
| 416 | 416 | continue; |
| 417 | 417 | } |
@@ -427,19 +427,19 @@ discard block |
||
| 427 | 427 | if ($this->currentNode->isDefaultNamespace($namespace)) { |
| 428 | 428 | return $this->document->createElementNS($namespace, $tagName); |
| 429 | 429 | } |
| 430 | - if (!($prefix = $this->currentNode->lookupPrefix($namespace)) && !($prefix = $this->document->lookupPrefix($namespace))) { |
|
| 431 | - $prefix = 'ns-' . substr(sha1($namespace), 0, 8); |
|
| 430 | + if ( ! ($prefix = $this->currentNode->lookupPrefix($namespace)) && ! ($prefix = $this->document->lookupPrefix($namespace))) { |
|
| 431 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
| 432 | 432 | } |
| 433 | - return $this->document->createElementNS($namespace, $prefix . ':' . $tagName); |
|
| 433 | + return $this->document->createElementNS($namespace, $prefix.':'.$tagName); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | private function setAttributeOnNode(\DOMElement $node, $name, $value, $namespace = null) |
| 437 | 437 | { |
| 438 | 438 | if (null !== $namespace) { |
| 439 | - if (!$prefix = $node->lookupPrefix($namespace)) { |
|
| 440 | - $prefix = 'ns-' . substr(sha1($namespace), 0, 8); |
|
| 439 | + if ( ! $prefix = $node->lookupPrefix($namespace)) { |
|
| 440 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
| 441 | 441 | } |
| 442 | - $node->setAttributeNS($namespace, $prefix . ':' . $name, $value); |
|
| 442 | + $node->setAttributeNS($namespace, $prefix.':'.$name, $value); |
|
| 443 | 443 | } else { |
| 444 | 444 | $node->setAttribute($name, $value); |
| 445 | 445 | } |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | /** @var $metadata ClassMetadata */ |
| 154 | 154 | $metadata = $this->metadataFactory->getMetadataForClass($type['name']); |
| 155 | 155 | |
| 156 | - if ($metadata->usingExpression && !$this->expressionExclusionStrategy) { |
|
| 156 | + if ($metadata->usingExpression && ! $this->expressionExclusionStrategy) { |
|
| 157 | 157 | throw new ExpressionLanguageRequiredException("To use conditional exclude/expose in {$metadata->name} you must configure the expression language."); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - if (!empty($metadata->discriminatorMap) && $type['name'] === $metadata->discriminatorBaseClass) { |
|
| 160 | + if ( ! empty($metadata->discriminatorMap) && $type['name'] === $metadata->discriminatorBaseClass) { |
|
| 161 | 161 | $metadata = $this->resolveMetadata($data, $metadata); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | try { |
| 190 | 190 | $v = $this->visitor->visitProperty($propertyMetadata, $data); |
| 191 | 191 | $this->accessor->setValue($object, $v, $propertyMetadata); |
| 192 | - }catch (NotAcceptableException $e){ |
|
| 192 | + } catch (NotAcceptableException $e) { |
|
| 193 | 193 | |
| 194 | 194 | } |
| 195 | 195 | $this->context->popPropertyMetadata(); |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | { |
| 207 | 207 | $typeValue = $this->visitor->visitDiscriminatorMapProperty($data, $metadata); |
| 208 | 208 | |
| 209 | - if (!isset($metadata->discriminatorMap[$typeValue])) { |
|
| 209 | + if ( ! isset($metadata->discriminatorMap[$typeValue])) { |
|
| 210 | 210 | throw new LogicException(sprintf( |
| 211 | 211 | 'The type value "%s" does not exist in the discriminator map of class "%s". Available types: %s', |
| 212 | 212 | $typeValue, |
@@ -189,7 +189,7 @@ |
||
| 189 | 189 | try { |
| 190 | 190 | $v = $this->visitor->visitProperty($propertyMetadata, $data); |
| 191 | 191 | $this->accessor->setValue($object, $v, $propertyMetadata); |
| 192 | - }catch (NotAcceptableException $e){ |
|
| 192 | + } catch (NotAcceptableException $e) { |
|
| 193 | 193 | |
| 194 | 194 | } |
| 195 | 195 | $this->context->popPropertyMetadata(); |