Completed
Push — master ( 9d7f2b...8fe48d )
by Lars
24:45
created
src/Arrayy.php 1 patch
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
     if ($this->checkPropertiesMismatchInConstructor === true) {
69 69
       if (\count(\array_diff_key($this->properties, $array)) > 0) {
70
-        throw new \InvalidArgumentException('Property mismatch - input: ' . print_r(array_keys($array), true) . ' | expected: ' . print_r(array_keys($this->properties), true));
70
+        throw new \InvalidArgumentException('Property mismatch - input: '.print_r(array_keys($array), true).' | expected: '.print_r(array_keys($this->properties), true));
71 71
       }
72 72
     }
73 73
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
       return false;
114 114
     }
115 115
 
116
-    return (array)$this->array;
116
+    return (array) $this->array;
117 117
   }
118 118
 
119 119
   /**
@@ -357,8 +357,8 @@  discard block
 block discarded – undo
357 357
     }
358 358
 
359 359
     // php cast "bool"-index into "int"-index
360
-    if ((bool)$offset === $offset) {
361
-      $offset = (int)$offset;
360
+    if ((bool) $offset === $offset) {
361
+      $offset = (int) $offset;
362 362
     }
363 363
 
364 364
     $tmpReturn = \array_key_exists($offset, $this->array);
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
         (
370 370
             $tmpReturn === false
371 371
             &&
372
-            \strpos((string)$offset, $this->pathSeparator) === false
372
+            \strpos((string) $offset, $this->pathSeparator) === false
373 373
         )
374 374
     ) {
375 375
       return $tmpReturn;
@@ -377,16 +377,16 @@  discard block
 block discarded – undo
377 377
 
378 378
     $offsetExists = false;
379 379
 
380
-    if (\strpos((string)$offset, $this->pathSeparator) !== false) {
380
+    if (\strpos((string) $offset, $this->pathSeparator) !== false) {
381 381
 
382 382
       $offsetExists = false;
383
-      $explodedPath = \explode($this->pathSeparator, (string)$offset);
383
+      $explodedPath = \explode($this->pathSeparator, (string) $offset);
384 384
       $lastOffset = \array_pop($explodedPath);
385 385
       $containerPath = \implode($this->pathSeparator, $explodedPath);
386 386
 
387 387
       $this->callAtPath(
388 388
           $containerPath,
389
-          function ($container) use ($lastOffset, &$offsetExists) {
389
+          function($container) use ($lastOffset, &$offsetExists) {
390 390
             $offsetExists = \array_key_exists($lastOffset, $container);
391 391
           }
392 392
       );
@@ -439,14 +439,14 @@  discard block
 block discarded – undo
439 439
       return;
440 440
     }
441 441
 
442
-    if (\strpos((string)$offset, $this->pathSeparator) !== false) {
442
+    if (\strpos((string) $offset, $this->pathSeparator) !== false) {
443 443
 
444
-      $path = \explode($this->pathSeparator, (string)$offset);
444
+      $path = \explode($this->pathSeparator, (string) $offset);
445 445
       $pathToUnset = \array_pop($path);
446 446
 
447 447
       $this->callAtPath(
448 448
           \implode($this->pathSeparator, $path),
449
-          function (&$offset) use ($pathToUnset) {
449
+          function(&$offset) use ($pathToUnset) {
450 450
             unset($offset[$pathToUnset]);
451 451
           }
452 452
       );
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
     }
483 483
 
484 484
     if (\strpos($class, '\\') === 0) {
485
-      $class = '\\' . $class;
485
+      $class = '\\'.$class;
486 486
       if (\class_exists($class)) {
487 487
         $this->iteratorClass = $class;
488 488
 
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
       }
491 491
     }
492 492
 
493
-    throw new \InvalidArgumentException('The iterator class does not exist: ' . $class);
493
+    throw new \InvalidArgumentException('The iterator class does not exist: '.$class);
494 494
   }
495 495
 
496 496
   /**
@@ -588,11 +588,11 @@  discard block
 block discarded – undo
588 588
     $result = [];
589 589
     foreach ($this->array as $key => $item) {
590 590
       if ($item instanceof self) {
591
-        $result[$prefix . $key] = $item->appendToEachKey($prefix);
591
+        $result[$prefix.$key] = $item->appendToEachKey($prefix);
592 592
       } elseif (\is_array($item)) {
593
-        $result[$prefix . $key] = self::create($item)->appendToEachKey($prefix)->toArray();
593
+        $result[$prefix.$key] = self::create($item)->appendToEachKey($prefix)->toArray();
594 594
       } else {
595
-        $result[$prefix . $key] = $item;
595
+        $result[$prefix.$key] = $item;
596 596
       }
597 597
     }
598 598
 
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
       } elseif (\is_object($item)) {
618 618
         $result[$key] = $item;
619 619
       } else {
620
-        $result[$key] = $prefix . $item;
620
+        $result[$key] = $prefix.$item;
621 621
       }
622 622
     }
623 623
 
@@ -828,8 +828,8 @@  discard block
 block discarded – undo
828 828
   public function clean()
829 829
   {
830 830
     return $this->filter(
831
-        function ($value) {
832
-          return (bool)$value;
831
+        function($value) {
832
+          return (bool) $value;
833 833
         }
834 834
     );
835 835
   }
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
       return $this->in_array_recursive(
879 879
           UTF8::strtoupper($value),
880 880
           $this->walk(
881
-              function (&$val) {
881
+              function(&$val) {
882 882
                 $val = UTF8::strtoupper($val);
883 883
               },
884 884
               true
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
     return \in_array(
891 891
         UTF8::strtoupper($value),
892 892
         $this->walk(
893
-            function (&$val) {
893
+            function(&$val) {
894 894
               $val = UTF8::strtoupper($val);
895 895
             },
896 896
             false
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
     // trim all string in the array
1113 1113
     \array_walk(
1114 1114
         $array,
1115
-        function (&$val) {
1115
+        function(&$val) {
1116 1116
           /** @noinspection ReferenceMismatchInspection */
1117 1117
           if (\is_string($val)) {
1118 1118
             $val = \trim($val);
@@ -1349,7 +1349,7 @@  discard block
 block discarded – undo
1349 1349
     }
1350 1350
 
1351 1351
     if ($isObject && \method_exists($array, '__toArray')) {
1352
-      return (array)$array->__toArray();
1352
+      return (array) $array->__toArray();
1353 1353
     }
1354 1354
 
1355 1355
     /** @noinspection ReferenceMismatchInspection */
@@ -1358,7 +1358,7 @@  discard block
 block discarded – undo
1358 1358
         ||
1359 1359
         ($isObject && \method_exists($array, '__toString'))
1360 1360
     ) {
1361
-      return [(string)$array];
1361
+      return [(string) $array];
1362 1362
     }
1363 1363
 
1364 1364
     throw new \InvalidArgumentException(
@@ -1460,54 +1460,54 @@  discard block
 block discarded – undo
1460 1460
     }
1461 1461
 
1462 1462
     $ops = [
1463
-        'eq'          => function ($item, $prop, $value) {
1463
+        'eq'          => function($item, $prop, $value) {
1464 1464
           return $item[$prop] === $value;
1465 1465
         },
1466
-        'gt'          => function ($item, $prop, $value) {
1466
+        'gt'          => function($item, $prop, $value) {
1467 1467
           return $item[$prop] > $value;
1468 1468
         },
1469
-        'ge'          => function ($item, $prop, $value) {
1469
+        'ge'          => function($item, $prop, $value) {
1470 1470
           return $item[$prop] >= $value;
1471 1471
         },
1472
-        'gte'         => function ($item, $prop, $value) {
1472
+        'gte'         => function($item, $prop, $value) {
1473 1473
           return $item[$prop] >= $value;
1474 1474
         },
1475
-        'lt'          => function ($item, $prop, $value) {
1475
+        'lt'          => function($item, $prop, $value) {
1476 1476
           return $item[$prop] < $value;
1477 1477
         },
1478
-        'le'          => function ($item, $prop, $value) {
1478
+        'le'          => function($item, $prop, $value) {
1479 1479
           return $item[$prop] <= $value;
1480 1480
         },
1481
-        'lte'         => function ($item, $prop, $value) {
1481
+        'lte'         => function($item, $prop, $value) {
1482 1482
           return $item[$prop] <= $value;
1483 1483
         },
1484
-        'ne'          => function ($item, $prop, $value) {
1484
+        'ne'          => function($item, $prop, $value) {
1485 1485
           return $item[$prop] !== $value;
1486 1486
         },
1487
-        'contains'    => function ($item, $prop, $value) {
1488
-          return \in_array($item[$prop], (array)$value, true);
1487
+        'contains'    => function($item, $prop, $value) {
1488
+          return \in_array($item[$prop], (array) $value, true);
1489 1489
         },
1490
-        'notContains' => function ($item, $prop, $value) {
1491
-          return !\in_array($item[$prop], (array)$value, true);
1490
+        'notContains' => function($item, $prop, $value) {
1491
+          return !\in_array($item[$prop], (array) $value, true);
1492 1492
         },
1493
-        'newer'       => function ($item, $prop, $value) {
1493
+        'newer'       => function($item, $prop, $value) {
1494 1494
           return \strtotime($item[$prop]) > \strtotime($value);
1495 1495
         },
1496
-        'older'       => function ($item, $prop, $value) {
1496
+        'older'       => function($item, $prop, $value) {
1497 1497
           return \strtotime($item[$prop]) < \strtotime($value);
1498 1498
         },
1499 1499
     ];
1500 1500
 
1501 1501
     $result = \array_values(
1502 1502
         \array_filter(
1503
-            (array)$this->array,
1504
-            function ($item) use (
1503
+            (array) $this->array,
1504
+            function($item) use (
1505 1505
                 $property,
1506 1506
                 $value,
1507 1507
                 $ops,
1508 1508
                 $comparisonOp
1509 1509
             ) {
1510
-              $item = (array)$item;
1510
+              $item = (array) $item;
1511 1511
               $itemArrayy = new Arrayy($item);
1512 1512
               $item[$property] = $itemArrayy->get($property, []);
1513 1513
 
@@ -1576,9 +1576,9 @@  discard block
 block discarded – undo
1576 1576
   {
1577 1577
     if ($number === null) {
1578 1578
       $arrayTmp = $this->array;
1579
-      $array = (array)\array_shift($arrayTmp);
1579
+      $array = (array) \array_shift($arrayTmp);
1580 1580
     } else {
1581
-      $number = (int)$number;
1581
+      $number = (int) $number;
1582 1582
       $arrayTmp = $this->array;
1583 1583
       $array = \array_splice($arrayTmp, 0, $number, true);
1584 1584
     }
@@ -1596,9 +1596,9 @@  discard block
 block discarded – undo
1596 1596
   public function firstsMutable(int $number = null)
1597 1597
   {
1598 1598
     if ($number === null) {
1599
-      $this->array = (array)\array_shift($this->array);
1599
+      $this->array = (array) \array_shift($this->array);
1600 1600
     } else {
1601
-      $number = (int)$number;
1601
+      $number = (int) $number;
1602 1602
       $this->array = \array_splice($this->array, 0, $number, true);
1603 1603
     }
1604 1604
 
@@ -1640,8 +1640,8 @@  discard block
 block discarded – undo
1640 1640
     }
1641 1641
 
1642 1642
     // php cast "bool"-index into "int"-index
1643
-    if ((bool)$key === $key) {
1644
-      $key = (int)$key;
1643
+    if ((bool) $key === $key) {
1644
+      $key = (int) $key;
1645 1645
     }
1646 1646
 
1647 1647
     if (\array_key_exists($key, $usedArray) === true) {
@@ -1653,7 +1653,7 @@  discard block
 block discarded – undo
1653 1653
     }
1654 1654
 
1655 1655
     // Crawl through array, get key according to object or not
1656
-    foreach (\explode($this->pathSeparator, (string)$key) as $segment) {
1656
+    foreach (\explode($this->pathSeparator, (string) $key) as $segment) {
1657 1657
       if (!isset($usedArray[$segment])) {
1658 1658
         return $fallback instanceof \Closure ? $fallback() : $fallback;
1659 1659
       }
@@ -1761,7 +1761,7 @@  discard block
 block discarded – undo
1761 1761
   protected function getPublicProperties(): array
1762 1762
   {
1763 1763
     static $PROPERTY_CACHE = [];
1764
-    $cacheKey = 'Class::' . static::class;
1764
+    $cacheKey = 'Class::'.static::class;
1765 1765
 
1766 1766
     if (isset($PROPERTY_CACHE[$cacheKey])) {
1767 1767
       return $PROPERTY_CACHE[$cacheKey];
@@ -1855,7 +1855,7 @@  discard block
 block discarded – undo
1855 1855
    */
1856 1856
   public function group($grouper, bool $saveKeys = false)
1857 1857
   {
1858
-    $array = (array)$this->array;
1858
+    $array = (array) $this->array;
1859 1859
     $result = [];
1860 1860
 
1861 1861
     // Iterate over values, group by property/results from closure.
@@ -1958,7 +1958,7 @@  discard block
 block discarded – undo
1958 1958
       );
1959 1959
     }
1960 1960
 
1961
-    return (string)$pieces;
1961
+    return (string) $pieces;
1962 1962
   }
1963 1963
 
1964 1964
   /**
@@ -2081,7 +2081,7 @@  discard block
 block discarded – undo
2081 2081
    */
2082 2082
   protected function internalRemove($key): bool
2083 2083
   {
2084
-    $path = \explode($this->pathSeparator, (string)$key);
2084
+    $path = \explode($this->pathSeparator, (string) $key);
2085 2085
 
2086 2086
     // Crawl though the keys
2087 2087
     while (\count($path, COUNT_NORMAL) > 1) {
@@ -2113,7 +2113,7 @@  discard block
 block discarded – undo
2113 2113
   {
2114 2114
     if ($this->checkPropertyTypes === true) {
2115 2115
       if (isset($this->properties[$key]) === false) {
2116
-        throw new \InvalidArgumentException('The key ' . $key . ' does not exists as @property in the class (' . \get_class($this) . ').');
2116
+        throw new \InvalidArgumentException('The key '.$key.' does not exists as @property in the class ('.\get_class($this).').');
2117 2117
       }
2118 2118
 
2119 2119
       $this->properties[$key]->set($value);
@@ -2124,14 +2124,14 @@  discard block
 block discarded – undo
2124 2124
     }
2125 2125
 
2126 2126
     // init
2127
-    $array =& $this->array;
2128
-    $path = \explode($this->pathSeparator, (string)$key);
2127
+    $array = & $this->array;
2128
+    $path = \explode($this->pathSeparator, (string) $key);
2129 2129
 
2130 2130
     // Crawl through the keys
2131 2131
     while (\count($path, COUNT_NORMAL) > 1) {
2132 2132
       $key = \array_shift($path);
2133 2133
 
2134
-      $array =& $array[$key];
2134
+      $array = & $array[$key];
2135 2135
     }
2136 2136
 
2137 2137
     $array[\array_shift($path)] = $value;
@@ -2390,12 +2390,12 @@  discard block
 block discarded – undo
2390 2390
       if ($poppedValue === null) {
2391 2391
         $poppedValue = [$poppedValue];
2392 2392
       } else {
2393
-        $poppedValue = (array)$poppedValue;
2393
+        $poppedValue = (array) $poppedValue;
2394 2394
       }
2395 2395
 
2396 2396
       $arrayy = static::create($poppedValue);
2397 2397
     } else {
2398
-      $number = (int)$number;
2398
+      $number = (int) $number;
2399 2399
       $arrayy = $this->rest(-$number);
2400 2400
     }
2401 2401
 
@@ -2421,12 +2421,12 @@  discard block
 block discarded – undo
2421 2421
       if ($poppedValue === null) {
2422 2422
         $poppedValue = [$poppedValue];
2423 2423
       } else {
2424
-        $poppedValue = (array)$poppedValue;
2424
+        $poppedValue = (array) $poppedValue;
2425 2425
       }
2426 2426
 
2427 2427
       $this->array = static::create($poppedValue)->array;
2428 2428
     } else {
2429
-      $number = (int)$number;
2429
+      $number = (int) $number;
2430 2430
       $this->array = $this->rest(-$number)->array;
2431 2431
     }
2432 2432
 
@@ -2773,7 +2773,7 @@  discard block
 block discarded – undo
2773 2773
       } elseif (\is_array($item)) {
2774 2774
         $result[$key] = self::create($item)->prependToEachKey($suffix)->toArray();
2775 2775
       } else {
2776
-        $result[$key . $suffix] = $item;
2776
+        $result[$key.$suffix] = $item;
2777 2777
       }
2778 2778
 
2779 2779
     }
@@ -2799,7 +2799,7 @@  discard block
 block discarded – undo
2799 2799
       } elseif (\is_object($item)) {
2800 2800
         $result[$key] = $item;
2801 2801
       } else {
2802
-        $result[$key] = $item . $suffix;
2802
+        $result[$key] = $item.$suffix;
2803 2803
       }
2804 2804
     }
2805 2805
 
@@ -2889,7 +2889,7 @@  discard block
 block discarded – undo
2889 2889
       );
2890 2890
     }
2891 2891
 
2892
-    $result = (array)\array_rand($this->array, $number);
2892
+    $result = (array) \array_rand($this->array, $number);
2893 2893
 
2894 2894
     return static::create($result);
2895 2895
   }
@@ -2988,7 +2988,7 @@  discard block
 block discarded – undo
2988 2988
     if ($result === null) {
2989 2989
       $this->array = [];
2990 2990
     } else {
2991
-      $this->array = (array)$result;
2991
+      $this->array = (array) $result;
2992 2992
     }
2993 2993
 
2994 2994
     return static::create($this->array);
@@ -3114,7 +3114,7 @@  discard block
 block discarded – undo
3114 3114
       return new static();
3115 3115
     }
3116 3116
 
3117
-    return static::create(\array_fill(0, (int)$times, $this->array));
3117
+    return static::create(\array_fill(0, (int) $times, $this->array));
3118 3118
   }
3119 3119
 
3120 3120
   /**
@@ -3207,7 +3207,7 @@  discard block
 block discarded – undo
3207 3207
   public function replaceValues($search, $replacement = '')
3208 3208
   {
3209 3209
     $array = $this->each(
3210
-        function ($value) use ($search, $replacement) {
3210
+        function($value) use ($search, $replacement) {
3211 3211
           return UTF8::str_replace($search, $replacement, $value);
3212 3212
         }
3213 3213
     );
@@ -3288,8 +3288,8 @@  discard block
 block discarded – undo
3288 3288
     }
3289 3289
 
3290 3290
     // php cast "bool"-index into "int"-index
3291
-    if ((bool)$index === $index) {
3292
-      $index = (int)$index;
3291
+    if ((bool) $index === $index) {
3292
+      $index = (int) $index;
3293 3293
     }
3294 3294
 
3295 3295
     if (\array_key_exists($index, $this->array) === true) {
@@ -3531,7 +3531,7 @@  discard block
 block discarded – undo
3531 3531
    */
3532 3532
   public function sorter($sorter = null, $direction = SORT_ASC, int $strategy = SORT_REGULAR)
3533 3533
   {
3534
-    $array = (array)$this->array;
3534
+    $array = (array) $this->array;
3535 3535
     $direction = $this->getDirection($direction);
3536 3536
 
3537 3537
     // Transform all values into their results.
@@ -3540,7 +3540,7 @@  discard block
 block discarded – undo
3540 3540
 
3541 3541
       $that = $this;
3542 3542
       $results = $arrayy->each(
3543
-          function ($value) use ($sorter, $that) {
3543
+          function($value) use ($sorter, $that) {
3544 3544
             return \is_callable($sorter) ? $sorter($value) : $that->get($sorter, null, $value);
3545 3545
           }
3546 3546
       );
@@ -3638,7 +3638,7 @@  discard block
 block discarded – undo
3638 3638
     if ($arrayCount === 0) {
3639 3639
       $result = [];
3640 3640
     } else {
3641
-      $splitSize = (int)\ceil($arrayCount / $numberOfPieces);
3641
+      $splitSize = (int) \ceil($arrayCount / $numberOfPieces);
3642 3642
       $result = \array_chunk($this->array, $splitSize, $keepKeys);
3643 3643
     }
3644 3644
 
@@ -3653,12 +3653,12 @@  discard block
 block discarded – undo
3653 3653
   public function stripEmpty()
3654 3654
   {
3655 3655
     return $this->filter(
3656
-        function ($item) {
3656
+        function($item) {
3657 3657
           if ($item === null) {
3658 3658
             return false;
3659 3659
           }
3660 3660
 
3661
-          return (bool)\trim((string)$item);
3661
+          return (bool) \trim((string) $item);
3662 3662
         }
3663 3663
     );
3664 3664
   }
@@ -3726,7 +3726,7 @@  discard block
 block discarded – undo
3726 3726
 
3727 3727
     $this->array = \array_reduce(
3728 3728
         $this->array,
3729
-        function ($resultArray, $value) {
3729
+        function($resultArray, $value) {
3730 3730
           if (!\in_array($value, $resultArray, true)) {
3731 3731
             $resultArray[] = $value;
3732 3732
           }
@@ -3739,7 +3739,7 @@  discard block
 block discarded – undo
3739 3739
     if ($this->array === null) {
3740 3740
       $this->array = [];
3741 3741
     } else {
3742
-      $this->array = (array)$this->array;
3742
+      $this->array = (array) $this->array;
3743 3743
     }
3744 3744
 
3745 3745
     return $this;
@@ -3759,7 +3759,7 @@  discard block
 block discarded – undo
3759 3759
 
3760 3760
     $this->array = \array_reduce(
3761 3761
         \array_keys($array),
3762
-        function ($resultArray, $key) use ($array) {
3762
+        function($resultArray, $key) use ($array) {
3763 3763
           if (!\in_array($array[$key], $resultArray, true)) {
3764 3764
             $resultArray[$key] = $array[$key];
3765 3765
           }
@@ -3772,7 +3772,7 @@  discard block
 block discarded – undo
3772 3772
     if ($this->array === null) {
3773 3773
       $this->array = [];
3774 3774
     } else {
3775
-      $this->array = (array)$this->array;
3775
+      $this->array = (array) $this->array;
3776 3776
     }
3777 3777
 
3778 3778
     return $this;
@@ -3812,7 +3812,7 @@  discard block
 block discarded – undo
3812 3812
    */
3813 3813
   public function values()
3814 3814
   {
3815
-    return static::create(\array_values((array)$this->array));
3815
+    return static::create(\array_values((array) $this->array));
3816 3816
   }
3817 3817
 
3818 3818
   /**
Please login to merge, or discard this patch.
src/Property.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
   protected static function parseDocTypeObject(Type $type)
120 120
   {
121 121
     if ($type instanceof \phpDocumentor\Reflection\Types\Object_) {
122
-      return (string)$type->getFqsen();
122
+      return (string) $type->getFqsen();
123 123
     }
124 124
 
125 125
     if ($type instanceof \phpDocumentor\Reflection\Types\Array_) {
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
       return 'int';
172 172
     }
173 173
 
174
-    throw new \Exception('Unhandled PhpDoc type: ' . get_class($type));
174
+    throw new \Exception('Unhandled PhpDoc type: '.get_class($type));
175 175
   }
176 176
 
177 177
   public function getTypes(): array
Please login to merge, or discard this patch.