@@ -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(); |
@@ -62,97 +62,97 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | $metadata = new ClassMetadata($name = $class->name); |
| 65 | - if (!$elems = $elem->xpath("./class[@name = '" . $name . "']")) { |
|
| 65 | + if ( ! $elems = $elem->xpath("./class[@name = '".$name."']")) { |
|
| 66 | 66 | throw new RuntimeException(sprintf('Could not find class %s inside XML element.', $name)); |
| 67 | 67 | } |
| 68 | 68 | $elem = reset($elems); |
| 69 | 69 | |
| 70 | 70 | $metadata->fileResources[] = $path; |
| 71 | 71 | $metadata->fileResources[] = $class->getFileName(); |
| 72 | - $exclusionPolicy = strtoupper((string)$elem->attributes()->{'exclusion-policy'}) ?: 'NONE'; |
|
| 73 | - $excludeAll = null !== ($exclude = $elem->attributes()->exclude) ? 'true' === strtolower((string)$exclude) : false; |
|
| 74 | - $classAccessType = (string)($elem->attributes()->{'access-type'} ?: PropertyMetadata::ACCESS_TYPE_PROPERTY); |
|
| 72 | + $exclusionPolicy = strtoupper((string) $elem->attributes()->{'exclusion-policy'}) ?: 'NONE'; |
|
| 73 | + $excludeAll = null !== ($exclude = $elem->attributes()->exclude) ? 'true' === strtolower((string) $exclude) : false; |
|
| 74 | + $classAccessType = (string) ($elem->attributes()->{'access-type'} ?: PropertyMetadata::ACCESS_TYPE_PROPERTY); |
|
| 75 | 75 | |
| 76 | 76 | $propertiesMetadata = array(); |
| 77 | 77 | $propertiesNodes = array(); |
| 78 | 78 | |
| 79 | 79 | if (null !== $accessorOrder = $elem->attributes()->{'accessor-order'}) { |
| 80 | - $metadata->setAccessorOrder((string)$accessorOrder, preg_split('/\s*,\s*/', (string)$elem->attributes()->{'custom-accessor-order'})); |
|
| 80 | + $metadata->setAccessorOrder((string) $accessorOrder, preg_split('/\s*,\s*/', (string) $elem->attributes()->{'custom-accessor-order'})); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | if (null !== $xmlRootName = $elem->attributes()->{'xml-root-name'}) { |
| 84 | - $metadata->xmlRootName = (string)$xmlRootName; |
|
| 84 | + $metadata->xmlRootName = (string) $xmlRootName; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | if (null !== $xmlRootNamespace = $elem->attributes()->{'xml-root-namespace'}) { |
| 88 | - $metadata->xmlRootNamespace = (string)$xmlRootNamespace; |
|
| 88 | + $metadata->xmlRootNamespace = (string) $xmlRootNamespace; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - $readOnlyClass = 'true' === strtolower((string)$elem->attributes()->{'read-only'}); |
|
| 91 | + $readOnlyClass = 'true' === strtolower((string) $elem->attributes()->{'read-only'}); |
|
| 92 | 92 | |
| 93 | - $discriminatorFieldName = (string)$elem->attributes()->{'discriminator-field-name'}; |
|
| 93 | + $discriminatorFieldName = (string) $elem->attributes()->{'discriminator-field-name'}; |
|
| 94 | 94 | $discriminatorMap = array(); |
| 95 | 95 | foreach ($elem->xpath('./discriminator-class') as $entry) { |
| 96 | - if (!isset($entry->attributes()->value)) { |
|
| 96 | + if ( ! isset($entry->attributes()->value)) { |
|
| 97 | 97 | throw new RuntimeException('Each discriminator-class element must have a "value" attribute.'); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - $discriminatorMap[(string)$entry->attributes()->value] = (string)$entry; |
|
| 100 | + $discriminatorMap[(string) $entry->attributes()->value] = (string) $entry; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - if ('true' === (string)$elem->attributes()->{'discriminator-disabled'}) { |
|
| 103 | + if ('true' === (string) $elem->attributes()->{'discriminator-disabled'}) { |
|
| 104 | 104 | $metadata->discriminatorDisabled = true; |
| 105 | - } elseif (!empty($discriminatorFieldName) || !empty($discriminatorMap)) { |
|
| 105 | + } elseif ( ! empty($discriminatorFieldName) || ! empty($discriminatorMap)) { |
|
| 106 | 106 | |
| 107 | 107 | $discriminatorGroups = array(); |
| 108 | 108 | foreach ($elem->xpath('./discriminator-groups/group') as $entry) { |
| 109 | - $discriminatorGroups[] = (string)$entry; |
|
| 109 | + $discriminatorGroups[] = (string) $entry; |
|
| 110 | 110 | } |
| 111 | 111 | $metadata->setDiscriminator($discriminatorFieldName, $discriminatorMap, $discriminatorGroups); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | foreach ($elem->xpath('./xml-namespace') as $xmlNamespace) { |
| 115 | - if (!isset($xmlNamespace->attributes()->uri)) { |
|
| 115 | + if ( ! isset($xmlNamespace->attributes()->uri)) { |
|
| 116 | 116 | throw new RuntimeException('The prefix attribute must be set for all xml-namespace elements.'); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | if (isset($xmlNamespace->attributes()->prefix)) { |
| 120 | - $prefix = (string)$xmlNamespace->attributes()->prefix; |
|
| 120 | + $prefix = (string) $xmlNamespace->attributes()->prefix; |
|
| 121 | 121 | } else { |
| 122 | 122 | $prefix = null; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - $metadata->registerNamespace((string)$xmlNamespace->attributes()->uri, $prefix); |
|
| 125 | + $metadata->registerNamespace((string) $xmlNamespace->attributes()->uri, $prefix); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | foreach ($elem->xpath('./xml-discriminator') as $xmlDiscriminator) { |
| 129 | 129 | if (isset($xmlDiscriminator->attributes()->attribute)) { |
| 130 | - $metadata->xmlDiscriminatorAttribute = (string)$xmlDiscriminator->attributes()->attribute === 'true'; |
|
| 130 | + $metadata->xmlDiscriminatorAttribute = (string) $xmlDiscriminator->attributes()->attribute === 'true'; |
|
| 131 | 131 | } |
| 132 | 132 | if (isset($xmlDiscriminator->attributes()->cdata)) { |
| 133 | - $metadata->xmlDiscriminatorCData = (string)$xmlDiscriminator->attributes()->cdata === 'true'; |
|
| 133 | + $metadata->xmlDiscriminatorCData = (string) $xmlDiscriminator->attributes()->cdata === 'true'; |
|
| 134 | 134 | } |
| 135 | 135 | if (isset($xmlDiscriminator->attributes()->namespace)) { |
| 136 | - $metadata->xmlDiscriminatorNamespace = (string)$xmlDiscriminator->attributes()->namespace; |
|
| 136 | + $metadata->xmlDiscriminatorNamespace = (string) $xmlDiscriminator->attributes()->namespace; |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | foreach ($elem->xpath('./virtual-property') as $method) { |
| 141 | 141 | |
| 142 | 142 | if (isset($method->attributes()->expression)) { |
| 143 | - $virtualPropertyMetadata = new ExpressionPropertyMetadata($name, (string)$method->attributes()->name, (string)$method->attributes()->expression); |
|
| 143 | + $virtualPropertyMetadata = new ExpressionPropertyMetadata($name, (string) $method->attributes()->name, (string) $method->attributes()->expression); |
|
| 144 | 144 | } else { |
| 145 | - if (!isset($method->attributes()->method)) { |
|
| 145 | + if ( ! isset($method->attributes()->method)) { |
|
| 146 | 146 | throw new RuntimeException('The method attribute must be set for all virtual-property elements.'); |
| 147 | 147 | } |
| 148 | - $virtualPropertyMetadata = new VirtualPropertyMetadata($name, (string)$method->attributes()->method); |
|
| 148 | + $virtualPropertyMetadata = new VirtualPropertyMetadata($name, (string) $method->attributes()->method); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | $propertiesMetadata[] = $virtualPropertyMetadata; |
| 152 | 152 | $propertiesNodes[] = $method; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - if (!$excludeAll) { |
|
| 155 | + if ( ! $excludeAll) { |
|
| 156 | 156 | |
| 157 | 157 | foreach ($class->getProperties() as $property) { |
| 158 | 158 | if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) { |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | $propertiesMetadata[] = new PropertyMetadata($name, $pName = $property->getName()); |
| 163 | - $pElems = $elem->xpath("./property[@name = '" . $pName . "']"); |
|
| 163 | + $pElems = $elem->xpath("./property[@name = '".$pName."']"); |
|
| 164 | 164 | |
| 165 | 165 | $propertiesNodes[] = $pElems ? reset($pElems) : null; |
| 166 | 166 | } |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | || $pMetadata instanceof ExpressionPropertyMetadata; |
| 173 | 173 | |
| 174 | 174 | $pElem = $propertiesNodes[$propertyKey]; |
| 175 | - if (!empty($pElem)) { |
|
| 175 | + if ( ! empty($pElem)) { |
|
| 176 | 176 | |
| 177 | 177 | if (null !== $exclude = $pElem->attributes()->exclude) { |
| 178 | - $isExclude = 'true' === strtolower((string)$exclude); |
|
| 178 | + $isExclude = 'true' === strtolower((string) $exclude); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | if ($isExclude) { |
@@ -183,42 +183,42 @@ discard block |
||
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | if (null !== $expose = $pElem->attributes()->expose) { |
| 186 | - $isExpose = 'true' === strtolower((string)$expose); |
|
| 186 | + $isExpose = 'true' === strtolower((string) $expose); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | if (null !== $excludeIf = $pElem->attributes()->{'exclude-if'}) { |
| 190 | - $pMetadata->excludeIf = (string)$excludeIf; |
|
| 190 | + $pMetadata->excludeIf = (string) $excludeIf; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | if (null !== $skip = $pElem->attributes()->{'skip-when-empty'}) { |
| 194 | - $pMetadata->skipWhenEmpty = 'true' === strtolower((string)$skip); |
|
| 194 | + $pMetadata->skipWhenEmpty = 'true' === strtolower((string) $skip); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | if (null !== $excludeIf = $pElem->attributes()->{'expose-if'}) { |
| 198 | - $pMetadata->excludeIf = "!(" . (string)$excludeIf . ")"; |
|
| 198 | + $pMetadata->excludeIf = "!(".(string) $excludeIf.")"; |
|
| 199 | 199 | $isExpose = true; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | if (null !== $version = $pElem->attributes()->{'since-version'}) { |
| 203 | - $pMetadata->sinceVersion = (string)$version; |
|
| 203 | + $pMetadata->sinceVersion = (string) $version; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | if (null !== $version = $pElem->attributes()->{'until-version'}) { |
| 207 | - $pMetadata->untilVersion = (string)$version; |
|
| 207 | + $pMetadata->untilVersion = (string) $version; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | if (null !== $serializedName = $pElem->attributes()->{'serialized-name'}) { |
| 211 | - $pMetadata->serializedName = (string)$serializedName; |
|
| 211 | + $pMetadata->serializedName = (string) $serializedName; |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | if (null !== $type = $pElem->attributes()->type) { |
| 215 | - $pMetadata->setType($this->typeParser->parse((string)$type)); |
|
| 215 | + $pMetadata->setType($this->typeParser->parse((string) $type)); |
|
| 216 | 216 | } elseif (isset($pElem->type)) { |
| 217 | - $pMetadata->setType($this->typeParser->parse((string)$pElem->type)); |
|
| 217 | + $pMetadata->setType($this->typeParser->parse((string) $pElem->type)); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | if (null !== $groups = $pElem->attributes()->groups) { |
| 221 | - $pMetadata->groups = preg_split('/\s*,\s*/', trim((string)$groups)); |
|
| 221 | + $pMetadata->groups = preg_split('/\s*,\s*/', trim((string) $groups)); |
|
| 222 | 222 | } elseif (isset($pElem->groups)) { |
| 223 | 223 | $pMetadata->groups = (array) $pElem->groups->value; |
| 224 | 224 | } |
@@ -229,21 +229,21 @@ discard block |
||
| 229 | 229 | |
| 230 | 230 | $colConfig = $pElem->{'xml-list'}; |
| 231 | 231 | if (isset($colConfig->attributes()->inline)) { |
| 232 | - $pMetadata->xmlCollectionInline = 'true' === (string)$colConfig->attributes()->inline; |
|
| 232 | + $pMetadata->xmlCollectionInline = 'true' === (string) $colConfig->attributes()->inline; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | if (isset($colConfig->attributes()->{'entry-name'})) { |
| 236 | - $pMetadata->xmlEntryName = (string)$colConfig->attributes()->{'entry-name'}; |
|
| 236 | + $pMetadata->xmlEntryName = (string) $colConfig->attributes()->{'entry-name'}; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | if (isset($colConfig->attributes()->{'skip-when-empty'})) { |
| 240 | - $pMetadata->xmlCollectionSkipWhenEmpty = 'true' === (string)$colConfig->attributes()->{'skip-when-empty'}; |
|
| 240 | + $pMetadata->xmlCollectionSkipWhenEmpty = 'true' === (string) $colConfig->attributes()->{'skip-when-empty'}; |
|
| 241 | 241 | } else { |
| 242 | 242 | $pMetadata->xmlCollectionSkipWhenEmpty = true; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | if (isset($colConfig->attributes()->namespace)) { |
| 246 | - $pMetadata->xmlEntryNamespace = (string)$colConfig->attributes()->namespace; |
|
| 246 | + $pMetadata->xmlEntryNamespace = (string) $colConfig->attributes()->namespace; |
|
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | |
@@ -252,56 +252,56 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | $colConfig = $pElem->{'xml-map'}; |
| 254 | 254 | if (isset($colConfig->attributes()->inline)) { |
| 255 | - $pMetadata->xmlCollectionInline = 'true' === (string)$colConfig->attributes()->inline; |
|
| 255 | + $pMetadata->xmlCollectionInline = 'true' === (string) $colConfig->attributes()->inline; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | if (isset($colConfig->attributes()->{'entry-name'})) { |
| 259 | - $pMetadata->xmlEntryName = (string)$colConfig->attributes()->{'entry-name'}; |
|
| 259 | + $pMetadata->xmlEntryName = (string) $colConfig->attributes()->{'entry-name'}; |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | if (isset($colConfig->attributes()->namespace)) { |
| 263 | - $pMetadata->xmlEntryNamespace = (string)$colConfig->attributes()->namespace; |
|
| 263 | + $pMetadata->xmlEntryNamespace = (string) $colConfig->attributes()->namespace; |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | if (isset($colConfig->attributes()->{'key-attribute-name'})) { |
| 267 | - $pMetadata->xmlKeyAttribute = (string)$colConfig->attributes()->{'key-attribute-name'}; |
|
| 267 | + $pMetadata->xmlKeyAttribute = (string) $colConfig->attributes()->{'key-attribute-name'}; |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | if (isset($pElem->{'xml-element'})) { |
| 272 | 272 | $colConfig = $pElem->{'xml-element'}; |
| 273 | 273 | if (isset($colConfig->attributes()->cdata)) { |
| 274 | - $pMetadata->xmlElementCData = 'true' === (string)$colConfig->attributes()->cdata; |
|
| 274 | + $pMetadata->xmlElementCData = 'true' === (string) $colConfig->attributes()->cdata; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | if (isset($colConfig->attributes()->namespace)) { |
| 278 | - $pMetadata->xmlNamespace = (string)$colConfig->attributes()->namespace; |
|
| 278 | + $pMetadata->xmlNamespace = (string) $colConfig->attributes()->namespace; |
|
| 279 | 279 | } |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | if (isset($pElem->attributes()->{'xml-attribute'})) { |
| 283 | - $pMetadata->xmlAttribute = 'true' === (string)$pElem->attributes()->{'xml-attribute'}; |
|
| 283 | + $pMetadata->xmlAttribute = 'true' === (string) $pElem->attributes()->{'xml-attribute'}; |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | if (isset($pElem->attributes()->{'xml-attribute-map'})) { |
| 287 | - $pMetadata->xmlAttributeMap = 'true' === (string)$pElem->attributes()->{'xml-attribute-map'}; |
|
| 287 | + $pMetadata->xmlAttributeMap = 'true' === (string) $pElem->attributes()->{'xml-attribute-map'}; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | if (isset($pElem->attributes()->{'xml-value'})) { |
| 291 | - $pMetadata->xmlValue = 'true' === (string)$pElem->attributes()->{'xml-value'}; |
|
| 291 | + $pMetadata->xmlValue = 'true' === (string) $pElem->attributes()->{'xml-value'}; |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | if (isset($pElem->attributes()->{'xml-key-value-pairs'})) { |
| 295 | - $pMetadata->xmlKeyValuePairs = 'true' === (string)$pElem->attributes()->{'xml-key-value-pairs'}; |
|
| 295 | + $pMetadata->xmlKeyValuePairs = 'true' === (string) $pElem->attributes()->{'xml-key-value-pairs'}; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | if (isset($pElem->attributes()->{'max-depth'})) { |
| 299 | - $pMetadata->maxDepth = (int)$pElem->attributes()->{'max-depth'}; |
|
| 299 | + $pMetadata->maxDepth = (int) $pElem->attributes()->{'max-depth'}; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | //we need read-only before setter and getter set, because that method depends on flag being set |
| 303 | 303 | if (null !== $readOnly = $pElem->attributes()->{'read-only'}) { |
| 304 | - $pMetadata->readOnly = 'true' === strtolower((string)$readOnly); |
|
| 304 | + $pMetadata->readOnly = 'true' === strtolower((string) $readOnly); |
|
| 305 | 305 | } else { |
| 306 | 306 | $pMetadata->readOnly = $pMetadata->readOnly || $readOnlyClass; |
| 307 | 307 | } |
@@ -309,26 +309,26 @@ discard block |
||
| 309 | 309 | $getter = $pElem->attributes()->{'accessor-getter'}; |
| 310 | 310 | $setter = $pElem->attributes()->{'accessor-setter'}; |
| 311 | 311 | $pMetadata->setAccessor( |
| 312 | - (string)($pElem->attributes()->{'access-type'} ?: $classAccessType), |
|
| 313 | - $getter ? (string)$getter : null, |
|
| 314 | - $setter ? (string)$setter : null |
|
| 312 | + (string) ($pElem->attributes()->{'access-type'} ?: $classAccessType), |
|
| 313 | + $getter ? (string) $getter : null, |
|
| 314 | + $setter ? (string) $setter : null |
|
| 315 | 315 | ); |
| 316 | 316 | |
| 317 | 317 | if (null !== $inline = $pElem->attributes()->inline) { |
| 318 | - $pMetadata->inline = 'true' === strtolower((string)$inline); |
|
| 318 | + $pMetadata->inline = 'true' === strtolower((string) $inline); |
|
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - if (!$pMetadata->serializedName) { |
|
| 322 | + if ( ! $pMetadata->serializedName) { |
|
| 323 | 323 | $pMetadata->serializedName = $this->namingStrategy->translateName($pMetadata); |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if (!empty($pElem) && null !== $name = $pElem->attributes()->name) { |
|
| 327 | - $pMetadata->name = (string)$name; |
|
| 326 | + if ( ! empty($pElem) && null !== $name = $pElem->attributes()->name) { |
|
| 327 | + $pMetadata->name = (string) $name; |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - if ((ExclusionPolicy::NONE === (string)$exclusionPolicy && !$isExclude) |
|
| 331 | - || (ExclusionPolicy::ALL === (string)$exclusionPolicy && $isExpose) |
|
| 330 | + if ((ExclusionPolicy::NONE === (string) $exclusionPolicy && ! $isExclude) |
|
| 331 | + || (ExclusionPolicy::ALL === (string) $exclusionPolicy && $isExpose) |
|
| 332 | 332 | ) { |
| 333 | 333 | |
| 334 | 334 | |
@@ -338,31 +338,31 @@ discard block |
||
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | foreach ($elem->xpath('./callback-method') as $method) { |
| 341 | - if (!isset($method->attributes()->type)) { |
|
| 341 | + if ( ! isset($method->attributes()->type)) { |
|
| 342 | 342 | throw new RuntimeException('The type attribute must be set for all callback-method elements.'); |
| 343 | 343 | } |
| 344 | - if (!isset($method->attributes()->name)) { |
|
| 344 | + if ( ! isset($method->attributes()->name)) { |
|
| 345 | 345 | throw new RuntimeException('The name attribute must be set for all callback-method elements.'); |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - switch ((string)$method->attributes()->type) { |
|
| 348 | + switch ((string) $method->attributes()->type) { |
|
| 349 | 349 | case 'pre-serialize': |
| 350 | - $metadata->addPreSerializeMethod(new MethodMetadata($name, (string)$method->attributes()->name)); |
|
| 350 | + $metadata->addPreSerializeMethod(new MethodMetadata($name, (string) $method->attributes()->name)); |
|
| 351 | 351 | break; |
| 352 | 352 | |
| 353 | 353 | case 'post-serialize': |
| 354 | - $metadata->addPostSerializeMethod(new MethodMetadata($name, (string)$method->attributes()->name)); |
|
| 354 | + $metadata->addPostSerializeMethod(new MethodMetadata($name, (string) $method->attributes()->name)); |
|
| 355 | 355 | break; |
| 356 | 356 | |
| 357 | 357 | case 'post-deserialize': |
| 358 | - $metadata->addPostDeserializeMethod(new MethodMetadata($name, (string)$method->attributes()->name)); |
|
| 358 | + $metadata->addPostDeserializeMethod(new MethodMetadata($name, (string) $method->attributes()->name)); |
|
| 359 | 359 | break; |
| 360 | 360 | |
| 361 | 361 | case 'handler': |
| 362 | - if (!isset($method->attributes()->format)) { |
|
| 362 | + if ( ! isset($method->attributes()->format)) { |
|
| 363 | 363 | throw new RuntimeException('The format attribute must be set for "handler" callback methods.'); |
| 364 | 364 | } |
| 365 | - if (!isset($method->attributes()->direction)) { |
|
| 365 | + if ( ! isset($method->attributes()->direction)) { |
|
| 366 | 366 | throw new RuntimeException('The direction attribute must be set for "handler" callback methods.'); |
| 367 | 367 | } |
| 368 | 368 | |
@@ -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 | |
@@ -22,12 +22,12 @@ discard block |
||
| 22 | 22 | use Hoa\Compiler\Llk\Llk; |
| 23 | 23 | use Hoa\File\Read; |
| 24 | 24 | |
| 25 | -require __DIR__ . '/../../vendor/autoload.php'; |
|
| 25 | +require __DIR__.'/../../vendor/autoload.php'; |
|
| 26 | 26 | |
| 27 | -$compiler = Llk::load(new Read(__DIR__ . '/grammar.pp')); |
|
| 27 | +$compiler = Llk::load(new Read(__DIR__.'/grammar.pp')); |
|
| 28 | 28 | |
| 29 | 29 | file_put_contents( |
| 30 | - __DIR__ . '/InnerParser.php', |
|
| 30 | + __DIR__.'/InnerParser.php', |
|
| 31 | 31 | <<<EOS |
| 32 | 32 | <?php |
| 33 | 33 | |
@@ -57,5 +57,5 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | |
| 59 | 59 | EOS |
| 60 | - . 'final ' . Llk::save($compiler, 'InnerParser') |
|
| 60 | + . 'final '.Llk::save($compiler, 'InnerParser') |
|
| 61 | 61 | ); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | return $value; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - return str_replace($escapeChar . $escapeChar, $escapeChar, $value); |
|
| 62 | + return str_replace($escapeChar.$escapeChar, $escapeChar, $value); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | private function visitCompoundType(TreeNode $element, ?int &$handle, ?int $eldnah) : array |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | return [ |
| 71 | 71 | 'name' => $nameToken->getValueValue(), |
| 72 | 72 | 'params' => array_map( |
| 73 | - function (TreeNode $node) use ($handle, $eldnah) { |
|
| 73 | + function(TreeNode $node) use ($handle, $eldnah) { |
|
| 74 | 74 | return $node->accept($this, $handle, $eldnah); |
| 75 | 75 | }, |
| 76 | 76 | $parameters |