@@ -23,17 +23,11 @@ |
||
| 23 | 23 | use JMS\Serializer\Handler\PhpCollectionHandler; |
| 24 | 24 | use JMS\Serializer\Handler\PropelCollectionHandler; |
| 25 | 25 | use JMS\Serializer\Exception\RuntimeException; |
| 26 | -use Metadata\Driver\DriverInterface; |
|
| 27 | 26 | use Metadata\MetadataFactory; |
| 28 | -use JMS\Serializer\Metadata\Driver\AnnotationDriver; |
|
| 29 | 27 | use JMS\Serializer\Handler\HandlerRegistry; |
| 30 | 28 | use JMS\Serializer\Construction\UnserializeObjectConstructor; |
| 31 | 29 | use PhpCollection\Map; |
| 32 | 30 | use JMS\Serializer\EventDispatcher\EventDispatcher; |
| 33 | -use Metadata\Driver\DriverChain; |
|
| 34 | -use JMS\Serializer\Metadata\Driver\YamlDriver; |
|
| 35 | -use JMS\Serializer\Metadata\Driver\XmlDriver; |
|
| 36 | -use Metadata\Driver\FileLocator; |
|
| 37 | 31 | use JMS\Serializer\Handler\DateHandler; |
| 38 | 32 | use JMS\Serializer\Handler\ArrayCollectionHandler; |
| 39 | 33 | use JMS\Serializer\Construction\ObjectConstructorInterface; |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | $this->classListeners[$eventName][$loweredClass][$format] = $this->initializeListeners($eventName, $loweredClass, $format); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - return !!$this->classListeners[$eventName][$loweredClass][$format]; |
|
| 83 | + return ! ! $this->classListeners[$eventName][$loweredClass][$format]; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | public function dispatch($eventName, $class, $format, Event $event) |
@@ -25,5 +25,7 @@ |
||
| 25 | 25 | const PRE_DESERIALIZE = 'serializer.pre_deserialize'; |
| 26 | 26 | const POST_DESERIALIZE = 'serializer.post_deserialize'; |
| 27 | 27 | |
| 28 | - final private function __construct() { } |
|
| 28 | + final private function __construct() |
|
| 29 | + { |
|
| 30 | +} |
|
| 29 | 31 | } |
@@ -167,7 +167,7 @@ |
||
| 167 | 167 | |
| 168 | 168 | //we need read_only before setter and getter set, because that method depends on flag being set |
| 169 | 169 | if (isset($pConfig['read_only'])) { |
| 170 | - $pMetadata->readOnly = (Boolean) $pConfig['read_only']; |
|
| 170 | + $pMetadata->readOnly = (Boolean) $pConfig['read_only']; |
|
| 171 | 171 | } else { |
| 172 | 172 | $pMetadata->readOnly = $pMetadata->readOnly || $readOnlyClass; |
| 173 | 173 | } |
@@ -113,15 +113,15 @@ |
||
| 113 | 113 | |
| 114 | 114 | $colConfig = $pConfig['xml_list']; |
| 115 | 115 | if (isset($colConfig['inline'])) { |
| 116 | - $pMetadata->xmlCollectionInline = (Boolean)$colConfig['inline']; |
|
| 116 | + $pMetadata->xmlCollectionInline = (Boolean) $colConfig['inline']; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | if (isset($colConfig['entry_name'])) { |
| 120 | - $pMetadata->xmlEntryName = (string)$colConfig['entry_name']; |
|
| 120 | + $pMetadata->xmlEntryName = (string) $colConfig['entry_name']; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | if (isset($colConfig['skip_when_empty'])) { |
| 124 | - $pMetadata->xmlCollectionSkipWhenEmpty = (Boolean)$colConfig['skip_when_empty']; |
|
| 124 | + $pMetadata->xmlCollectionSkipWhenEmpty = (Boolean) $colConfig['skip_when_empty']; |
|
| 125 | 125 | } else { |
| 126 | 126 | $pMetadata->xmlCollectionSkipWhenEmpty = true; |
| 127 | 127 | } |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | |(.) |
| 50 | 50 | /x', |
| 51 | 51 | array(self::T_NAME => 'T_NAME', self::T_STRING => 'T_STRING', self::T_OPEN_BRACKET => 'T_OPEN_BRACKET', |
| 52 | - self::T_CLOSE_BRACKET => 'T_CLOSE_BRACKET', self::T_COMMA => 'T_COMMA', self::T_NONE => 'T_NONE'), |
|
| 52 | + self::T_CLOSE_BRACKET => 'T_CLOSE_BRACKET', self::T_COMMA => 'T_COMMA', self::T_NONE => 'T_NONE'), |
|
| 53 | 53 | function($value) { |
| 54 | 54 | switch ($value[0]) { |
| 55 | 55 | case '"': |
@@ -83,16 +83,16 @@ |
||
| 83 | 83 | $addition = ''; |
| 84 | 84 | |
| 85 | 85 | $lines = explode("\n", $content); |
| 86 | - for ($i=0,$c=count($lines); $i<$c; $i++) { |
|
| 86 | + for ($i = 0, $c = count($lines); $i < $c; $i++) { |
|
| 87 | 87 | if ($this->indentationLevel > 0 |
| 88 | - && !empty($lines[$i]) |
|
| 88 | + && ! empty($lines[$i]) |
|
| 89 | 89 | && ((empty($addition) && "\n" === substr($this->content, -1)) || "\n" === substr($addition, -1))) { |
| 90 | 90 | $addition .= str_repeat(' ', $this->indentationLevel * $this->indentationSpaces); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $addition .= $lines[$i]; |
| 94 | 94 | |
| 95 | - if ($i+1 < $c) { |
|
| 95 | + if ($i + 1 < $c) { |
|
| 96 | 96 | $addition .= "\n"; |
| 97 | 97 | } |
| 98 | 98 | } |
@@ -168,8 +168,8 @@ |
||
| 168 | 168 | |
| 169 | 169 | if ( ! $metadata->inline) { |
| 170 | 170 | $this->writer |
| 171 | - ->writeln(Inline::dump($name).':') |
|
| 172 | - ->indent(); |
|
| 171 | + ->writeln(Inline::dump($name).':') |
|
| 172 | + ->indent(); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | $this->setCurrentMetadata($metadata); |
@@ -226,7 +226,7 @@ |
||
| 226 | 226 | throw new RuntimeException(sprintf('You must define a type for %s::$%s.', $metadata->reflection->class, $metadata->name)); |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if ($metadata->xmlAttribute) { |
|
| 229 | + if ($metadata->xmlAttribute) { |
|
| 230 | 230 | |
| 231 | 231 | $attributes = $data->attributes($metadata->xmlNamespace); |
| 232 | 232 | if (isset($attributes[$name])) { |
@@ -346,7 +346,6 @@ |
||
| 346 | 346 | /** |
| 347 | 347 | * Retrieves internalSubset even in bugfixed php versions |
| 348 | 348 | * |
| 349 | - * @param \DOMDocumentType $child |
|
| 350 | 349 | * @param string $data |
| 351 | 350 | * @return string |
| 352 | 351 | */ |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | if (false !== stripos($data, '<!doctype')) { |
| 65 | 65 | $internalSubset = $this->getDomDocumentTypeEntitySubset($data); |
| 66 | - if (!in_array($internalSubset, $this->doctypeWhitelist, true)) { |
|
| 66 | + if ( ! in_array($internalSubset, $this->doctypeWhitelist, true)) { |
|
| 67 | 67 | throw new InvalidArgumentException(sprintf( |
| 68 | 68 | 'The document type "%s" is not allowed. If it is safe, you may add it to the whitelist configuration.', |
| 69 | 69 | $internalSubset |
@@ -147,10 +147,10 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | if ($namespace === null && $this->objectMetadataStack->count()) { |
| 149 | 149 | $classMetadata = $this->objectMetadataStack->top(); |
| 150 | - $namespace = isset($classMetadata->xmlNamespaces[''])?$classMetadata->xmlNamespaces['']:$namespace; |
|
| 150 | + $namespace = isset($classMetadata->xmlNamespaces['']) ? $classMetadata->xmlNamespaces[''] : $namespace; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - if ( ! isset($data->$entryName) ) { |
|
| 153 | + if ( ! isset($data->$entryName)) { |
|
| 154 | 154 | if (null === $this->result) { |
| 155 | 155 | return $this->result = array(); |
| 156 | 156 | } |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | |
| 243 | 243 | if ($metadata->xmlCollection) { |
| 244 | 244 | $enclosingElem = $data; |
| 245 | - if (!$metadata->xmlCollectionInline) { |
|
| 245 | + if ( ! $metadata->xmlCollectionInline) { |
|
| 246 | 246 | $enclosingElem = $data->children($metadata->xmlNamespace)->$name; |
| 247 | 247 | } |
| 248 | 248 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | if ($metadata->xmlNamespace) { |
| 258 | 258 | $node = $data->children($metadata->xmlNamespace)->$name; |
| 259 | - if (!$node->count()) { |
|
| 259 | + if ( ! $node->count()) { |
|
| 260 | 260 | return; |
| 261 | 261 | } |
| 262 | 262 | } else { |
@@ -266,9 +266,9 @@ discard block |
||
| 266 | 266 | if (isset($namespaces[''])) { |
| 267 | 267 | $prefix = uniqid('ns-'); |
| 268 | 268 | $data->registerXPathNamespace($prefix, $namespaces['']); |
| 269 | - $nodes = $data->xpath('./'.$prefix. ':'.$name ); |
|
| 269 | + $nodes = $data->xpath('./'.$prefix.':'.$name); |
|
| 270 | 270 | } else { |
| 271 | - $nodes = $data->xpath('./'. $name ); |
|
| 271 | + $nodes = $data->xpath('./'.$name); |
|
| 272 | 272 | } |
| 273 | 273 | if (empty($nodes)) { |
| 274 | 274 | return; |
@@ -44,6 +44,9 @@ discard block |
||
| 44 | 44 | private $nullWasVisited; |
| 45 | 45 | private $objectMetadataStack; |
| 46 | 46 | |
| 47 | + /** |
|
| 48 | + * @param Naming\PropertyNamingStrategyInterface $namingStrategy |
|
| 49 | + */ |
|
| 47 | 50 | public function __construct($namingStrategy) |
| 48 | 51 | { |
| 49 | 52 | parent::__construct($namingStrategy); |
@@ -126,6 +129,9 @@ discard block |
||
| 126 | 129 | return $doCData ? $this->document->createCDATASection($data) : $this->document->createTextNode((string) $data); |
| 127 | 130 | } |
| 128 | 131 | |
| 132 | + /** |
|
| 133 | + * @param string $data |
|
| 134 | + */ |
|
| 129 | 135 | public function visitSimpleString($data, array $type, Context $context) |
| 130 | 136 | { |
| 131 | 137 | if (null === $this->document) { |
@@ -437,6 +443,9 @@ discard block |
||
| 437 | 443 | } |
| 438 | 444 | } |
| 439 | 445 | |
| 446 | + /** |
|
| 447 | + * @return \DOMNode |
|
| 448 | + */ |
|
| 440 | 449 | private function createElement($tagName, $namespace = null) |
| 441 | 450 | { |
| 442 | 451 | if (null !== $namespace) { |
@@ -456,6 +465,9 @@ discard block |
||
| 456 | 465 | } |
| 457 | 466 | } |
| 458 | 467 | |
| 468 | + /** |
|
| 469 | + * @param string $value |
|
| 470 | + */ |
|
| 459 | 471 | private function setAttributeOnNode(\DOMElement $node, $name, $value, $namespace = null) |
| 460 | 472 | { |
| 461 | 473 | if (null !== $namespace) { |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | $this->document = $this->createDocument(null, null, false); |
| 198 | 198 | if ($metadata->xmlRootName) { |
| 199 | 199 | $rootName = $metadata->xmlRootName; |
| 200 | - $rootNamespace = $metadata->xmlRootNamespace?:$this->getClassDefaultNamespace($metadata); |
|
| 200 | + $rootNamespace = $metadata->xmlRootNamespace ?: $this->getClassDefaultNamespace($metadata); |
|
| 201 | 201 | } else { |
| 202 | 202 | $rootName = $this->defaultRootName; |
| 203 | 203 | $rootNamespace = $this->defaultRootNamespace; |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | if ($addEnclosingElement) { |
| 304 | 304 | $this->revertCurrentNode(); |
| 305 | 305 | |
| 306 | - if ($this->nodeNotEmpty($element) || ((!$metadata->xmlCollection || !$metadata->xmlCollectionSkipWhenEmpty) && $node === null && $v !== null && !$context->isVisiting($v))) { |
|
| 306 | + if ($this->nodeNotEmpty($element) || (( ! $metadata->xmlCollection || ! $metadata->xmlCollectionSkipWhenEmpty) && $node === null && $v !== null && ! $context->isVisiting($v))) { |
|
| 307 | 307 | $this->currentNode->appendChild($element); |
| 308 | 308 | } |
| 309 | 309 | } |
@@ -449,18 +449,18 @@ discard block |
||
| 449 | 449 | if ($this->currentNode->isDefaultNamespace($namespace)) { |
| 450 | 450 | return $this->document->createElementNS($namespace, $tagName); |
| 451 | 451 | } |
| 452 | - if (!($prefix = $this->currentNode->lookupPrefix($namespace)) && !($prefix = $this->document->lookupPrefix($namespace))) { |
|
| 453 | - $prefix = 'ns-'. substr(sha1($namespace), 0, 8); |
|
| 454 | - return $this->document->createElementNS($namespace, $prefix . ':' . $tagName); |
|
| 452 | + if ( ! ($prefix = $this->currentNode->lookupPrefix($namespace)) && ! ($prefix = $this->document->lookupPrefix($namespace))) { |
|
| 453 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
| 454 | + return $this->document->createElementNS($namespace, $prefix.':'.$tagName); |
|
| 455 | 455 | } |
| 456 | - return $this->document->createElement($prefix . ':' . $tagName); |
|
| 456 | + return $this->document->createElement($prefix.':'.$tagName); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | private function setAttributeOnNode(\DOMElement $node, $name, $value, $namespace = null) |
| 460 | 460 | { |
| 461 | 461 | if (null !== $namespace) { |
| 462 | - if (!$prefix = $node->lookupPrefix($namespace)) { |
|
| 463 | - $prefix = 'ns-'. substr(sha1($namespace), 0, 8); |
|
| 462 | + if ( ! $prefix = $node->lookupPrefix($namespace)) { |
|
| 463 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
| 464 | 464 | } |
| 465 | 465 | $node->setAttributeNS($namespace, $prefix.':'.$name, $value); |
| 466 | 466 | } else { |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | |
| 471 | 471 | private function getClassDefaultNamespace(ClassMetadata $metadata) |
| 472 | 472 | { |
| 473 | - return (isset($metadata->xmlNamespaces[''])?$metadata->xmlNamespaces['']:null); |
|
| 473 | + return (isset($metadata->xmlNamespaces['']) ? $metadata->xmlNamespaces[''] : null); |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | } |