Completed
Push — master ( dc05b5...73c8dd )
by Ondřej
03:15
created
src/Ivory/Type/ArrayType.php 1 patch
Braces   +19 added lines, -38 removed lines patch added patch discarded remove patch
@@ -72,8 +72,7 @@  discard block
 block discarded – undo
72 72
             for ($strOffset = $decorSepPos + 1; isset($str[$strOffset]) && ctype_space($str[$strOffset]); $strOffset++);
73 73
             $lowerBounds = $m[1];
74 74
             unset($m);
75
-        }
76
-        else {
75
+        } else {
77 76
             if (trim($str) == '{}') {
78 77
                 return [];
79 78
             }
@@ -82,11 +81,9 @@  discard block
 block discarded – undo
82 81
             for ($i = $strOffset; $i < $len; $i++) {
83 82
                 if (ctype_space($str[$i])) {
84 83
                     continue;
85
-                }
86
-                elseif ($str[$i] == '{') {
84
+                } elseif ($str[$i] == '{') {
87 85
                     $dims++;
88
-                }
89
-                else {
86
+                } else {
90 87
                     break;
91 88
                 }
92 89
             }
@@ -146,14 +143,12 @@  discard block
 block discarded – undo
146 143
                 $k = $keys[$dim];
147 144
                 if (strcasecmp($elem, 'NULL') == 0) {
148 145
                     $refs[$dim][$k] = null;
149
-                }
150
-                else {
146
+                } else {
151 147
                     $cont = ($elem[0] == '"' ? substr($elem, 1, -1) : $elem);
152 148
                     $unEsc = preg_replace('~\\\\(.)~', '$1', $cont);
153 149
                     $refs[$dim][$k] = $this->elemType->parseValue($unEsc);
154 150
                 }
155
-            }
156
-            catch (ParseException $e) {
151
+            } catch (ParseException $e) {
157 152
                 $this->throwParseException($str, 'Error parsing the element value', $strOffset, $e);
158 153
             }
159 154
             $strOffset += strlen($elem);
@@ -221,8 +216,7 @@  discard block
 block discarded – undo
221 216
             $maxDim = $curDim;
222 217
             $b = ($arr ? [$keys[0], $keys[count($keys) - 1]] : [1, 0]);
223 218
             $bounds[$curDim] = $b;
224
-        }
225
-        else {
219
+        } else {
226 220
             $b = $bounds[$curDim];
227 221
             if ($keys[0] < $b[0] || $keys[count($keys) - 1] > $b[1]) {
228 222
                 $msg = "Some array subscripts do not match the bounds of the array: " . print_r($val, true);
@@ -239,15 +233,13 @@  discard block
 block discarded – undo
239 233
         foreach ($arr as $v) {
240 234
             if ($first) {
241 235
                 $first = false;
242
-            }
243
-            else {
236
+            } else {
244 237
                 $out .= $this->delim;
245 238
             }
246 239
 
247 240
             if (is_array($v)) {
248 241
                 $out .= $this->serializeValueImpl($v, $bounds, $curDim + 1, $maxDim);
249
-            }
250
-            else {
242
+            } else {
251 243
                 if ($curDim != $maxDim) {
252 244
                     $msg = "Some array items do not match the dimensions of the array: " . print_r($val, true);
253 245
                     throw new \InvalidArgumentException($msg);
@@ -255,8 +247,7 @@  discard block
 block discarded – undo
255 247
 
256 248
                 if ($v === null) {
257 249
                     $valOut = 'NULL';
258
-                }
259
-                else {
250
+                } else {
260 251
                     $valOut = $this->elemType->serializeValue($v);
261 252
                     /* Trim the single quotes and other decoration - the value will be used inside a string literal.
262 253
                        As an optimization, doubled single quotes (meaning the literal single quote) will be preserved
@@ -328,25 +319,20 @@  discard block
 block discarded – undo
328 319
                 if ($bv !== null) {
329 320
                     return -1;
330 321
                 }
331
-            }
332
-            elseif ($bv === null) {
322
+            } elseif ($bv === null) {
333 323
                 return 1;
334
-            }
335
-            elseif (is_array($av)) {
324
+            } elseif (is_array($av)) {
336 325
                 if (is_array($bv)) {
337 326
                     $comp = $this->compareValuesImpl($av, $bv);
338 327
                     if ($comp) {
339 328
                         return $comp;
340 329
                     }
341
-                }
342
-                else {
330
+                } else {
343 331
                     return 1;
344 332
                 }
345
-            }
346
-            elseif (is_array($bv)) {
333
+            } elseif (is_array($bv)) {
347 334
                 return -1;
348
-            }
349
-            else {
335
+            } else {
350 336
                 /** @var ITotallyOrderedType $et */
351 337
                 $et = $this->elemType;
352 338
                 $comp = $et->compareValues($av, $bv);
@@ -369,22 +355,17 @@  discard block
 block discarded – undo
369 355
             $bk = key($bFst);
370 356
             if ($ak === null && $bk === null) {
371 357
                 return 0;
372
-            }
373
-            elseif ($ak === null) {
358
+            } elseif ($ak === null) {
374 359
                 return -1;
375
-            }
376
-            elseif ($bk === null) {
360
+            } elseif ($bk === null) {
377 361
                 return 1;
378
-            }
379
-            elseif (!is_numeric($ak) || !is_numeric($bk)) {
362
+            } elseif (!is_numeric($ak) || !is_numeric($bk)) {
380 363
                 return 0;
381
-            }
382
-            else {
364
+            } else {
383 365
                 $d = $ak - $bk;
384 366
                 if ($d) {
385 367
                     return $d;
386
-                }
387
-                else {
368
+                } else {
388 369
                     $aFst = current($aFst);
389 370
                     $bFst = current($bFst);
390 371
                 }
Please login to merge, or discard this patch.