Completed
Pull Request — master (#844)
by Christian
03:19
created
src/JMS/Serializer/Serializer.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         }
107 107
 
108 108
         return $this->serializationVisitors->get($format)
109
-            ->map(function (VisitorInterface $visitor) use ($context, $data, $format) {
109
+            ->map(function(VisitorInterface $visitor) use ($context, $data, $format) {
110 110
                 $type = $context->getInitialType() !== null ? $this->typeParser->parse($context->getInitialType()) : null;
111 111
 
112 112
                 $this->visit($visitor, $context, $visitor->prepare($data), $format, $type);
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         }
124 124
 
125 125
         return $this->deserializationVisitors->get($format)
126
-            ->map(function (VisitorInterface $visitor) use ($context, $data, $format, $type) {
126
+            ->map(function(VisitorInterface $visitor) use ($context, $data, $format, $type) {
127 127
                 $preparedData = $visitor->prepare($data);
128 128
                 $navigatorResult = $this->visit($visitor, $context, $preparedData, $format, $this->typeParser->parse($type));
129 129
 
@@ -142,13 +142,13 @@  discard block
 block discarded – undo
142 142
         }
143 143
 
144 144
         return $this->serializationVisitors->get('json')
145
-            ->map(function (JsonSerializationVisitor $visitor) use ($context, $data) {
145
+            ->map(function(JsonSerializationVisitor $visitor) use ($context, $data) {
146 146
                 $type = $context->getInitialType() !== null ? $this->typeParser->parse($context->getInitialType()) : null;
147 147
 
148 148
                 $this->visit($visitor, $context, $data, 'json', $type);
149 149
                 $result = $this->convertArrayObjects($visitor->getRoot());
150 150
 
151
-                if (!is_array($result)) {
151
+                if ( ! is_array($result)) {
152 152
                     throw new RuntimeException(sprintf(
153 153
                         'The input data of type "%s" did not convert to an array, but got a result of type "%s".',
154 154
                         is_object($data) ? get_class($data) : gettype($data),
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
         }
172 172
 
173 173
         return $this->deserializationVisitors->get('json')
174
-            ->map(function (JsonDeserializationVisitor $visitor) use ($data, $type, $context) {
174
+            ->map(function(JsonDeserializationVisitor $visitor) use ($data, $type, $context) {
175 175
                 $navigatorResult = $this->visit($visitor, $context, $data, 'json', $this->typeParser->parse($type));
176 176
 
177 177
                 return $this->handleDeserializeResult($visitor->getResult(), $navigatorResult);
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     private function convertArrayObjects($data)
207 207
     {
208 208
         if ($data instanceof \ArrayObject || $data instanceof \stdClass) {
209
-            $data = (array)$data;
209
+            $data = (array) $data;
210 210
         }
211 211
         if (is_array($data)) {
212 212
             foreach ($data as $k => $v) {
Please login to merge, or discard this patch.
src/JMS/Serializer/Exclusion/GroupsExclusionStrategy.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
     {
53 53
         $groups = $this->getGroupsFor($navigatorContext);
54 54
 
55
-        if (!$property->groups) {
56
-            return !in_array(self::DEFAULT_GROUP, $groups);
55
+        if ( ! $property->groups) {
56
+            return ! in_array(self::DEFAULT_GROUP, $groups);
57 57
         }
58 58
 
59 59
         return $this->shouldSkipUsingGroups($property, $groups);
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 
77 77
         $groups = $this->groups;
78 78
         foreach ($paths as $index => $path) {
79
-            if (!array_key_exists($path, $groups)) {
79
+            if ( ! array_key_exists($path, $groups)) {
80 80
                 if ($index > 0) {
81 81
                     $groups = array(self::DEFAULT_GROUP);
82 82
                 }
Please login to merge, or discard this patch.
src/JMS/Serializer/Exclusion/DisjunctExclusionStrategy.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
      */
42 42
     public function __construct($delegates)
43 43
     {
44
-        if (!$delegates instanceof SequenceInterface) {
44
+        if ( ! $delegates instanceof SequenceInterface) {
45 45
             $delegates = new Sequence($delegates);
46 46
         }
47 47
 
Please login to merge, or discard this patch.
src/JMS/Serializer/JsonSerializationVisitor.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
             $this->root = $data;
58 58
         }
59 59
 
60
-        return (string)$data;
60
+        return (string) $data;
61 61
     }
62 62
 
63 63
     public function visitBoolean($data, array $type, Context $context)
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             $this->root = $data;
67 67
         }
68 68
 
69
-        return (boolean)$data;
69
+        return (boolean) $data;
70 70
     }
71 71
 
72 72
     public function visitInteger($data, array $type, Context $context)
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             $this->root = $data;
76 76
         }
77 77
 
78
-        return (int)$data;
78
+        return (int) $data;
79 79
     }
80 80
 
81 81
     public function visitDouble($data, array $type, Context $context)
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             $this->root = $data;
85 85
         }
86 86
 
87
-        return (float)$data;
87
+        return (float) $data;
88 88
     }
89 89
 
90 90
     /**
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
             $rs = $isHash ? new \ArrayObject() : array();
107 107
         }
108 108
 
109
-        $isList = isset($type['params'][0]) && !isset($type['params'][1]);
109
+        $isList = isset($type['params'][0]) && ! isset($type['params'][1]);
110 110
 
111 111
         foreach ($data as $k => $v) {
112 112
             $v = $this->navigator->accept($v, $this->getElementType($type), $context);
@@ -251,6 +251,6 @@  discard block
 block discarded – undo
251 251
 
252 252
     public function setOptions($options)
253 253
     {
254
-        $this->options = (integer)$options;
254
+        $this->options = (integer) $options;
255 255
     }
256 256
 }
Please login to merge, or discard this patch.
src/JMS/Serializer/Annotation/ExclusionPolicy.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 
34 34
     public function __construct(array $values)
35 35
     {
36
-        if (!is_string($values['value'])) {
36
+        if ( ! is_string($values['value'])) {
37 37
             throw new RuntimeException('"value" must be a string.');
38 38
         }
39 39
 
Please login to merge, or discard this patch.
src/JMS/Serializer/Naming/CamelCaseNamingStrategy.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
      */
42 42
     public function translateName(PropertyMetadata $property)
43 43
     {
44
-        $name = preg_replace('/[A-Z]/', $this->separator . '\\0', $property->name);
44
+        $name = preg_replace('/[A-Z]/', $this->separator.'\\0', $property->name);
45 45
 
46 46
         if ($this->lowerCase) {
47 47
             return strtolower($name);
Please login to merge, or discard this patch.
src/JMS/Serializer/GraphNavigator.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
             case 'resource':
151 151
                 $msg = 'Resources are not supported in serialized data.';
152 152
                 if ($context instanceof SerializationContext && null !== $path = $context->getPath()) {
153
-                    $msg .= ' Path: ' . $path;
153
+                    $msg .= ' Path: '.$path;
154 154
                 }
155 155
 
156 156
                 throw new RuntimeException($msg);
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
                 /** @var $metadata ClassMetadata */
207 207
                 $metadata = $this->metadataFactory->getMetadataForClass($type['name']);
208 208
 
209
-                if ($metadata->usingExpression && !$this->expressionExclusionStrategy) {
209
+                if ($metadata->usingExpression && ! $this->expressionExclusionStrategy) {
210 210
                     throw new ExpressionLanguageRequiredException("To use conditional exclude/expose in {$metadata->name} you must configure the expression language.");
211 211
                 }
212 212
 
213
-                if ($context instanceof DeserializationContext && !empty($metadata->discriminatorMap) && $type['name'] === $metadata->discriminatorBaseClass) {
213
+                if ($context instanceof DeserializationContext && ! empty($metadata->discriminatorMap) && $type['name'] === $metadata->discriminatorBaseClass) {
214 214
                     $metadata = $this->resolveMetadata($data, $metadata);
215 215
                 }
216 216
 
@@ -280,22 +280,22 @@  discard block
 block discarded – undo
280 280
     {
281 281
         switch (true) {
282 282
             case is_array($data) && isset($data[$metadata->discriminatorFieldName]):
283
-                $typeValue = (string)$data[$metadata->discriminatorFieldName];
283
+                $typeValue = (string) $data[$metadata->discriminatorFieldName];
284 284
                 break;
285 285
 
286 286
             // Check XML attribute for discriminatorFieldName
287 287
             case is_object($data) && $metadata->xmlDiscriminatorAttribute && isset($data[$metadata->discriminatorFieldName]):
288
-                $typeValue = (string)$data[$metadata->discriminatorFieldName];
288
+                $typeValue = (string) $data[$metadata->discriminatorFieldName];
289 289
                 break;
290 290
 
291 291
             // Check XML element with namespace for discriminatorFieldName
292
-            case is_object($data) && !$metadata->xmlDiscriminatorAttribute && null !== $metadata->xmlDiscriminatorNamespace && isset($data->children($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName}):
293
-                $typeValue = (string)$data->children($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName};
292
+            case is_object($data) && ! $metadata->xmlDiscriminatorAttribute && null !== $metadata->xmlDiscriminatorNamespace && isset($data->children($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName}):
293
+                $typeValue = (string) $data->children($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName};
294 294
                 break;
295 295
 
296 296
             // Check XML element for discriminatorFieldName
297 297
             case is_object($data) && isset($data->{$metadata->discriminatorFieldName}):
298
-                $typeValue = (string)$data->{$metadata->discriminatorFieldName};
298
+                $typeValue = (string) $data->{$metadata->discriminatorFieldName};
299 299
                 break;
300 300
 
301 301
             default:
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
                 ));
307 307
         }
308 308
 
309
-        if (!isset($metadata->discriminatorMap[$typeValue])) {
309
+        if ( ! isset($metadata->discriminatorMap[$typeValue])) {
310 310
             throw new \LogicException(sprintf(
311 311
                 'The type value "%s" does not exist in the discriminator map of class "%s". Available types: %s',
312 312
                 $typeValue,
Please login to merge, or discard this patch.
src/JMS/Serializer/XmlDeserializationVisitor.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
         if (false !== stripos($data, '<!doctype')) {
69 69
             $internalSubset = $this->getDomDocumentTypeEntitySubset($data);
70
-            if (!in_array($internalSubset, $this->doctypeWhitelist, true)) {
70
+            if ( ! in_array($internalSubset, $this->doctypeWhitelist, true)) {
71 71
                 throw new InvalidArgumentException(sprintf(
72 72
                     'The document type "%s" is not allowed. If it is safe, you may add it to the whitelist configuration.',
73 73
                     $internalSubset
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
     private function emptyStringToSpaceCharacter($data)
91 91
     {
92
-        return $data === '' ? ' ' : (string)$data;
92
+        return $data === '' ? ' ' : (string) $data;
93 93
     }
94 94
 
95 95
     public function visitNull($data, array $type, Context $context)
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
     public function visitString($data, array $type, Context $context)
101 101
     {
102
-        $data = (string)$data;
102
+        $data = (string) $data;
103 103
 
104 104
         if (null === $this->result) {
105 105
             $this->result = $data;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
     public function visitBoolean($data, array $type, Context $context)
112 112
     {
113
-        $data = (string)$data;
113
+        $data = (string) $data;
114 114
 
115 115
         if ('true' === $data || '1' === $data) {
116 116
             $data = true;
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 
130 130
     public function visitInteger($data, array $type, Context $context)
131 131
     {
132
-        $data = (integer)$data;
132
+        $data = (integer) $data;
133 133
 
134 134
         if (null === $this->result) {
135 135
             $this->result = $data;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
     public function visitDouble($data, array $type, Context $context)
142 142
     {
143
-        $data = (double)$data;
143
+        $data = (double) $data;
144 144
 
145 145
         if (null === $this->result) {
146 146
             $this->result = $data;
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
             $nodes = $data->xpath($entryName);
168 168
         }
169 169
 
170
-        if (!count($nodes)) {
170
+        if ( ! count($nodes)) {
171 171
             if (null === $this->result) {
172 172
                 return $this->result = array();
173 173
             }
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
                 $nodes = $data->children($namespace)->$entryName;
207 207
                 foreach ($nodes as $v) {
208 208
                     $attrs = $v->attributes();
209
-                    if (!isset($attrs[$this->currentMetadata->xmlKeyAttribute])) {
209
+                    if ( ! isset($attrs[$this->currentMetadata->xmlKeyAttribute])) {
210 210
                         throw new RuntimeException(sprintf('The key attribute "%s" must be set for each entry of the map.', $this->currentMetadata->xmlKeyAttribute));
211 211
                     }
212 212
 
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
     {
235 235
         $name = $this->namingStrategy->translateName($metadata);
236 236
 
237
-        if (!$metadata->type) {
237
+        if ( ! $metadata->type) {
238 238
             throw new RuntimeException(sprintf('You must define a type for %s::$%s.', $metadata->reflection->class, $metadata->name));
239 239
         }
240 240
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 
259 259
         if ($metadata->xmlCollection) {
260 260
             $enclosingElem = $data;
261
-            if (!$metadata->xmlCollectionInline) {
261
+            if ( ! $metadata->xmlCollectionInline) {
262 262
                 $enclosingElem = $data->children($metadata->xmlNamespace)->$name;
263 263
             }
264 264
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 
273 273
         if ($metadata->xmlNamespace) {
274 274
             $node = $data->children($metadata->xmlNamespace)->$name;
275
-            if (!$node->count()) {
275
+            if ( ! $node->count()) {
276 276
                 return;
277 277
             }
278 278
         } else {
@@ -282,9 +282,9 @@  discard block
 block discarded – undo
282 282
             if (isset($namespaces[''])) {
283 283
                 $prefix = uniqid('ns-');
284 284
                 $data->registerXPathNamespace($prefix, $namespaces['']);
285
-                $nodes = $data->xpath('./' . $prefix . ':' . $name);
285
+                $nodes = $data->xpath('./'.$prefix.':'.$name);
286 286
             } else {
287
-                $nodes = $data->xpath('./' . $name);
287
+                $nodes = $data->xpath('./'.$name);
288 288
             }
289 289
             if (empty($nodes)) {
290 290
                 return;
Please login to merge, or discard this patch.
src/JMS/Serializer/GenericDeserializationVisitor.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
     public function visitString($data, array $type, Context $context)
60 60
     {
61
-        $data = (string)$data;
61
+        $data = (string) $data;
62 62
 
63 63
         if (null === $this->result) {
64 64
             $this->result = $data;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
     public function visitBoolean($data, array $type, Context $context)
71 71
     {
72
-        $data = (Boolean)$data;
72
+        $data = (Boolean) $data;
73 73
 
74 74
         if (null === $this->result) {
75 75
             $this->result = $data;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
     public function visitInteger($data, array $type, Context $context)
82 82
     {
83
-        $data = (integer)$data;
83
+        $data = (integer) $data;
84 84
 
85 85
         if (null === $this->result) {
86 86
             $this->result = $data;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
     public function visitDouble($data, array $type, Context $context)
93 93
     {
94
-        $data = (double)$data;
94
+        $data = (double) $data;
95 95
 
96 96
         if (null === $this->result) {
97 97
             $this->result = $data;
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 
103 103
     public function visitArray($data, array $type, Context $context)
104 104
     {
105
-        if (!is_array($data)) {
105
+        if ( ! is_array($data)) {
106 106
             throw new RuntimeException(sprintf('Expected array, but got %s: %s', gettype($data), json_encode($data)));
107 107
         }
108 108
 
109 109
         // If no further parameters were given, keys/values are just passed as is.
110
-        if (!$type['params']) {
110
+        if ( ! $type['params']) {
111 111
             if (null === $this->result) {
112 112
                 $this->result = $data;
113 113
             }
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
             return;
167 167
         }
168 168
 
169
-        if (!is_array($data)) {
169
+        if ( ! is_array($data)) {
170 170
             throw new RuntimeException(sprintf('Invalid data "%s"(%s), expected "%s".', $data, $metadata->type['name'], $metadata->reflection->class));
171 171
         }
172 172
 
173
-        if (!array_key_exists($name, $data)) {
173
+        if ( ! array_key_exists($name, $data)) {
174 174
             return;
175 175
         }
176 176
 
177
-        if (!$metadata->type) {
177
+        if ( ! $metadata->type) {
178 178
             throw new RuntimeException(sprintf('You must define a type for %s::$%s.', $metadata->reflection->class, $metadata->name));
179 179
         }
180 180
 
Please login to merge, or discard this patch.