@@ -85,6 +85,9 @@ discard block |
||
| 85 | 85 | return $doc; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | + /** |
|
| 89 | + * @return string |
|
| 90 | + */ |
|
| 88 | 91 | private function emptyStringToSpaceCharacter($data) |
| 89 | 92 | { |
| 90 | 93 | return $data === '' ? ' ' : $data; |
@@ -359,7 +362,6 @@ discard block |
||
| 359 | 362 | /** |
| 360 | 363 | * Retrieves internalSubset even in bugfixed php versions |
| 361 | 364 | * |
| 362 | - * @param \DOMDocumentType $child |
|
| 363 | 365 | * @param string $data |
| 364 | 366 | * @return string |
| 365 | 367 | */ |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | if (false !== stripos($data, '<!doctype')) { |
| 62 | 62 | $internalSubset = $this->getDomDocumentTypeEntitySubset($data); |
| 63 | - if (!in_array($internalSubset, $this->doctypeWhitelist, true)) { |
|
| 63 | + if ( ! in_array($internalSubset, $this->doctypeWhitelist, true)) { |
|
| 64 | 64 | throw new InvalidArgumentException(sprintf( |
| 65 | 65 | 'The document type "%s" is not allowed. If it is safe, you may add it to the whitelist configuration.', |
| 66 | 66 | $internalSubset |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | public function visitString($data, array $type, Context $context) |
| 94 | 94 | { |
| 95 | - return (string)$data; |
|
| 95 | + return (string) $data; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | public function visitBoolean($data, array $type, Context $context) |
| 99 | 99 | { |
| 100 | - $data = (string)$data; |
|
| 100 | + $data = (string) $data; |
|
| 101 | 101 | |
| 102 | 102 | if ('true' === $data || '1' === $data) { |
| 103 | 103 | $data = true; |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | public function visitInteger($data, array $type, Context $context) |
| 114 | 114 | { |
| 115 | - return (integer)$data; |
|
| 115 | + return (integer) $data; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | public function visitDouble($data, array $type, Context $context) |
| 119 | 119 | { |
| 120 | - return (double)$data; |
|
| 120 | + return (double) $data; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | public function visitArray($data, array $type, Context $context) |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | $nodes = $data->xpath($entryName); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if (!count($nodes)) { |
|
| 141 | + if ( ! count($nodes)) { |
|
| 142 | 142 | return array(); |
| 143 | 143 | } |
| 144 | 144 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | $nodes = $data->children($namespace)->$entryName; |
| 166 | 166 | foreach ($nodes as $v) { |
| 167 | 167 | $attrs = $v->attributes(); |
| 168 | - if (!isset($attrs[$this->currentMetadata->xmlKeyAttribute])) { |
|
| 168 | + if ( ! isset($attrs[$this->currentMetadata->xmlKeyAttribute])) { |
|
| 169 | 169 | throw new RuntimeException(sprintf('The key attribute "%s" must be set for each entry of the map.', $this->currentMetadata->xmlKeyAttribute)); |
| 170 | 170 | } |
| 171 | 171 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | { |
| 191 | 191 | $name = $this->namingStrategy->translateName($metadata); |
| 192 | 192 | |
| 193 | - if (!$metadata->type) { |
|
| 193 | + if ( ! $metadata->type) { |
|
| 194 | 194 | throw new RuntimeException(sprintf('You must define a type for %s::$%s.', $metadata->reflection->class, $metadata->name)); |
| 195 | 195 | } |
| 196 | 196 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | if ($metadata->xmlCollection) { |
| 216 | 216 | $enclosingElem = $data; |
| 217 | - if (!$metadata->xmlCollectionInline) { |
|
| 217 | + if ( ! $metadata->xmlCollectionInline) { |
|
| 218 | 218 | $enclosingElem = $data->children($metadata->xmlNamespace)->$name; |
| 219 | 219 | } |
| 220 | 220 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | if ($metadata->xmlNamespace) { |
| 230 | 230 | $node = $data->children($metadata->xmlNamespace)->$name; |
| 231 | - if (!$node->count()) { |
|
| 231 | + if ( ! $node->count()) { |
|
| 232 | 232 | return; |
| 233 | 233 | } |
| 234 | 234 | } else { |
@@ -238,9 +238,9 @@ discard block |
||
| 238 | 238 | if (isset($namespaces[''])) { |
| 239 | 239 | $prefix = uniqid('ns-'); |
| 240 | 240 | $data->registerXPathNamespace($prefix, $namespaces['']); |
| 241 | - $nodes = $data->xpath('./' . $prefix . ':' . $name); |
|
| 241 | + $nodes = $data->xpath('./'.$prefix.':'.$name); |
|
| 242 | 242 | } else { |
| 243 | - $nodes = $data->xpath('./' . $name); |
|
| 243 | + $nodes = $data->xpath('./'.$name); |
|
| 244 | 244 | } |
| 245 | 245 | if (empty($nodes)) { |
| 246 | 246 | return; |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | public function getResult() |
| 298 | 298 | { |
| 299 | - throw new \Exception(__METHOD__ . " has been deprecated for deserialization visitors"); |
|
| 299 | + throw new \Exception(__METHOD__." has been deprecated for deserialization visitors"); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -83,8 +83,7 @@ |
||
| 83 | 83 | EventDispatcherInterface $dispatcher = null, |
| 84 | 84 | TypeParser $typeParser = null, |
| 85 | 85 | ExpressionEvaluatorInterface $expressionEvaluator = null |
| 86 | - ) |
|
| 87 | - { |
|
| 86 | + ) { |
|
| 88 | 87 | $this->factory = $factory; |
| 89 | 88 | $this->handlerRegistry = $handlerRegistry; |
| 90 | 89 | $this->objectConstructor = $objectConstructor; |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @param Construction\ObjectConstructorInterface $objectConstructor |
| 74 | 74 | * @param \PhpCollection\MapInterface $serializationVisitors of VisitorInterface |
| 75 | 75 | * @param \PhpCollection\MapInterface $deserializationVisitors of VisitorInterface |
| 76 | - * @param EventDispatcher\EventDispatcherInterface $dispatcher |
|
| 76 | + * @param EventDispatcherInterface $dispatcher |
|
| 77 | 77 | * @param TypeParser $typeParser |
| 78 | 78 | * @param ExpressionEvaluatorInterface|null $expressionEvaluator |
| 79 | 79 | */ |
@@ -181,6 +181,9 @@ discard block |
||
| 181 | 181 | ->get(); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | + /** |
|
| 185 | + * @param string $format |
|
| 186 | + */ |
|
| 184 | 187 | private function visit(GraphNavigatorInterface $navigator, $visitor, Context $context, $data, $format, array $type = null) |
| 185 | 188 | { |
| 186 | 189 | $context->initialize( |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | return $this->serializationVisitors->get($format) |
| 113 | - ->map(function (SerializationVisitorInterface $visitor) use ($context, $data, $format, $type) { |
|
| 113 | + ->map(function(SerializationVisitorInterface $visitor) use ($context, $data, $format, $type) { |
|
| 114 | 114 | |
| 115 | 115 | $type = $this->findInitialType($type, $context); |
| 116 | 116 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | return $this->deserializationVisitors->get($format) |
| 141 | - ->map(function (DeserializationVisitorInterface $visitor) use ($context, $data, $format, $type) { |
|
| 141 | + ->map(function(DeserializationVisitorInterface $visitor) use ($context, $data, $format, $type) { |
|
| 142 | 142 | $preparedData = $visitor->prepare($data); |
| 143 | 143 | return $this->visit($this->deserializationNavigator, $visitor, $context, $preparedData, $format, $this->typeParser->parse($type)); |
| 144 | 144 | }) |
@@ -155,14 +155,14 @@ discard block |
||
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | return $this->serializationVisitors->get('json') |
| 158 | - ->map(function (JsonSerializationVisitor $visitor) use ($context, $data, $type) { |
|
| 158 | + ->map(function(JsonSerializationVisitor $visitor) use ($context, $data, $type) { |
|
| 159 | 159 | |
| 160 | 160 | $type = $this->findInitialType($type, $context); |
| 161 | 161 | |
| 162 | 162 | $this->visit($this->serializationNavigator, $visitor, $context, $data, 'json', $type); |
| 163 | 163 | $result = $this->removeInternalArrayObjects($visitor->getRoot()); |
| 164 | 164 | |
| 165 | - if (!is_array($result)) { |
|
| 165 | + if ( ! is_array($result)) { |
|
| 166 | 166 | throw new RuntimeException(sprintf( |
| 167 | 167 | 'The input data of type "%s" did not convert to an array, but got a result of type "%s".', |
| 168 | 168 | is_object($data) ? get_class($data) : gettype($data), |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | return $this->deserializationVisitors->get('json') |
| 188 | - ->map(function (JsonDeserializationVisitor $visitor) use ($data, $type, $context) { |
|
| 188 | + ->map(function(JsonDeserializationVisitor $visitor) use ($data, $type, $context) { |
|
| 189 | 189 | return $this->visit($this->deserializationNavigator, $visitor, $context, $data, 'json', $this->typeParser->parse($type)); |
| 190 | 190 | }) |
| 191 | 191 | ->get(); |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | foreach ($data as $key => $value) { |
| 41 | - if (!property_exists(__CLASS__, $key)) { |
|
| 41 | + if ( ! property_exists(__CLASS__, $key)) { |
|
| 42 | 42 | throw new \BadMethodCallException(sprintf('Unknown property "%s" on annotation "%s".', $key, __CLASS__)); |
| 43 | 43 | } |
| 44 | 44 | $this->{$key} = $value; |
@@ -73,8 +73,7 @@ discard block |
||
| 73 | 73 | \DateTimeInterface $date, |
| 74 | 74 | array $type, |
| 75 | 75 | SerializationContext $context |
| 76 | - ) |
|
| 77 | - { |
|
| 76 | + ) { |
|
| 78 | 77 | if ($visitor instanceof XmlSerializationVisitor && false === $this->xmlCData) { |
| 79 | 78 | return $visitor->visitSimpleString($date->format($this->getFormat($type)), $type, $context); |
| 80 | 79 | } |
@@ -97,8 +96,7 @@ discard block |
||
| 97 | 96 | \DateTimeImmutable $date, |
| 98 | 97 | array $type, |
| 99 | 98 | SerializationContext $context |
| 100 | - ) |
|
| 101 | - { |
|
| 99 | + ) { |
|
| 102 | 100 | return $this->serializeDateTimeInterface($visitor, $date, $type, $context); |
| 103 | 101 | } |
| 104 | 102 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | 'type' => $type, |
| 54 | 54 | 'format' => $format, |
| 55 | 55 | 'direction' => GraphNavigator::DIRECTION_SERIALIZATION, |
| 56 | - 'method' => 'serialize' . $type, |
|
| 56 | + 'method' => 'serialize'.$type, |
|
| 57 | 57 | ); |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | private function isDataXmlNull($data) |
| 117 | 117 | { |
| 118 | 118 | $attributes = $data->attributes('xsi', true); |
| 119 | - return isset($attributes['nil'][0]) && (string)$attributes['nil'][0] === 'true'; |
|
| 119 | + return isset($attributes['nil'][0]) && (string) $attributes['nil'][0] === 'true'; |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | public function deserializeDateTimeFromXml(XmlDeserializationVisitor $visitor, $data, array $type) |
@@ -179,9 +179,9 @@ discard block |
||
| 179 | 179 | $format = $this->getFormat($type); |
| 180 | 180 | |
| 181 | 181 | if ($immutable) { |
| 182 | - $datetime = \DateTimeImmutable::createFromFormat($format, (string)$data, $timezone); |
|
| 182 | + $datetime = \DateTimeImmutable::createFromFormat($format, (string) $data, $timezone); |
|
| 183 | 183 | } else { |
| 184 | - $datetime = \DateTime::createFromFormat($format, (string)$data, $timezone); |
|
| 184 | + $datetime = \DateTime::createFromFormat($format, (string) $data, $timezone); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | if (false === $datetime) { |
@@ -221,15 +221,15 @@ discard block |
||
| 221 | 221 | $format = 'P'; |
| 222 | 222 | |
| 223 | 223 | if (0 < $dateInterval->y) { |
| 224 | - $format .= $dateInterval->y . 'Y'; |
|
| 224 | + $format .= $dateInterval->y.'Y'; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | if (0 < $dateInterval->m) { |
| 228 | - $format .= $dateInterval->m . 'M'; |
|
| 228 | + $format .= $dateInterval->m.'M'; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | if (0 < $dateInterval->d) { |
| 232 | - $format .= $dateInterval->d . 'D'; |
|
| 232 | + $format .= $dateInterval->d.'D'; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | if (0 < $dateInterval->h || 0 < $dateInterval->i || 0 < $dateInterval->s) { |
@@ -237,15 +237,15 @@ discard block |
||
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | if (0 < $dateInterval->h) { |
| 240 | - $format .= $dateInterval->h . 'H'; |
|
| 240 | + $format .= $dateInterval->h.'H'; |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | if (0 < $dateInterval->i) { |
| 244 | - $format .= $dateInterval->i . 'M'; |
|
| 244 | + $format .= $dateInterval->i.'M'; |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | if (0 < $dateInterval->s) { |
| 248 | - $format .= $dateInterval->s . 'S'; |
|
| 248 | + $format .= $dateInterval->s.'S'; |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | if ($format === 'P') { |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | $classMetadata = $context->getMetadataFactory()->getMetadataForClass('stdClass'); |
| 51 | 51 | $visitor->startVisitingObject($classMetadata, $stdClass, array('name' => 'stdClass'), $context); |
| 52 | 52 | |
| 53 | - foreach ((array)$stdClass as $name => $value) { |
|
| 53 | + foreach ((array) $stdClass as $name => $value) { |
|
| 54 | 54 | $metadata = new StaticPropertyMetadata('stdClass', $name, $value); |
| 55 | 55 | $visitor->visitProperty($metadata, $value, $context); |
| 56 | 56 | } |
@@ -64,13 +64,13 @@ |
||
| 64 | 64 | */ |
| 65 | 65 | public function evaluate($expression, array $data = array()) |
| 66 | 66 | { |
| 67 | - if (!is_string($expression)) { |
|
| 67 | + if ( ! is_string($expression)) { |
|
| 68 | 68 | return $expression; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $context = $data + $this->context; |
| 72 | 72 | |
| 73 | - if (!array_key_exists($expression, $this->cache)) { |
|
| 73 | + if ( ! array_key_exists($expression, $this->cache)) { |
|
| 74 | 74 | $this->cache[$expression] = $this->expressionLanguage->parse($expression, array_keys($context)); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -56,7 +56,7 @@ |
||
| 56 | 56 | ? null |
| 57 | 57 | : $context->attributes->get('validation_groups')->get(); |
| 58 | 58 | |
| 59 | - if (!$groups) { |
|
| 59 | + if ( ! $groups) { |
|
| 60 | 60 | return; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -62,8 +62,7 @@ |
||
| 62 | 62 | MetadataFactoryInterface $metadataFactory, |
| 63 | 63 | HandlerRegistryInterface $handlerRegistry, |
| 64 | 64 | EventDispatcherInterface $dispatcher |
| 65 | - ) |
|
| 66 | - { |
|
| 65 | + ) { |
|
| 67 | 66 | $this->dispatcher = $dispatcher; |
| 68 | 67 | $this->metadataFactory = $metadataFactory; |
| 69 | 68 | $this->handlerRegistry = $handlerRegistry; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | case 'resource': |
| 111 | 111 | $msg = 'Resources are not supported in serialized data.'; |
| 112 | 112 | if (null !== $path = $context->getPath()) { |
| 113 | - $msg .= ' Path: ' . $path; |
|
| 113 | + $msg .= ' Path: '.$path; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | throw new RuntimeException($msg); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | /** @var $metadata ClassMetadata */ |
| 155 | 155 | $metadata = $this->metadataFactory->getMetadataForClass($type['name']); |
| 156 | 156 | |
| 157 | - if ($metadata->usingExpression && !$this->expressionExclusionStrategy) { |
|
| 157 | + if ($metadata->usingExpression && ! $this->expressionExclusionStrategy) { |
|
| 158 | 158 | throw new ExpressionLanguageRequiredException("To use conditional exclude/expose in {$metadata->name} you must configure the expression language."); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -49,8 +49,7 @@ |
||
| 49 | 49 | HandlerRegistryInterface $handlerRegistry, |
| 50 | 50 | EventDispatcherInterface $dispatcher, |
| 51 | 51 | ExpressionEvaluatorInterface $expressionEvaluator = null |
| 52 | - ) |
|
| 53 | - { |
|
| 52 | + ) { |
|
| 54 | 53 | parent::__construct($metadataFactory, $handlerRegistry, $dispatcher); |
| 55 | 54 | if ($expressionEvaluator) { |
| 56 | 55 | $this->expressionExclusionStrategy = new ExpressionLanguageExclusionStrategy($expressionEvaluator); |