Completed
Push — master ( 371ca1...4d8967 )
by Lars
02:01
created
src/Arrayy.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
   }
345 345
 
346 346
   /**
347
-   * @param mixed      $path
347
+   * @param string      $path
348 348
    * @param callable   $callable
349 349
    * @param null|array $currentOffset
350 350
    */
@@ -2610,7 +2610,7 @@  discard block
 block discarded – undo
2610 2610
 
2611 2611
   /**
2612 2612
    * @param array      &$elements
2613
-   * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p>
2613
+   * @param integer $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p>
2614 2614
    * @param int        $strategy  <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or
2615 2615
    *                              <strong>SORT_NATURAL</strong></p>
2616 2616
    * @param bool       $keepKeys
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
       return false;
71 71
     }
72 72
 
73
-    return (array)$this->array;
73
+    return (array) $this->array;
74 74
   }
75 75
 
76 76
   /**
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
     }
183 183
 
184 184
     // php cast "bool"-index into "int"-index
185
-    if ((bool)$offset === $offset) {
186
-      $offset = (int)$offset;
185
+    if ((bool) $offset === $offset) {
186
+      $offset = (int) $offset;
187 187
     }
188 188
 
189 189
     $tmpReturn = array_key_exists($offset, $this->array);
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
         (
195 195
             $tmpReturn === false
196 196
             &&
197
-            strpos((string)$offset, $this->pathSeparator) === false
197
+            strpos((string) $offset, $this->pathSeparator) === false
198 198
         )
199 199
     ) {
200 200
       return $tmpReturn;
@@ -202,16 +202,16 @@  discard block
 block discarded – undo
202 202
 
203 203
     $offsetExists = false;
204 204
 
205
-    if (strpos((string)$offset, $this->pathSeparator) !== false) {
205
+    if (strpos((string) $offset, $this->pathSeparator) !== false) {
206 206
 
207 207
       $offsetExists = false;
208
-      $explodedPath = explode($this->pathSeparator, (string)$offset);
208
+      $explodedPath = explode($this->pathSeparator, (string) $offset);
209 209
       $lastOffset = array_pop($explodedPath);
210 210
       $containerPath = implode($this->pathSeparator, $explodedPath);
211 211
 
212 212
       $this->callAtPath(
213 213
           $containerPath,
214
-          function ($container) use ($lastOffset, &$offsetExists) {
214
+          function($container) use ($lastOffset, &$offsetExists) {
215 215
             $offsetExists = array_key_exists($lastOffset, $container);
216 216
           }
217 217
       );
@@ -264,14 +264,14 @@  discard block
 block discarded – undo
264 264
       return;
265 265
     }
266 266
 
267
-    if (strpos((string)$offset, $this->pathSeparator) !== false) {
267
+    if (strpos((string) $offset, $this->pathSeparator) !== false) {
268 268
 
269
-      $path = explode($this->pathSeparator, (string)$offset);
269
+      $path = explode($this->pathSeparator, (string) $offset);
270 270
       $pathToUnset = array_pop($path);
271 271
 
272 272
       $this->callAtPath(
273 273
           implode($this->pathSeparator, $path),
274
-          function (&$offset) use (&$pathToUnset) {
274
+          function(&$offset) use (&$pathToUnset) {
275 275
             unset($offset[$pathToUnset]);
276 276
           }
277 277
       );
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
   public function clean()
412 412
   {
413 413
     return $this->filter(
414
-        function ($value) {
415
-          return (bool)$value;
414
+        function($value) {
415
+          return (bool) $value;
416 416
         }
417 417
     );
418 418
   }
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
     // trim all string in the array
600 600
     array_walk(
601 601
         $array,
602
-        function (&$val) {
602
+        function(&$val) {
603 603
           /** @noinspection ReferenceMismatchInspection */
604 604
           if (is_string($val)) {
605 605
             $val = trim($val);
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
     }
817 817
 
818 818
     if (is_object($array) && method_exists($array, '__toArray')) {
819
-      return (array)$array->__toArray();
819
+      return (array) $array->__toArray();
820 820
     }
821 821
 
822 822
     /** @noinspection ReferenceMismatchInspection */
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
         ||
826 826
         (is_object($array) && method_exists($array, '__toString'))
827 827
     ) {
828
-      return array((string)$array);
828
+      return array((string) $array);
829 829
     }
830 830
 
831 831
     throw new \InvalidArgumentException(
@@ -880,54 +880,54 @@  discard block
 block discarded – undo
880 880
     }
881 881
 
882 882
     $ops = array(
883
-        'eq'          => function ($item, $prop, $value) {
883
+        'eq'          => function($item, $prop, $value) {
884 884
           return $item[$prop] === $value;
885 885
         },
886
-        'gt'          => function ($item, $prop, $value) {
886
+        'gt'          => function($item, $prop, $value) {
887 887
           return $item[$prop] > $value;
888 888
         },
889
-        'ge'          => function ($item, $prop, $value) {
889
+        'ge'          => function($item, $prop, $value) {
890 890
           return $item[$prop] >= $value;
891 891
         },
892
-        'gte'         => function ($item, $prop, $value) {
892
+        'gte'         => function($item, $prop, $value) {
893 893
           return $item[$prop] >= $value;
894 894
         },
895
-        'lt'          => function ($item, $prop, $value) {
895
+        'lt'          => function($item, $prop, $value) {
896 896
           return $item[$prop] < $value;
897 897
         },
898
-        'le'          => function ($item, $prop, $value) {
898
+        'le'          => function($item, $prop, $value) {
899 899
           return $item[$prop] <= $value;
900 900
         },
901
-        'lte'         => function ($item, $prop, $value) {
901
+        'lte'         => function($item, $prop, $value) {
902 902
           return $item[$prop] <= $value;
903 903
         },
904
-        'ne'          => function ($item, $prop, $value) {
904
+        'ne'          => function($item, $prop, $value) {
905 905
           return $item[$prop] !== $value;
906 906
         },
907
-        'contains'    => function ($item, $prop, $value) {
908
-          return in_array($item[$prop], (array)$value, true);
907
+        'contains'    => function($item, $prop, $value) {
908
+          return in_array($item[$prop], (array) $value, true);
909 909
         },
910
-        'notContains' => function ($item, $prop, $value) {
911
-          return !in_array($item[$prop], (array)$value, true);
910
+        'notContains' => function($item, $prop, $value) {
911
+          return !in_array($item[$prop], (array) $value, true);
912 912
         },
913
-        'newer'       => function ($item, $prop, $value) {
913
+        'newer'       => function($item, $prop, $value) {
914 914
           return strtotime($item[$prop]) > strtotime($value);
915 915
         },
916
-        'older'       => function ($item, $prop, $value) {
916
+        'older'       => function($item, $prop, $value) {
917 917
           return strtotime($item[$prop]) < strtotime($value);
918 918
         },
919 919
     );
920 920
 
921 921
     $result = array_values(
922 922
         array_filter(
923
-            (array)$this->array,
924
-            function ($item) use (
923
+            (array) $this->array,
924
+            function($item) use (
925 925
                 $property,
926 926
                 $value,
927 927
                 $ops,
928 928
                 $comparisonOp
929 929
             ) {
930
-              $item = (array)$item;
930
+              $item = (array) $item;
931 931
               $itemArrayy = new Arrayy($item);
932 932
               $item[$property] = $itemArrayy->get($property, array());
933 933
 
@@ -1000,9 +1000,9 @@  discard block
 block discarded – undo
1000 1000
   {
1001 1001
     if ($number === null) {
1002 1002
       $arrayTmp = $this->array;
1003
-      $array = (array)array_shift($arrayTmp);
1003
+      $array = (array) array_shift($arrayTmp);
1004 1004
     } else {
1005
-      $number = (int)$number;
1005
+      $number = (int) $number;
1006 1006
       $arrayTmp = $this->array;
1007 1007
       $array = array_splice($arrayTmp, 0, $number, true);
1008 1008
     }
@@ -1020,9 +1020,9 @@  discard block
 block discarded – undo
1020 1020
   public function firstsMutable($number = null)
1021 1021
   {
1022 1022
     if ($number === null) {
1023
-      $this->array = (array)array_shift($this->array);
1023
+      $this->array = (array) array_shift($this->array);
1024 1024
     } else {
1025
-      $number = (int)$number;
1025
+      $number = (int) $number;
1026 1026
       $this->array = array_splice($this->array, 0, $number, true);
1027 1027
     }
1028 1028
 
@@ -1068,8 +1068,8 @@  discard block
 block discarded – undo
1068 1068
     }
1069 1069
 
1070 1070
     // php cast "bool"-index into "int"-index
1071
-    if ((bool)$key === $key) {
1072
-      $key = (int)$key;
1071
+    if ((bool) $key === $key) {
1072
+      $key = (int) $key;
1073 1073
     }
1074 1074
 
1075 1075
     if (array_key_exists($key, $usedArray) === true) {
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
     }
1082 1082
 
1083 1083
     // Crawl through array, get key according to object or not
1084
-    foreach (explode($this->pathSeparator, (string)$key) as $segment) {
1084
+    foreach (explode($this->pathSeparator, (string) $key) as $segment) {
1085 1085
       if (!isset($usedArray[$segment])) {
1086 1086
         return $fallback instanceof \Closure ? $fallback() : $fallback;
1087 1087
       }
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
    */
1254 1254
   public function group($grouper, $saveKeys = false)
1255 1255
   {
1256
-    $array = (array)$this->array;
1256
+    $array = (array) $this->array;
1257 1257
     $result = array();
1258 1258
 
1259 1259
     // Iterate over values, group by property/results from closure
@@ -1296,7 +1296,7 @@  discard block
 block discarded – undo
1296 1296
   public function has($key)
1297 1297
   {
1298 1298
     // Generate unique string to use as marker.
1299
-    $unFound = (string)uniqid('arrayy', true);
1299
+    $unFound = (string) uniqid('arrayy', true);
1300 1300
 
1301 1301
     return $this->get($key, $unFound) !== $unFound;
1302 1302
   }
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
    */
1375 1375
   protected function internalRemove($key)
1376 1376
   {
1377
-    $path = explode($this->pathSeparator, (string)$key);
1377
+    $path = explode($this->pathSeparator, (string) $key);
1378 1378
 
1379 1379
     // Crawl though the keys
1380 1380
     while (count($path) > 1) {
@@ -1409,8 +1409,8 @@  discard block
 block discarded – undo
1409 1409
     }
1410 1410
 
1411 1411
     // init
1412
-    $array =& $this->array;
1413
-    $path = explode($this->pathSeparator, (string)$key);
1412
+    $array = & $this->array;
1413
+    $path = explode($this->pathSeparator, (string) $key);
1414 1414
 
1415 1415
     // Crawl through the keys
1416 1416
     while (count($path) > 1) {
@@ -1423,7 +1423,7 @@  discard block
 block discarded – undo
1423 1423
         $array[$key] = self::create(array());
1424 1424
       }
1425 1425
 
1426
-      $array =& $array[$key];
1426
+      $array = & $array[$key];
1427 1427
     }
1428 1428
 
1429 1429
     $array[array_shift($path)] = $value;
@@ -1601,12 +1601,12 @@  discard block
 block discarded – undo
1601 1601
       if ($poppedValue === null) {
1602 1602
         $poppedValue = array($poppedValue);
1603 1603
       } else {
1604
-        $poppedValue = (array)$poppedValue;
1604
+        $poppedValue = (array) $poppedValue;
1605 1605
       }
1606 1606
 
1607 1607
       $arrayy = static::create($poppedValue);
1608 1608
     } else {
1609
-      $number = (int)$number;
1609
+      $number = (int) $number;
1610 1610
       $arrayy = $this->rest(-$number);
1611 1611
     }
1612 1612
 
@@ -1632,12 +1632,12 @@  discard block
 block discarded – undo
1632 1632
       if ($poppedValue === null) {
1633 1633
         $poppedValue = array($poppedValue);
1634 1634
       } else {
1635
-        $poppedValue = (array)$poppedValue;
1635
+        $poppedValue = (array) $poppedValue;
1636 1636
       }
1637 1637
 
1638 1638
       $this->array = static::create($poppedValue)->array;
1639 1639
     } else {
1640
-      $number = (int)$number;
1640
+      $number = (int) $number;
1641 1641
       $this->array = $this->rest(-$number)->array;
1642 1642
     }
1643 1643
 
@@ -1969,7 +1969,7 @@  discard block
 block discarded – undo
1969 1969
    */
1970 1970
   public function randomKeys($number)
1971 1971
   {
1972
-    $number = (int)$number;
1972
+    $number = (int) $number;
1973 1973
     $count = $this->count();
1974 1974
 
1975 1975
     if ($number === 0 || $number > $count) {
@@ -1982,7 +1982,7 @@  discard block
 block discarded – undo
1982 1982
       );
1983 1983
     }
1984 1984
 
1985
-    $result = (array)array_rand($this->array, $number);
1985
+    $result = (array) array_rand($this->array, $number);
1986 1986
 
1987 1987
     return static::create($result);
1988 1988
   }
@@ -2037,7 +2037,7 @@  discard block
 block discarded – undo
2037 2037
    */
2038 2038
   public function randomValues($number)
2039 2039
   {
2040
-    $number = (int)$number;
2040
+    $number = (int) $number;
2041 2041
 
2042 2042
     return $this->randomMutable($number);
2043 2043
   }
@@ -2081,7 +2081,7 @@  discard block
 block discarded – undo
2081 2081
     if ($result === null) {
2082 2082
       $this->array = array();
2083 2083
     } else {
2084
-      $this->array = (array)$result;
2084
+      $this->array = (array) $result;
2085 2085
     }
2086 2086
 
2087 2087
     return static::create($this->array);
@@ -2284,7 +2284,7 @@  discard block
 block discarded – undo
2284 2284
   public function replaceValues($search, $replacement = '')
2285 2285
   {
2286 2286
     $array = $this->each(
2287
-        function ($value) use ($search, $replacement) {
2287
+        function($value) use ($search, $replacement) {
2288 2288
           return UTF8::str_replace($search, $replacement, $value);
2289 2289
         }
2290 2290
     );
@@ -2385,8 +2385,8 @@  discard block
 block discarded – undo
2385 2385
     }
2386 2386
 
2387 2387
     // php cast "bool"-index into "int"-index
2388
-    if ((bool)$index === $index) {
2389
-      $index = (int)$index;
2388
+    if ((bool) $index === $index) {
2389
+      $index = (int) $index;
2390 2390
     }
2391 2391
 
2392 2392
     if (array_key_exists($index, $this->array) === true) {
@@ -2558,7 +2558,7 @@  discard block
 block discarded – undo
2558 2558
    */
2559 2559
   public function sorter($sorter = null, $direction = SORT_ASC, $strategy = SORT_REGULAR)
2560 2560
   {
2561
-    $array = (array)$this->array;
2561
+    $array = (array) $this->array;
2562 2562
     $direction = $this->getDirection($direction);
2563 2563
 
2564 2564
     // Transform all values into their results.
@@ -2567,7 +2567,7 @@  discard block
 block discarded – undo
2567 2567
 
2568 2568
       $that = $this;
2569 2569
       $results = $arrayy->each(
2570
-          function ($value) use ($sorter, $that) {
2570
+          function($value) use ($sorter, $that) {
2571 2571
             return is_callable($sorter) ? $sorter($value) : $that->get($sorter, null, $value);
2572 2572
           }
2573 2573
       );
@@ -2660,8 +2660,8 @@  discard block
 block discarded – undo
2660 2660
     if ($arrayCount === 0) {
2661 2661
       $result = array();
2662 2662
     } else {
2663
-      $numberOfPieces = (int)$numberOfPieces;
2664
-      $splitSize = (int)ceil($arrayCount / $numberOfPieces);
2663
+      $numberOfPieces = (int) $numberOfPieces;
2664
+      $splitSize = (int) ceil($arrayCount / $numberOfPieces);
2665 2665
       $result = array_chunk($this->array, $splitSize, $keepKeys);
2666 2666
     }
2667 2667
 
@@ -2676,12 +2676,12 @@  discard block
 block discarded – undo
2676 2676
   public function stripEmpty()
2677 2677
   {
2678 2678
     return $this->filter(
2679
-        function ($item) {
2679
+        function($item) {
2680 2680
           if ($item === null) {
2681 2681
             return false;
2682 2682
           }
2683 2683
 
2684
-          return (bool)trim((string)$item);
2684
+          return (bool) trim((string) $item);
2685 2685
         }
2686 2686
     );
2687 2687
   }
@@ -2758,7 +2758,7 @@  discard block
 block discarded – undo
2758 2758
   {
2759 2759
     $this->array = array_reduce(
2760 2760
         $this->array,
2761
-        function ($resultArray, $value) {
2761
+        function($resultArray, $value) {
2762 2762
           if (!in_array($value, $resultArray, true)) {
2763 2763
             $resultArray[] = $value;
2764 2764
           }
@@ -2771,7 +2771,7 @@  discard block
 block discarded – undo
2771 2771
     if ($this->array === null) {
2772 2772
       $this->array = array();
2773 2773
     } else {
2774
-      $this->array = (array)$this->array;
2774
+      $this->array = (array) $this->array;
2775 2775
     }
2776 2776
 
2777 2777
     return $this;
@@ -2813,7 +2813,7 @@  discard block
 block discarded – undo
2813 2813
    */
2814 2814
   public function values()
2815 2815
   {
2816
-    return static::create(array_values((array)$this->array));
2816
+    return static::create(array_values((array) $this->array));
2817 2817
   }
2818 2818
 
2819 2819
   /**
Please login to merge, or discard this patch.