@@ -16,8 +16,7 @@ |
||
| 16 | 16 | array $metadataDirs, |
| 17 | 17 | Reader $annotationReader, |
| 18 | 18 | ClassMetadataUpdaterInterface $propertyUpdater = null |
| 19 | - ) |
|
| 20 | - { |
|
| 19 | + ) { |
|
| 21 | 20 | $annotationDriver = new AnnotationDriver($annotationReader, $propertyUpdater); |
| 22 | 21 | if (empty($metadataDirs)) { |
| 23 | 22 | return $annotationDriver; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $this->name = $name; |
| 80 | 80 | $this->prepareLazyReflection(); |
| 81 | 81 | |
| 82 | - $this->closureAccessor = \Closure::bind(function ($o, $name) { |
|
| 82 | + $this->closureAccessor = \Closure::bind(function($o, $name) { |
|
| 83 | 83 | return $o->$name; |
| 84 | 84 | }, null, $class); |
| 85 | 85 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | public function getReflection() |
| 99 | 99 | { |
| 100 | - if (!$this->lazyReflection) { |
|
| 100 | + if ( ! $this->lazyReflection) { |
|
| 101 | 101 | $this->lazyReflection = new \ReflectionProperty($this->class, $this->name); |
| 102 | 102 | $this->lazyReflection->setAccessible(true); |
| 103 | 103 | } |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | list($this->class, $this->name) = unserialize($parentStr); |
| 229 | 229 | $this->prepareLazyReflection(); |
| 230 | 230 | |
| 231 | - $this->closureAccessor = \Closure::bind(function ($o, $name) { |
|
| 231 | + $this->closureAccessor = \Closure::bind(function($o, $name) { |
|
| 232 | 232 | return $o->$name; |
| 233 | 233 | }, null, $this->class); |
| 234 | 234 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | { |
| 51 | 51 | $config = Yaml::parse(file_get_contents($file)); |
| 52 | 52 | |
| 53 | - if (!isset($config[$name = $class->name])) { |
|
| 53 | + if ( ! isset($config[$name = $class->name])) { |
|
| 54 | 54 | throw new RuntimeException(sprintf('Expected metadata for class %s to be defined in %s.', $class->name, $file)); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -59,10 +59,10 @@ discard block |
||
| 59 | 59 | $metadata->fileResources[] = $file; |
| 60 | 60 | $metadata->fileResources[] = $class->getFileName(); |
| 61 | 61 | $exclusionPolicy = isset($config['exclusion_policy']) ? strtoupper($config['exclusion_policy']) : 'NONE'; |
| 62 | - $excludeAll = isset($config['exclude']) ? (Boolean)$config['exclude'] : false; |
|
| 62 | + $excludeAll = isset($config['exclude']) ? (Boolean) $config['exclude'] : false; |
|
| 63 | 63 | $metadata->accessType = isset($config['access_type']) ? $config['access_type'] : null; |
| 64 | 64 | $metadata->accessTypeNaming = isset($config['access_type_naming']) ? $config['access_type_naming'] : null; |
| 65 | - $readOnlyClass = isset($config['read_only']) ? (Boolean)$config['read_only'] : false; |
|
| 65 | + $readOnlyClass = isset($config['read_only']) ? (Boolean) $config['read_only'] : false; |
|
| 66 | 66 | $this->addClassProperties($metadata, $config); |
| 67 | 67 | |
| 68 | 68 | $propertiesMetadata = array(); |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | } else { |
| 76 | 76 | |
| 77 | - if (!$class->hasMethod($methodName)) { |
|
| 78 | - throw new RuntimeException('The method ' . $methodName . ' not found in class ' . $class->name); |
|
| 77 | + if ( ! $class->hasMethod($methodName)) { |
|
| 78 | + throw new RuntimeException('The method '.$methodName.' not found in class '.$class->name); |
|
| 79 | 79 | } |
| 80 | 80 | $virtualPropertyMetadata = new VirtualPropertyMetadata($name, $methodName); |
| 81 | 81 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if (!$excludeAll) { |
|
| 87 | + if ( ! $excludeAll) { |
|
| 88 | 88 | foreach ($class->getProperties() as $property) { |
| 89 | 89 | if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) { |
| 90 | 90 | continue; |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $pConfig = $config['properties'][$pName]; |
| 106 | 106 | |
| 107 | 107 | if (isset($pConfig['exclude'])) { |
| 108 | - $isExclude = (Boolean)$pConfig['exclude']; |
|
| 108 | + $isExclude = (Boolean) $pConfig['exclude']; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | if ($isExclude) { |
@@ -113,35 +113,35 @@ discard block |
||
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | if (isset($pConfig['expose'])) { |
| 116 | - $isExpose = (Boolean)$pConfig['expose']; |
|
| 116 | + $isExpose = (Boolean) $pConfig['expose']; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | if (isset($pConfig['skip_when_empty'])) { |
| 120 | - $pMetadata->skipWhenEmpty = (Boolean)$pConfig['skip_when_empty']; |
|
| 120 | + $pMetadata->skipWhenEmpty = (Boolean) $pConfig['skip_when_empty']; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | if (isset($pConfig['since_version'])) { |
| 124 | - $pMetadata->sinceVersion = (string)$pConfig['since_version']; |
|
| 124 | + $pMetadata->sinceVersion = (string) $pConfig['since_version']; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | if (isset($pConfig['until_version'])) { |
| 128 | - $pMetadata->untilVersion = (string)$pConfig['until_version']; |
|
| 128 | + $pMetadata->untilVersion = (string) $pConfig['until_version']; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | if (isset($pConfig['exclude_if'])) { |
| 132 | - $pMetadata->excludeIf = (string)$pConfig['exclude_if']; |
|
| 132 | + $pMetadata->excludeIf = (string) $pConfig['exclude_if']; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | if (isset($pConfig['expose_if'])) { |
| 136 | - $pMetadata->excludeIf = "!(" . $pConfig['expose_if'] . ")"; |
|
| 136 | + $pMetadata->excludeIf = "!(".$pConfig['expose_if'].")"; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | if (isset($pConfig['serialized_name'])) { |
| 140 | - $pMetadata->serializedName = (string)$pConfig['serialized_name']; |
|
| 140 | + $pMetadata->serializedName = (string) $pConfig['serialized_name']; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | if (isset($pConfig['type'])) { |
| 144 | - $pMetadata->setType((string)$pConfig['type']); |
|
| 144 | + $pMetadata->setType((string) $pConfig['type']); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | if (isset($pConfig['groups'])) { |
@@ -153,21 +153,21 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | $colConfig = $pConfig['xml_list']; |
| 155 | 155 | if (isset($colConfig['inline'])) { |
| 156 | - $pMetadata->xmlCollectionInline = (Boolean)$colConfig['inline']; |
|
| 156 | + $pMetadata->xmlCollectionInline = (Boolean) $colConfig['inline']; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | if (isset($colConfig['entry_name'])) { |
| 160 | - $pMetadata->xmlEntryName = (string)$colConfig['entry_name']; |
|
| 160 | + $pMetadata->xmlEntryName = (string) $colConfig['entry_name']; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | if (isset($colConfig['skip_when_empty'])) { |
| 164 | - $pMetadata->xmlCollectionSkipWhenEmpty = (Boolean)$colConfig['skip_when_empty']; |
|
| 164 | + $pMetadata->xmlCollectionSkipWhenEmpty = (Boolean) $colConfig['skip_when_empty']; |
|
| 165 | 165 | } else { |
| 166 | 166 | $pMetadata->xmlCollectionSkipWhenEmpty = true; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | if (isset($colConfig['namespace'])) { |
| 170 | - $pMetadata->xmlEntryNamespace = (string)$colConfig['namespace']; |
|
| 170 | + $pMetadata->xmlEntryNamespace = (string) $colConfig['namespace']; |
|
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | |
@@ -176,15 +176,15 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | $colConfig = $pConfig['xml_map']; |
| 178 | 178 | if (isset($colConfig['inline'])) { |
| 179 | - $pMetadata->xmlCollectionInline = (Boolean)$colConfig['inline']; |
|
| 179 | + $pMetadata->xmlCollectionInline = (Boolean) $colConfig['inline']; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | if (isset($colConfig['entry_name'])) { |
| 183 | - $pMetadata->xmlEntryName = (string)$colConfig['entry_name']; |
|
| 183 | + $pMetadata->xmlEntryName = (string) $colConfig['entry_name']; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | if (isset($colConfig['namespace'])) { |
| 187 | - $pMetadata->xmlEntryNamespace = (string)$colConfig['namespace']; |
|
| 187 | + $pMetadata->xmlEntryNamespace = (string) $colConfig['namespace']; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | if (isset($colConfig['key_attribute_name'])) { |
@@ -196,33 +196,33 @@ discard block |
||
| 196 | 196 | if (isset($pConfig['xml_element'])) { |
| 197 | 197 | $colConfig = $pConfig['xml_element']; |
| 198 | 198 | if (isset($colConfig['cdata'])) { |
| 199 | - $pMetadata->xmlElementCData = (Boolean)$colConfig['cdata']; |
|
| 199 | + $pMetadata->xmlElementCData = (Boolean) $colConfig['cdata']; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | if (isset($colConfig['namespace'])) { |
| 203 | - $pMetadata->xmlNamespace = (string)$colConfig['namespace']; |
|
| 203 | + $pMetadata->xmlNamespace = (string) $colConfig['namespace']; |
|
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | if (isset($pConfig['xml_attribute'])) { |
| 208 | - $pMetadata->xmlAttribute = (Boolean)$pConfig['xml_attribute']; |
|
| 208 | + $pMetadata->xmlAttribute = (Boolean) $pConfig['xml_attribute']; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | if (isset($pConfig['xml_attribute_map'])) { |
| 212 | - $pMetadata->xmlAttributeMap = (Boolean)$pConfig['xml_attribute_map']; |
|
| 212 | + $pMetadata->xmlAttributeMap = (Boolean) $pConfig['xml_attribute_map']; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | if (isset($pConfig['xml_value'])) { |
| 216 | - $pMetadata->xmlValue = (Boolean)$pConfig['xml_value']; |
|
| 216 | + $pMetadata->xmlValue = (Boolean) $pConfig['xml_value']; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | if (isset($pConfig['xml_key_value_pairs'])) { |
| 220 | - $pMetadata->xmlKeyValuePairs = (Boolean)$pConfig['xml_key_value_pairs']; |
|
| 220 | + $pMetadata->xmlKeyValuePairs = (Boolean) $pConfig['xml_key_value_pairs']; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | //we need read_only before setter and getter set, because that method depends on flag being set |
| 224 | 224 | if (isset($pConfig['read_only'])) { |
| 225 | - $pMetadata->readOnly = (Boolean)$pConfig['read_only']; |
|
| 225 | + $pMetadata->readOnly = (Boolean) $pConfig['read_only']; |
|
| 226 | 226 | } else { |
| 227 | 227 | $pMetadata->readOnly = $pMetadata->readOnly || $readOnlyClass; |
| 228 | 228 | } |
@@ -235,14 +235,14 @@ discard block |
||
| 235 | 235 | ); |
| 236 | 236 | |
| 237 | 237 | if (isset($pConfig['inline'])) { |
| 238 | - $pMetadata->inline = (Boolean)$pConfig['inline']; |
|
| 238 | + $pMetadata->inline = (Boolean) $pConfig['inline']; |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | if (isset($pConfig['max_depth'])) { |
| 242 | - $pMetadata->maxDepth = (int)$pConfig['max_depth']; |
|
| 242 | + $pMetadata->maxDepth = (int) $pConfig['max_depth']; |
|
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | - if ((ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude) |
|
| 245 | + if ((ExclusionPolicy::NONE === $exclusionPolicy && ! $isExclude) |
|
| 246 | 246 | || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose) |
| 247 | 247 | ) { |
| 248 | 248 | $metadata->addPropertyMetadata($pMetadata); |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | private function addClassProperties(ClassMetadata $metadata, array $config) |
| 287 | 287 | { |
| 288 | - if (isset($config['custom_accessor_order']) && !isset($config['accessor_order'])) { |
|
| 288 | + if (isset($config['custom_accessor_order']) && ! isset($config['accessor_order'])) { |
|
| 289 | 289 | $config['accessor_order'] = 'custom'; |
| 290 | 290 | } |
| 291 | 291 | |
@@ -294,11 +294,11 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | if (isset($config['xml_root_name'])) { |
| 297 | - $metadata->xmlRootName = (string)$config['xml_root_name']; |
|
| 297 | + $metadata->xmlRootName = (string) $config['xml_root_name']; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | if (isset($config['xml_root_namespace'])) { |
| 301 | - $metadata->xmlRootNamespace = (string)$config['xml_root_namespace']; |
|
| 301 | + $metadata->xmlRootNamespace = (string) $config['xml_root_namespace']; |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | if (array_key_exists('xml_namespaces', $config)) { |
@@ -313,25 +313,25 @@ discard block |
||
| 313 | 313 | if (isset($config['discriminator']['disabled']) && true === $config['discriminator']['disabled']) { |
| 314 | 314 | $metadata->discriminatorDisabled = true; |
| 315 | 315 | } else { |
| 316 | - if (!isset($config['discriminator']['field_name'])) { |
|
| 316 | + if ( ! isset($config['discriminator']['field_name'])) { |
|
| 317 | 317 | throw new RuntimeException('The "field_name" attribute must be set for discriminators.'); |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - if (!isset($config['discriminator']['map']) || !\is_array($config['discriminator']['map'])) { |
|
| 320 | + if ( ! isset($config['discriminator']['map']) || ! \is_array($config['discriminator']['map'])) { |
|
| 321 | 321 | throw new RuntimeException('The "map" attribute must be set, and be an array for discriminators.'); |
| 322 | 322 | } |
| 323 | 323 | $groups = isset($config['discriminator']['groups']) ? $config['discriminator']['groups'] : array(); |
| 324 | 324 | $metadata->setDiscriminator($config['discriminator']['field_name'], $config['discriminator']['map'], $groups); |
| 325 | 325 | |
| 326 | 326 | if (isset($config['discriminator']['xml_attribute'])) { |
| 327 | - $metadata->xmlDiscriminatorAttribute = (bool)$config['discriminator']['xml_attribute']; |
|
| 327 | + $metadata->xmlDiscriminatorAttribute = (bool) $config['discriminator']['xml_attribute']; |
|
| 328 | 328 | } |
| 329 | 329 | if (isset($config['discriminator']['xml_element'])) { |
| 330 | 330 | if (isset($config['discriminator']['xml_element']['cdata'])) { |
| 331 | - $metadata->xmlDiscriminatorCData = (bool)$config['discriminator']['xml_element']['cdata']; |
|
| 331 | + $metadata->xmlDiscriminatorCData = (bool) $config['discriminator']['xml_element']['cdata']; |
|
| 332 | 332 | } |
| 333 | 333 | if (isset($config['discriminator']['xml_element']['namespace'])) { |
| 334 | - $metadata->xmlDiscriminatorNamespace = (string)$config['discriminator']['xml_element']['namespace']; |
|
| 334 | + $metadata->xmlDiscriminatorNamespace = (string) $config['discriminator']['xml_element']['namespace']; |
|
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | |
@@ -343,13 +343,13 @@ discard block |
||
| 343 | 343 | { |
| 344 | 344 | if (\is_string($config)) { |
| 345 | 345 | $config = array($config); |
| 346 | - } elseif (!\is_array($config)) { |
|
| 346 | + } elseif ( ! \is_array($config)) { |
|
| 347 | 347 | 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']))); |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | $methods = array(); |
| 351 | 351 | foreach ($config as $name) { |
| 352 | - if (!$class->hasMethod($name)) { |
|
| 352 | + if ( ! $class->hasMethod($name)) { |
|
| 353 | 353 | throw new RuntimeException(sprintf('The method %s does not exist in class %s.', $name, $class->name)); |
| 354 | 354 | } |
| 355 | 355 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $metadata = new ClassMetadata($name = $class->name); |
| 61 | - if (!$elems = $elem->xpath("./class[@name = '" . $name . "']")) { |
|
| 61 | + if ( ! $elems = $elem->xpath("./class[@name = '".$name."']")) { |
|
| 62 | 62 | throw new RuntimeException(sprintf('Could not find class %s inside XML element.', $name)); |
| 63 | 63 | } |
| 64 | 64 | $elem = reset($elems); |
@@ -74,82 +74,82 @@ discard block |
||
| 74 | 74 | $propertiesNodes = array(); |
| 75 | 75 | |
| 76 | 76 | if (null !== $accessorOrder = $elem->attributes()->{'accessor-order'}) { |
| 77 | - $metadata->setAccessorOrder((string)$accessorOrder, preg_split('/\s*,\s*/', (string)$elem->attributes()->{'custom-accessor-order'})); |
|
| 77 | + $metadata->setAccessorOrder((string) $accessorOrder, preg_split('/\s*,\s*/', (string) $elem->attributes()->{'custom-accessor-order'})); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | if (null !== $xmlRootName = $elem->attributes()->{'xml-root-name'}) { |
| 81 | - $metadata->xmlRootName = (string)$xmlRootName; |
|
| 81 | + $metadata->xmlRootName = (string) $xmlRootName; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | if (null !== $xmlRootNamespace = $elem->attributes()->{'xml-root-namespace'}) { |
| 85 | - $metadata->xmlRootNamespace = (string)$xmlRootNamespace; |
|
| 85 | + $metadata->xmlRootNamespace = (string) $xmlRootNamespace; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | $readOnlyClass = 'true' === strtolower($elem->attributes()->{'read-only'}); |
| 89 | 89 | |
| 90 | - $discriminatorFieldName = (string)$elem->attributes()->{'discriminator-field-name'}; |
|
| 90 | + $discriminatorFieldName = (string) $elem->attributes()->{'discriminator-field-name'}; |
|
| 91 | 91 | $discriminatorMap = array(); |
| 92 | 92 | foreach ($elem->xpath('./discriminator-class') as $entry) { |
| 93 | - if (!isset($entry->attributes()->value)) { |
|
| 93 | + if ( ! isset($entry->attributes()->value)) { |
|
| 94 | 94 | throw new RuntimeException('Each discriminator-class element must have a "value" attribute.'); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - $discriminatorMap[(string)$entry->attributes()->value] = (string)$entry; |
|
| 97 | + $discriminatorMap[(string) $entry->attributes()->value] = (string) $entry; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if ('true' === (string)$elem->attributes()->{'discriminator-disabled'}) { |
|
| 100 | + if ('true' === (string) $elem->attributes()->{'discriminator-disabled'}) { |
|
| 101 | 101 | $metadata->discriminatorDisabled = true; |
| 102 | - } elseif (!empty($discriminatorFieldName) || !empty($discriminatorMap)) { |
|
| 102 | + } elseif ( ! empty($discriminatorFieldName) || ! empty($discriminatorMap)) { |
|
| 103 | 103 | |
| 104 | 104 | $discriminatorGroups = array(); |
| 105 | 105 | foreach ($elem->xpath('./discriminator-groups/group') as $entry) { |
| 106 | - $discriminatorGroups[] = (string)$entry; |
|
| 106 | + $discriminatorGroups[] = (string) $entry; |
|
| 107 | 107 | } |
| 108 | 108 | $metadata->setDiscriminator($discriminatorFieldName, $discriminatorMap, $discriminatorGroups); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | foreach ($elem->xpath('./xml-namespace') as $xmlNamespace) { |
| 112 | - if (!isset($xmlNamespace->attributes()->uri)) { |
|
| 112 | + if ( ! isset($xmlNamespace->attributes()->uri)) { |
|
| 113 | 113 | throw new RuntimeException('The prefix attribute must be set for all xml-namespace elements.'); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | if (isset($xmlNamespace->attributes()->prefix)) { |
| 117 | - $prefix = (string)$xmlNamespace->attributes()->prefix; |
|
| 117 | + $prefix = (string) $xmlNamespace->attributes()->prefix; |
|
| 118 | 118 | } else { |
| 119 | 119 | $prefix = null; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - $metadata->registerNamespace((string)$xmlNamespace->attributes()->uri, $prefix); |
|
| 122 | + $metadata->registerNamespace((string) $xmlNamespace->attributes()->uri, $prefix); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | foreach ($elem->xpath('./xml-discriminator') as $xmlDiscriminator) { |
| 126 | 126 | if (isset($xmlDiscriminator->attributes()->attribute)) { |
| 127 | - $metadata->xmlDiscriminatorAttribute = (string)$xmlDiscriminator->attributes()->attribute === 'true'; |
|
| 127 | + $metadata->xmlDiscriminatorAttribute = (string) $xmlDiscriminator->attributes()->attribute === 'true'; |
|
| 128 | 128 | } |
| 129 | 129 | if (isset($xmlDiscriminator->attributes()->cdata)) { |
| 130 | - $metadata->xmlDiscriminatorCData = (string)$xmlDiscriminator->attributes()->cdata === 'true'; |
|
| 130 | + $metadata->xmlDiscriminatorCData = (string) $xmlDiscriminator->attributes()->cdata === 'true'; |
|
| 131 | 131 | } |
| 132 | 132 | if (isset($xmlDiscriminator->attributes()->namespace)) { |
| 133 | - $metadata->xmlDiscriminatorNamespace = (string)$xmlDiscriminator->attributes()->namespace; |
|
| 133 | + $metadata->xmlDiscriminatorNamespace = (string) $xmlDiscriminator->attributes()->namespace; |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | foreach ($elem->xpath('./virtual-property') as $method) { |
| 138 | 138 | |
| 139 | 139 | if (isset($method->attributes()->expression)) { |
| 140 | - $virtualPropertyMetadata = new ExpressionPropertyMetadata($name, (string)$method->attributes()->name, (string)$method->attributes()->expression); |
|
| 140 | + $virtualPropertyMetadata = new ExpressionPropertyMetadata($name, (string) $method->attributes()->name, (string) $method->attributes()->expression); |
|
| 141 | 141 | } else { |
| 142 | - if (!isset($method->attributes()->method)) { |
|
| 142 | + if ( ! isset($method->attributes()->method)) { |
|
| 143 | 143 | throw new RuntimeException('The method attribute must be set for all virtual-property elements.'); |
| 144 | 144 | } |
| 145 | - $virtualPropertyMetadata = new VirtualPropertyMetadata($name, (string)$method->attributes()->method); |
|
| 145 | + $virtualPropertyMetadata = new VirtualPropertyMetadata($name, (string) $method->attributes()->method); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | $propertiesMetadata[] = $virtualPropertyMetadata; |
| 149 | 149 | $propertiesNodes[] = $method; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - if (!$excludeAll) { |
|
| 152 | + if ( ! $excludeAll) { |
|
| 153 | 153 | |
| 154 | 154 | foreach ($class->getProperties() as $property) { |
| 155 | 155 | if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) { |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | $propertiesMetadata[] = new PropertyMetadata($name, $pName = $property->getName()); |
| 160 | - $pElems = $elem->xpath("./property[@name = '" . $pName . "']"); |
|
| 160 | + $pElems = $elem->xpath("./property[@name = '".$pName."']"); |
|
| 161 | 161 | |
| 162 | 162 | $propertiesNodes[] = $pElems ? reset($pElems) : null; |
| 163 | 163 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | || $pMetadata instanceof ExpressionPropertyMetadata; |
| 171 | 171 | |
| 172 | 172 | $pElem = $propertiesNodes[$propertyKey]; |
| 173 | - if (!empty($pElem)) { |
|
| 173 | + if ( ! empty($pElem)) { |
|
| 174 | 174 | |
| 175 | 175 | if (null !== $exclude = $pElem->attributes()->exclude) { |
| 176 | 176 | $isExclude = 'true' === strtolower($exclude); |
@@ -193,26 +193,26 @@ discard block |
||
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | if (null !== $excludeIf = $pElem->attributes()->{'expose-if'}) { |
| 196 | - $pMetadata->excludeIf = "!(" . $excludeIf . ")"; |
|
| 196 | + $pMetadata->excludeIf = "!(".$excludeIf.")"; |
|
| 197 | 197 | $isExpose = true; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | if (null !== $version = $pElem->attributes()->{'since-version'}) { |
| 201 | - $pMetadata->sinceVersion = (string)$version; |
|
| 201 | + $pMetadata->sinceVersion = (string) $version; |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | if (null !== $version = $pElem->attributes()->{'until-version'}) { |
| 205 | - $pMetadata->untilVersion = (string)$version; |
|
| 205 | + $pMetadata->untilVersion = (string) $version; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | if (null !== $serializedName = $pElem->attributes()->{'serialized-name'}) { |
| 209 | - $pMetadata->serializedName = (string)$serializedName; |
|
| 209 | + $pMetadata->serializedName = (string) $serializedName; |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | if (null !== $type = $pElem->attributes()->type) { |
| 213 | - $pMetadata->setType((string)$type); |
|
| 213 | + $pMetadata->setType((string) $type); |
|
| 214 | 214 | } elseif (isset($pElem->type)) { |
| 215 | - $pMetadata->setType((string)$pElem->type); |
|
| 215 | + $pMetadata->setType((string) $pElem->type); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | if (null !== $groups = $pElem->attributes()->groups) { |
@@ -227,21 +227,21 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | $colConfig = $pElem->{'xml-list'}; |
| 229 | 229 | if (isset($colConfig->attributes()->inline)) { |
| 230 | - $pMetadata->xmlCollectionInline = 'true' === (string)$colConfig->attributes()->inline; |
|
| 230 | + $pMetadata->xmlCollectionInline = 'true' === (string) $colConfig->attributes()->inline; |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | if (isset($colConfig->attributes()->{'entry-name'})) { |
| 234 | - $pMetadata->xmlEntryName = (string)$colConfig->attributes()->{'entry-name'}; |
|
| 234 | + $pMetadata->xmlEntryName = (string) $colConfig->attributes()->{'entry-name'}; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | if (isset($colConfig->attributes()->{'skip-when-empty'})) { |
| 238 | - $pMetadata->xmlCollectionSkipWhenEmpty = 'true' === (string)$colConfig->attributes()->{'skip-when-empty'}; |
|
| 238 | + $pMetadata->xmlCollectionSkipWhenEmpty = 'true' === (string) $colConfig->attributes()->{'skip-when-empty'}; |
|
| 239 | 239 | } else { |
| 240 | 240 | $pMetadata->xmlCollectionSkipWhenEmpty = true; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | if (isset($colConfig->attributes()->namespace)) { |
| 244 | - $pMetadata->xmlEntryNamespace = (string)$colConfig->attributes()->namespace; |
|
| 244 | + $pMetadata->xmlEntryNamespace = (string) $colConfig->attributes()->namespace; |
|
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | |
@@ -250,51 +250,51 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | $colConfig = $pElem->{'xml-map'}; |
| 252 | 252 | if (isset($colConfig->attributes()->inline)) { |
| 253 | - $pMetadata->xmlCollectionInline = 'true' === (string)$colConfig->attributes()->inline; |
|
| 253 | + $pMetadata->xmlCollectionInline = 'true' === (string) $colConfig->attributes()->inline; |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | if (isset($colConfig->attributes()->{'entry-name'})) { |
| 257 | - $pMetadata->xmlEntryName = (string)$colConfig->attributes()->{'entry-name'}; |
|
| 257 | + $pMetadata->xmlEntryName = (string) $colConfig->attributes()->{'entry-name'}; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | if (isset($colConfig->attributes()->namespace)) { |
| 261 | - $pMetadata->xmlEntryNamespace = (string)$colConfig->attributes()->namespace; |
|
| 261 | + $pMetadata->xmlEntryNamespace = (string) $colConfig->attributes()->namespace; |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | if (isset($colConfig->attributes()->{'key-attribute-name'})) { |
| 265 | - $pMetadata->xmlKeyAttribute = (string)$colConfig->attributes()->{'key-attribute-name'}; |
|
| 265 | + $pMetadata->xmlKeyAttribute = (string) $colConfig->attributes()->{'key-attribute-name'}; |
|
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | if (isset($pElem->{'xml-element'})) { |
| 270 | 270 | $colConfig = $pElem->{'xml-element'}; |
| 271 | 271 | if (isset($colConfig->attributes()->cdata)) { |
| 272 | - $pMetadata->xmlElementCData = 'true' === (string)$colConfig->attributes()->cdata; |
|
| 272 | + $pMetadata->xmlElementCData = 'true' === (string) $colConfig->attributes()->cdata; |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | if (isset($colConfig->attributes()->namespace)) { |
| 276 | - $pMetadata->xmlNamespace = (string)$colConfig->attributes()->namespace; |
|
| 276 | + $pMetadata->xmlNamespace = (string) $colConfig->attributes()->namespace; |
|
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | if (isset($pElem->attributes()->{'xml-attribute'})) { |
| 281 | - $pMetadata->xmlAttribute = 'true' === (string)$pElem->attributes()->{'xml-attribute'}; |
|
| 281 | + $pMetadata->xmlAttribute = 'true' === (string) $pElem->attributes()->{'xml-attribute'}; |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | if (isset($pElem->attributes()->{'xml-attribute-map'})) { |
| 285 | - $pMetadata->xmlAttributeMap = 'true' === (string)$pElem->attributes()->{'xml-attribute-map'}; |
|
| 285 | + $pMetadata->xmlAttributeMap = 'true' === (string) $pElem->attributes()->{'xml-attribute-map'}; |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | if (isset($pElem->attributes()->{'xml-value'})) { |
| 289 | - $pMetadata->xmlValue = 'true' === (string)$pElem->attributes()->{'xml-value'}; |
|
| 289 | + $pMetadata->xmlValue = 'true' === (string) $pElem->attributes()->{'xml-value'}; |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | if (isset($pElem->attributes()->{'xml-key-value-pairs'})) { |
| 293 | - $pMetadata->xmlKeyValuePairs = 'true' === (string)$pElem->attributes()->{'xml-key-value-pairs'}; |
|
| 293 | + $pMetadata->xmlKeyValuePairs = 'true' === (string) $pElem->attributes()->{'xml-key-value-pairs'}; |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | if (isset($pElem->attributes()->{'max-depth'})) { |
| 297 | - $pMetadata->maxDepth = (int)$pElem->attributes()->{'max-depth'}; |
|
| 297 | + $pMetadata->maxDepth = (int) $pElem->attributes()->{'max-depth'}; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | //we need read-only before setter and getter set, because that method depends on flag being set |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | $setter = $pElem->attributes()->{'accessor-setter'}; |
| 309 | 309 | $pMetadata->setAccessor( |
| 310 | 310 | (string) $pElem->attributes()->{'access-type'}, |
| 311 | - $getter ? (string)$getter : null, |
|
| 311 | + $getter ? (string) $getter : null, |
|
| 312 | 312 | $setter ? (string) $setter : null, |
| 313 | 313 | (string) $pElem->attributes()->{'access-type-naming'} |
| 314 | 314 | ); |
@@ -319,8 +319,8 @@ discard block |
||
| 319 | 319 | |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - if ((ExclusionPolicy::NONE === (string)$exclusionPolicy && !$isExclude) |
|
| 323 | - || (ExclusionPolicy::ALL === (string)$exclusionPolicy && $isExpose) |
|
| 322 | + if ((ExclusionPolicy::NONE === (string) $exclusionPolicy && ! $isExclude) |
|
| 323 | + || (ExclusionPolicy::ALL === (string) $exclusionPolicy && $isExpose) |
|
| 324 | 324 | ) { |
| 325 | 325 | $metadata->addPropertyMetadata($pMetadata); |
| 326 | 326 | } |
@@ -328,37 +328,37 @@ discard block |
||
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | foreach ($elem->xpath('./callback-method') as $method) { |
| 331 | - if (!isset($method->attributes()->type)) { |
|
| 331 | + if ( ! isset($method->attributes()->type)) { |
|
| 332 | 332 | throw new RuntimeException('The type attribute must be set for all callback-method elements.'); |
| 333 | 333 | } |
| 334 | - if (!isset($method->attributes()->name)) { |
|
| 334 | + if ( ! isset($method->attributes()->name)) { |
|
| 335 | 335 | throw new RuntimeException('The name attribute must be set for all callback-method elements.'); |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - switch ((string)$method->attributes()->type) { |
|
| 338 | + switch ((string) $method->attributes()->type) { |
|
| 339 | 339 | case 'pre-serialize': |
| 340 | - $metadata->addPreSerializeMethod(new MethodMetadata($name, (string)$method->attributes()->name)); |
|
| 340 | + $metadata->addPreSerializeMethod(new MethodMetadata($name, (string) $method->attributes()->name)); |
|
| 341 | 341 | break; |
| 342 | 342 | |
| 343 | 343 | case 'post-serialize': |
| 344 | - $metadata->addPostSerializeMethod(new MethodMetadata($name, (string)$method->attributes()->name)); |
|
| 344 | + $metadata->addPostSerializeMethod(new MethodMetadata($name, (string) $method->attributes()->name)); |
|
| 345 | 345 | break; |
| 346 | 346 | |
| 347 | 347 | case 'post-deserialize': |
| 348 | - $metadata->addPostDeserializeMethod(new MethodMetadata($name, (string)$method->attributes()->name)); |
|
| 348 | + $metadata->addPostDeserializeMethod(new MethodMetadata($name, (string) $method->attributes()->name)); |
|
| 349 | 349 | break; |
| 350 | 350 | |
| 351 | 351 | case 'handler': |
| 352 | - if (!isset($method->attributes()->format)) { |
|
| 352 | + if ( ! isset($method->attributes()->format)) { |
|
| 353 | 353 | throw new RuntimeException('The format attribute must be set for "handler" callback methods.'); |
| 354 | 354 | } |
| 355 | - if (!isset($method->attributes()->direction)) { |
|
| 355 | + if ( ! isset($method->attributes()->direction)) { |
|
| 356 | 356 | throw new RuntimeException('The direction attribute must be set for "handler" callback methods.'); |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | - $direction = GraphNavigator::parseDirection((string)$method->attributes()->direction); |
|
| 360 | - $format = (string)$method->attributes()->format; |
|
| 361 | - $metadata->addHandlerCallback($direction, $format, (string)$method->attributes()->name); |
|
| 359 | + $direction = GraphNavigator::parseDirection((string) $method->attributes()->direction); |
|
| 360 | + $format = (string) $method->attributes()->format; |
|
| 361 | + $metadata->addHandlerCallback($direction, $format, (string) $method->attributes()->name); |
|
| 362 | 362 | |
| 363 | 363 | break; |
| 364 | 364 | |
@@ -63,10 +63,10 @@ discard block |
||
| 63 | 63 | { |
| 64 | 64 | switch ($naming) { |
| 65 | 65 | case PropertyMetadata::ACCESS_TYPE_NAMING_CAMEL_CASE: |
| 66 | - return $accessorPrefix . preg_replace('/_(\w)/', '\\1', $propertyName) ?: null; |
|
| 66 | + return $accessorPrefix.preg_replace('/_(\w)/', '\\1', $propertyName) ?: null; |
|
| 67 | 67 | |
| 68 | 68 | case PropertyMetadata::ACCESS_TYPE_NAMING_EXACT: |
| 69 | - return $accessorPrefix . $propertyName; |
|
| 69 | + return $accessorPrefix.$propertyName; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | throw new RuntimeException("Undefined naming type '$naming'."); |
@@ -147,18 +147,14 @@ discard block |
||
| 147 | 147 | protected function updateAccessors(PropertyMetadata $propertyMetadata, ClassMetadata $classMetadata) |
| 148 | 148 | { |
| 149 | 149 | $type = |
| 150 | - $propertyMetadata->accessType ?: |
|
| 151 | - $classMetadata->accessType ?: |
|
| 152 | - $this->defaultType; |
|
| 150 | + $propertyMetadata->accessType ?: $classMetadata->accessType ?: $this->defaultType; |
|
| 153 | 151 | |
| 154 | 152 | if ($type !== PropertyMetadata::ACCESS_TYPE_PUBLIC_METHOD) { |
| 155 | 153 | return; |
| 156 | 154 | } |
| 157 | 155 | |
| 158 | 156 | $naming = |
| 159 | - $propertyMetadata->accessTypeNaming ?: |
|
| 160 | - $classMetadata->accessTypeNaming ?: |
|
| 161 | - $this->defaultNaming; |
|
| 157 | + $propertyMetadata->accessTypeNaming ?: $classMetadata->accessTypeNaming ?: $this->defaultNaming; |
|
| 162 | 158 | |
| 163 | 159 | $propertyMetadata->setter = $propertyMetadata->setter ?: $this->getSetter($propertyMetadata, $naming); |
| 164 | 160 | $propertyMetadata->getter = $propertyMetadata->getter ?: $this->getGetter($propertyMetadata, $naming); |
@@ -34,8 +34,7 @@ |
||
| 34 | 34 | $defaultNaming = PropertyMetadata::ACCESS_TYPE_NAMING_EXACT, |
| 35 | 35 | array $getterPrefixes = ['get', 'is', 'has'], |
| 36 | 36 | array $setterPrefixes = ['set', 'update'] |
| 37 | - ) |
|
| 38 | - { |
|
| 37 | + ) { |
|
| 39 | 38 | $this->defaultType = $defaultType; |
| 40 | 39 | $this->defaultNaming = $defaultNaming; |
| 41 | 40 | $this->getterPrefixes = $getterPrefixes; |