Completed
Pull Request — master (#863)
by Omar
04:51
created
src/JMS/Serializer/Metadata/Driver/YamlDriver.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     {
36 36
         $config = Yaml::parse(file_get_contents($file));
37 37
 
38
-        if (!isset($config[$name = $class->name])) {
38
+        if ( ! isset($config[$name = $class->name])) {
39 39
             throw new RuntimeException(sprintf('Expected metadata for class %s to be defined in %s.', $class->name, $file));
40 40
         }
41 41
 
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
         $metadata->fileResources[] = $file;
45 45
         $metadata->fileResources[] = $class->getFileName();
46 46
         $exclusionPolicy = isset($config['exclusion_policy']) ? strtoupper($config['exclusion_policy']) : 'NONE';
47
-        $excludeAll = isset($config['exclude']) ? (Boolean)$config['exclude'] : false;
47
+        $excludeAll = isset($config['exclude']) ? (Boolean) $config['exclude'] : false;
48 48
         $classAccessType = isset($config['access_type']) ? $config['access_type'] : PropertyMetadata::ACCESS_TYPE_PROPERTY;
49
-        $readOnlyClass = isset($config['read_only']) ? (Boolean)$config['read_only'] : false;
49
+        $readOnlyClass = isset($config['read_only']) ? (Boolean) $config['read_only'] : false;
50 50
         $this->addClassProperties($metadata, $config);
51 51
 
52 52
         $propertiesMetadata = array();
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 
59 59
                 } else {
60 60
 
61
-                    if (!$class->hasMethod($methodName)) {
62
-                        throw new RuntimeException('The method ' . $methodName . ' not found in class ' . $class->name);
61
+                    if ( ! $class->hasMethod($methodName)) {
62
+                        throw new RuntimeException('The method '.$methodName.' not found in class '.$class->name);
63 63
                     }
64 64
                     $virtualPropertyMetadata = new VirtualPropertyMetadata($name, $methodName);
65 65
                 }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             }
69 69
         }
70 70
 
71
-        if (!$excludeAll) {
71
+        if ( ! $excludeAll) {
72 72
             foreach ($class->getProperties() as $property) {
73 73
                 if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) {
74 74
                     continue;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
                     $pConfig = $config['properties'][$pName];
89 89
 
90 90
                     if (isset($pConfig['exclude'])) {
91
-                        $isExclude = (Boolean)$pConfig['exclude'];
91
+                        $isExclude = (Boolean) $pConfig['exclude'];
92 92
                     }
93 93
 
94 94
                     if ($isExclude) {
@@ -96,35 +96,35 @@  discard block
 block discarded – undo
96 96
                     }
97 97
 
98 98
                     if (isset($pConfig['expose'])) {
99
-                        $isExpose = (Boolean)$pConfig['expose'];
99
+                        $isExpose = (Boolean) $pConfig['expose'];
100 100
                     }
101 101
 
102 102
                     if (isset($pConfig['skip_when_empty'])) {
103
-                        $pMetadata->skipWhenEmpty = (Boolean)$pConfig['skip_when_empty'];
103
+                        $pMetadata->skipWhenEmpty = (Boolean) $pConfig['skip_when_empty'];
104 104
                     }
105 105
 
106 106
                     if (isset($pConfig['since_version'])) {
107
-                        $pMetadata->sinceVersion = (string)$pConfig['since_version'];
107
+                        $pMetadata->sinceVersion = (string) $pConfig['since_version'];
108 108
                     }
109 109
 
110 110
                     if (isset($pConfig['until_version'])) {
111
-                        $pMetadata->untilVersion = (string)$pConfig['until_version'];
111
+                        $pMetadata->untilVersion = (string) $pConfig['until_version'];
112 112
                     }
113 113
 
114 114
                     if (isset($pConfig['exclude_if'])) {
115
-                        $pMetadata->excludeIf = (string)$pConfig['exclude_if'];
115
+                        $pMetadata->excludeIf = (string) $pConfig['exclude_if'];
116 116
                     }
117 117
 
118 118
                     if (isset($pConfig['expose_if'])) {
119
-                        $pMetadata->excludeIf = "!(" . $pConfig['expose_if'] . ")";
119
+                        $pMetadata->excludeIf = "!(".$pConfig['expose_if'].")";
120 120
                     }
121 121
 
122 122
                     if (isset($pConfig['serialized_name'])) {
123
-                        $pMetadata->serializedName = (string)$pConfig['serialized_name'];
123
+                        $pMetadata->serializedName = (string) $pConfig['serialized_name'];
124 124
                     }
125 125
 
126 126
                     if (isset($pConfig['type'])) {
127
-                        $pMetadata->setType((string)$pConfig['type']);
127
+                        $pMetadata->setType((string) $pConfig['type']);
128 128
                     }
129 129
 
130 130
                     if (isset($pConfig['groups'])) {
@@ -136,21 +136,21 @@  discard block
 block discarded – undo
136 136
 
137 137
                         $colConfig = $pConfig['xml_list'];
138 138
                         if (isset($colConfig['inline'])) {
139
-                            $pMetadata->xmlCollectionInline = (Boolean)$colConfig['inline'];
139
+                            $pMetadata->xmlCollectionInline = (Boolean) $colConfig['inline'];
140 140
                         }
141 141
 
142 142
                         if (isset($colConfig['entry_name'])) {
143
-                            $pMetadata->xmlEntryName = (string)$colConfig['entry_name'];
143
+                            $pMetadata->xmlEntryName = (string) $colConfig['entry_name'];
144 144
                         }
145 145
 
146 146
                         if (isset($colConfig['skip_when_empty'])) {
147
-                            $pMetadata->xmlCollectionSkipWhenEmpty = (Boolean)$colConfig['skip_when_empty'];
147
+                            $pMetadata->xmlCollectionSkipWhenEmpty = (Boolean) $colConfig['skip_when_empty'];
148 148
                         } else {
149 149
                             $pMetadata->xmlCollectionSkipWhenEmpty = true;
150 150
                         }
151 151
 
152 152
                         if (isset($colConfig['namespace'])) {
153
-                            $pMetadata->xmlEntryNamespace = (string)$colConfig['namespace'];
153
+                            $pMetadata->xmlEntryNamespace = (string) $colConfig['namespace'];
154 154
                         }
155 155
                     }
156 156
 
@@ -159,15 +159,15 @@  discard block
 block discarded – undo
159 159
 
160 160
                         $colConfig = $pConfig['xml_map'];
161 161
                         if (isset($colConfig['inline'])) {
162
-                            $pMetadata->xmlCollectionInline = (Boolean)$colConfig['inline'];
162
+                            $pMetadata->xmlCollectionInline = (Boolean) $colConfig['inline'];
163 163
                         }
164 164
 
165 165
                         if (isset($colConfig['entry_name'])) {
166
-                            $pMetadata->xmlEntryName = (string)$colConfig['entry_name'];
166
+                            $pMetadata->xmlEntryName = (string) $colConfig['entry_name'];
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
                         if (isset($colConfig['key_attribute_name'])) {
@@ -179,33 +179,33 @@  discard block
 block discarded – undo
179 179
                     if (isset($pConfig['xml_element'])) {
180 180
                         $colConfig = $pConfig['xml_element'];
181 181
                         if (isset($colConfig['cdata'])) {
182
-                            $pMetadata->xmlElementCData = (Boolean)$colConfig['cdata'];
182
+                            $pMetadata->xmlElementCData = (Boolean) $colConfig['cdata'];
183 183
                         }
184 184
 
185 185
                         if (isset($colConfig['namespace'])) {
186
-                            $pMetadata->xmlNamespace = (string)$colConfig['namespace'];
186
+                            $pMetadata->xmlNamespace = (string) $colConfig['namespace'];
187 187
                         }
188 188
                     }
189 189
 
190 190
                     if (isset($pConfig['xml_attribute'])) {
191
-                        $pMetadata->xmlAttribute = (Boolean)$pConfig['xml_attribute'];
191
+                        $pMetadata->xmlAttribute = (Boolean) $pConfig['xml_attribute'];
192 192
                     }
193 193
 
194 194
                     if (isset($pConfig['xml_attribute_map'])) {
195
-                        $pMetadata->xmlAttributeMap = (Boolean)$pConfig['xml_attribute_map'];
195
+                        $pMetadata->xmlAttributeMap = (Boolean) $pConfig['xml_attribute_map'];
196 196
                     }
197 197
 
198 198
                     if (isset($pConfig['xml_value'])) {
199
-                        $pMetadata->xmlValue = (Boolean)$pConfig['xml_value'];
199
+                        $pMetadata->xmlValue = (Boolean) $pConfig['xml_value'];
200 200
                     }
201 201
 
202 202
                     if (isset($pConfig['xml_key_value_pairs'])) {
203
-                        $pMetadata->xmlKeyValuePairs = (Boolean)$pConfig['xml_key_value_pairs'];
203
+                        $pMetadata->xmlKeyValuePairs = (Boolean) $pConfig['xml_key_value_pairs'];
204 204
                     }
205 205
 
206 206
                     //we need read_only before setter and getter set, because that method depends on flag being set
207 207
                     if (isset($pConfig['read_only'])) {
208
-                        $pMetadata->readOnly = (Boolean)$pConfig['read_only'];
208
+                        $pMetadata->readOnly = (Boolean) $pConfig['read_only'];
209 209
                     } else {
210 210
                         $pMetadata->readOnly = $pMetadata->readOnly || $readOnlyClass;
211 211
                     }
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
                     );
218 218
 
219 219
                     if (isset($pConfig['inline'])) {
220
-                        $pMetadata->inline = (Boolean)$pConfig['inline'];
220
+                        $pMetadata->inline = (Boolean) $pConfig['inline'];
221 221
                     }
222 222
 
223 223
                     if (isset($pConfig['max_depth'])) {
224
-                        $pMetadata->maxDepth = (int)$pConfig['max_depth'];
224
+                        $pMetadata->maxDepth = (int) $pConfig['max_depth'];
225 225
                     }
226 226
                 }
227
-                if ((ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude)
227
+                if ((ExclusionPolicy::NONE === $exclusionPolicy && ! $isExclude)
228 228
                     || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose)
229 229
                 ) {
230 230
                     $metadata->addPropertyMetadata($pMetadata);
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 
266 266
     private function addClassProperties(ClassMetadata $metadata, array $config)
267 267
     {
268
-        if (isset($config['custom_accessor_order']) && !isset($config['accessor_order'])) {
268
+        if (isset($config['custom_accessor_order']) && ! isset($config['accessor_order'])) {
269 269
             $config['accessor_order'] = 'custom';
270 270
         }
271 271
 
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
         }
275 275
 
276 276
         if (isset($config['xml_root_name'])) {
277
-            $metadata->xmlRootName = (string)$config['xml_root_name'];
277
+            $metadata->xmlRootName = (string) $config['xml_root_name'];
278 278
         }
279 279
 
280 280
         if (isset($config['xml_root_namespace'])) {
281
-            $metadata->xmlRootNamespace = (string)$config['xml_root_namespace'];
281
+            $metadata->xmlRootNamespace = (string) $config['xml_root_namespace'];
282 282
         }
283 283
 
284 284
         if (array_key_exists('xml_namespaces', $config)) {
@@ -293,25 +293,25 @@  discard block
 block discarded – undo
293 293
             if (isset($config['discriminator']['disabled']) && true === $config['discriminator']['disabled']) {
294 294
                 $metadata->discriminatorDisabled = true;
295 295
             } else {
296
-                if (!isset($config['discriminator']['field_name'])) {
296
+                if ( ! isset($config['discriminator']['field_name'])) {
297 297
                     throw new RuntimeException('The "field_name" attribute must be set for discriminators.');
298 298
                 }
299 299
 
300
-                if (!isset($config['discriminator']['map']) || !is_array($config['discriminator']['map'])) {
300
+                if ( ! isset($config['discriminator']['map']) || ! is_array($config['discriminator']['map'])) {
301 301
                     throw new RuntimeException('The "map" attribute must be set, and be an array for discriminators.');
302 302
                 }
303 303
                 $groups = isset($config['discriminator']['groups']) ? $config['discriminator']['groups'] : array();
304 304
                 $metadata->setDiscriminator($config['discriminator']['field_name'], $config['discriminator']['map'], $groups);
305 305
 
306 306
                 if (isset($config['discriminator']['xml_attribute'])) {
307
-                    $metadata->xmlDiscriminatorAttribute = (bool)$config['discriminator']['xml_attribute'];
307
+                    $metadata->xmlDiscriminatorAttribute = (bool) $config['discriminator']['xml_attribute'];
308 308
                 }
309 309
                 if (isset($config['discriminator']['xml_element'])) {
310 310
                     if (isset($config['discriminator']['xml_element']['cdata'])) {
311
-                        $metadata->xmlDiscriminatorCData = (bool)$config['discriminator']['xml_element']['cdata'];
311
+                        $metadata->xmlDiscriminatorCData = (bool) $config['discriminator']['xml_element']['cdata'];
312 312
                     }
313 313
                     if (isset($config['discriminator']['xml_element']['namespace'])) {
314
-                        $metadata->xmlDiscriminatorNamespace = (string)$config['discriminator']['xml_element']['namespace'];
314
+                        $metadata->xmlDiscriminatorNamespace = (string) $config['discriminator']['xml_element']['namespace'];
315 315
                     }
316 316
                 }
317 317
 
@@ -323,13 +323,13 @@  discard block
 block discarded – undo
323 323
     {
324 324
         if (is_string($config)) {
325 325
             $config = array($config);
326
-        } elseif (!is_array($config)) {
326
+        } elseif ( ! is_array($config)) {
327 327
             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'])));
328 328
         }
329 329
 
330 330
         $methods = array();
331 331
         foreach ($config as $name) {
332
-            if (!$class->hasMethod($name)) {
332
+            if ( ! $class->hasMethod($name)) {
333 333
                 throw new RuntimeException(sprintf('The method %s does not exist in class %s.', $name, $class->name));
334 334
             }
335 335
 
Please login to merge, or discard this patch.