Passed
Branch master (f15e85)
by Muhammed
23:56 queued 15:20
created
src/Zicht/Itertools/itertools.php 2 patches
Doc Comments   +7 added lines, -23 removed lines patch added patch discarded remove patch
@@ -166,8 +166,6 @@  discard block
 block discarded – undo
166 166
  * > chain('ABC', 'DEF')
167 167
  * A B C D E F
168 168
  *
169
- * @param array|string|\Iterator $iterable
170
- * @param array|string|\Iterator $iterable2
171 169
  * @return ChainIterator
172 170
  */
173 171
 function chain(/* $iterable, $iterable2, ... */)
@@ -192,8 +190,8 @@  discard block
 block discarded – undo
192 190
  * > count(2.5, 0.5)
193 191
  * 2.5 3.0 3.5 4.0 ...
194 192
  *
195
- * @param int|float $start
196
- * @param int|float $step
193
+ * @param integer $start
194
+ * @param integer $step
197 195
  * @return CountIterator
198 196
  */
199 197
 function count($start = 0, $step = 1)
@@ -217,7 +215,7 @@  discard block
 block discarded – undo
217 215
  * > cycle('ABCD')
218 216
  * A B C D A B C D A B C D ...
219 217
  *
220
- * @param array|string|\Iterator $iterable
218
+ * @param lib\Traits\CycleTrait $iterable
221 219
  * @return CycleIterator
222 220
  */
223 221
 function cycle($iterable)
@@ -299,7 +297,6 @@  discard block
 block discarded – undo
299 297
  *
300 298
  * @param null|string|\Closure $strategy
301 299
  * @param array|string|\Iterator $iterable
302
- * @param array|string|\Iterator $iterable2
303 300
  * @return MapIterator
304 301
  */
305 302
 function map($strategy, $iterable /*, $iterable2, ... */)
@@ -455,8 +452,6 @@  discard block
 block discarded – undo
455 452
  * Make an iterator that returns values from $iterable where the
456 453
  * $strategy determines that the values are not empty
457 454
  *
458
- * @param null|string|\Closure $strategy, Optional, when not specified !empty will be used
459
- * @param array|string|\Iterator $iterable
460 455
  * @return FilterIterator
461 456
  */
462 457
 function filter(/* [$strategy, ] $iterable */)
@@ -490,9 +485,6 @@  discard block
 block discarded – undo
490 485
  * TODO: document!
491 486
  * TODO: unit tests!
492 487
  *
493
- * @param string|\Closure $strategy
494
- * @param \Closure $closure Optional, when not specified !empty will be used
495
- * @param array|string|\Iterator $iterable
496 488
  * @return FilterIterator
497 489
  *
498 490
  * @deprecated Use filter() instead, will be removed in version 3.0
@@ -538,8 +530,6 @@  discard block
 block discarded – undo
538 530
  * > zip([1, 2, 3], ['a', 'b', 'c'])
539 531
  * [1, 'a'] [2, 'b'] [3, 'c']
540 532
  *
541
- * @param array|string|\Iterator $iterable
542
- * @param array|string|\Iterator $iterable2
543 533
  * @return ZipIterator
544 534
  */
545 535
 function zip(/* $iterable, $iterable2, ... */)
@@ -557,7 +547,7 @@  discard block
 block discarded – undo
557 547
 /**
558 548
  * Returns an iterable with all the elements from $ITERABLE reversed
559 549
  *
560
- * @param array|string|\Iterator $iterable
550
+ * @param lib\Traits\ReversedTrait $iterable
561 551
  * @return ReversedIterator
562 552
  */
563 553
 function reversed($iterable)
@@ -578,8 +568,6 @@  discard block
 block discarded – undo
578 568
  * > unique('id', [['id' => 1, 'value' => 'a'], ['id' => 1, 'value' => 'b']])
579 569
  * ['id' => 1, 'value' => 'a']  # one element in this list
580 570
  *
581
- * @param null|string|\Closure $strategy
582
- * @param array|string|\Iterator $iterable
583 571
  * @return UniqueIterator
584 572
  */
585 573
 function unique(/* [$strategy,] $iterable */)
@@ -634,8 +622,6 @@  discard block
 block discarded – undo
634 622
  * > any([1, null, 3])
635 623
  * true
636 624
  *
637
- * @param null|string|\Closure $strategy
638
- * @param array|string|\Iterator $iterable
639 625
  * @return boolean
640 626
  */
641 627
 function any(/* [$strategy,] $iterable */)
@@ -678,8 +664,6 @@  discard block
 block discarded – undo
678 664
  * > all([1, null, 3])
679 665
  * false
680 666
  *
681
- * @param null|string|\Closure $strategy
682
- * @param array|string|\Iterator $iterable
683 667
  * @return boolean
684 668
  */
685 669
 function all(/* [$strategy,] $iterable */)
@@ -713,7 +697,7 @@  discard block
 block discarded – undo
713 697
 /**
714 698
  * TODO: document!
715 699
  *
716
- * @param array|string|\Iterator $iterable
700
+ * @param lib\Traits\SliceTrait $iterable
717 701
  * @param integer $start
718 702
  * @param null|integer $end
719 703
  * @return SliceIterator
@@ -734,7 +718,7 @@  discard block
 block discarded – undo
734 718
  *
735 719
  * TODO: unit tests!
736 720
  *
737
- * @param array|string|\Iterator $iterable
721
+ * @param lib\Traits\FirstTrait $iterable
738 722
  * @param mixed $default
739 723
  * @return mixed
740 724
  */
@@ -752,7 +736,7 @@  discard block
 block discarded – undo
752 736
  *
753 737
  * TODO: unit tests!
754 738
  *
755
- * @param array|string|\Iterator $iterable
739
+ * @param lib\Traits\LastTrait $iterable
756 740
  * @param mixed $default
757 741
  * @return mixed
758 742
  */
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 function chain(/* $iterable, $iterable2, ... */)
174 174
 {
175 175
     $iterables = array_map(
176
-        function ($iterable) {
176
+        function($iterable) {
177 177
             return conversions\mixedToIterator($iterable);
178 178
         },
179 179
         func_get_args()
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 function map($strategy, $iterable /*, $iterable2, ... */)
306 306
 {
307 307
     $iterables = array_map(
308
-        function ($iterable) {
308
+        function($iterable) {
309 309
             return conversions\mixedToIterator($iterable);
310 310
         },
311 311
         array_slice(func_get_args(), 1)
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
     }
479 479
 
480 480
     $strategy = conversions\mixedToValueGetter($strategy);
481
-    $isValid = function ($value, $key) use ($strategy) {
481
+    $isValid = function($value, $key) use ($strategy) {
482 482
         $tempVarPhp54 = $strategy($value, $key);
483 483
         return !empty($tempVarPhp54);
484 484
     };
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
     switch (sizeof($args)) {
504 504
         case 2:
505 505
             $strategy = conversions\mixedToValueGetter($args[0]);
506
-            $closure = function ($value, $key) use ($strategy) {
506
+            $closure = function($value, $key) use ($strategy) {
507 507
                 $tempVarPhp54 = call_user_func($strategy, $value, $key);
508 508
                 return !empty($tempVarPhp54);
509 509
             };
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
         case 3:
514 514
             $strategy = conversions\mixedToValueGetter($args[0]);
515 515
             $userClosure = $args[1];
516
-            $closure = function ($value, $key) use ($strategy, $userClosure) {
516
+            $closure = function($value, $key) use ($strategy, $userClosure) {
517 517
                 return call_user_func($userClosure, call_user_func($strategy, $value, $key));
518 518
             };
519 519
             $iterable = conversions\mixedToIterator($args[2]);
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 function zip(/* $iterable, $iterable2, ... */)
546 546
 {
547 547
     $iterables = array_map(
548
-        function ($iterable) {
548
+        function($iterable) {
549 549
             return conversions\mixedToIterator($iterable);
550 550
         },
551 551
         func_get_args()
Please login to merge, or discard this patch.
src/Zicht/Itertools/lib/SliceIterator.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -60,6 +60,10 @@
 block discarded – undo
60 60
     private $start;
61 61
     private $end;
62 62
 
63
+    /**
64
+     * @param integer $start
65
+     * @param integer $end
66
+     */
63 67
     public function __construct(\Iterator $iterable, $start, $end = null)
64 68
     {
65 69
         if ($start < 0 || $end < 0) {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
         }
68 68
 
69 69
         $this->index = 0;
70
-        $this->start = $start < 0 ? $length + $start: $start;
70
+        $this->start = $start < 0 ? $length + $start : $start;
71 71
         $this->end = $end === null ? null : ($end < 0 ? $length + $end : $end);
72 72
         parent::__construct($iterable);
73 73
     }
Please login to merge, or discard this patch.
src/Zicht/Itertools/lib/Traits/ChainTrait.php 1 patch
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -26,8 +26,6 @@
 block discarded – undo
26 26
      * > iter\iterable('ABC', 'DEF')->chain()
27 27
      * A B C D E F
28 28
      *
29
-     * @param array|string|\Iterator $iterable
30
-     * @param array|string|\Iterator $iterable2
31 29
      * @return iter\lib\ChainIterator
32 30
      */
33 31
     public function chain(/* $iterable, $iterable2, ... */)
Please login to merge, or discard this patch.
src/Zicht/Itertools/lib/Traits/ReduceTrait.php 1 patch
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,6 @@
 block discarded – undo
25 25
      * > iter\iterable([])->reduce('min', 1)
26 26
      * 1
27 27
      *
28
-     * @param array|string|\Iterator $iterable
29 28
      * @param string|\Closure $closure
30 29
      * @param mixed $initializer
31 30
      * @return mixed
Please login to merge, or discard this patch.
src/Zicht/Itertools/lib/Traits/ZipTrait.php 1 patch
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,6 @@
 block discarded – undo
22 22
      * > zip([1, 2, 3], ['a', 'b', 'c'])
23 23
      * [1, 'a'] [2, 'b'] [3, 'c']
24 24
      *
25
-     * @param array|string|\Iterator $iterable2
26 25
      * @return iter\lib\ZipIterator
27 26
      */
28 27
     public function zip(/* $iterable2, ... */)
Please login to merge, or discard this patch.
src/Zicht/Itertools/reductions.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -176,6 +176,7 @@
 block discarded – undo
176 176
 
177 177
 /**
178 178
  * @deprecated please use the reduction functions directly, will be removed in version 3.0
179
+ * @param string $name
179 180
  */
180 181
 function getReduction($name /* [argument, [arguments, ...] */)
181 182
 {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  */
16 16
 function add()
17 17
 {
18
-    return function ($a, $b) {
18
+    return function($a, $b) {
19 19
         if (!is_numeric($a)) {
20 20
             throw new \InvalidArgumentException('Argument $A must be numeric to perform addition');
21 21
         }
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
  */
34 34
 function sub()
35 35
 {
36
-    return function ($a, $b) {
36
+    return function($a, $b) {
37 37
         if (!is_numeric($a)) {
38 38
             throw new \InvalidArgumentException('Argument $A must be numeric to perform subtraction');
39 39
         }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
  */
52 52
 function mul()
53 53
 {
54
-    return function ($a, $b) {
54
+    return function($a, $b) {
55 55
         if (!is_numeric($a)) {
56 56
             throw new \InvalidArgumentException('Argument $A must be numeric to perform multiplication');
57 57
         }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
  */
70 70
 function min()
71 71
 {
72
-    return function ($a, $b) {
72
+    return function($a, $b) {
73 73
         if (!is_numeric($a)) {
74 74
             throw new \InvalidArgumentException('Argument $A must be numeric to determine minimum');
75 75
         }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
  */
88 88
 function max()
89 89
 {
90
-    return function ($a, $b) {
90
+    return function($a, $b) {
91 91
         if (!is_numeric($a)) {
92 92
             throw new \InvalidArgumentException('Argument $A must be numeric to determine maximum');
93 93
         }
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     if (!is_string($glue)) {
110 110
         throw new \InvalidArgumentException('Argument $GLUE must be a string to join');
111 111
     }
112
-    return function ($a, $b) use ($glue) {
112
+    return function($a, $b) use ($glue) {
113 113
         if (!is_string($a)) {
114 114
             throw new \InvalidArgumentException('Argument $A must be a string to join');
115 115
         }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
  */
132 132
 function chain()
133 133
 {
134
-    return function ($chainIterator, $b) {
134
+    return function($chainIterator, $b) {
135 135
         if (!($chainIterator instanceof ChainIterator)) {
136 136
             throw new \InvalidArgumentException('Argument $A must be a ChainIterator.  Did your call "reduce" with "new ChainIterator()" as the initial parameter?');
137 137
         }
Please login to merge, or discard this patch.
src/Zicht/Itertools/lib/SortedIterator.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
     public function __construct(\Closure $func, \Iterator $iterable, $reverse = false)
58 58
     {
59 59
         if ($reverse) {
60
-            $cmp = function ($a, $b) use ($func) {
60
+            $cmp = function($a, $b) use ($func) {
61 61
                 $orderA = $a['order'];
62 62
                 $orderB = $b['order'];
63 63
                 return $orderA == $orderB ? 0 : ($orderA < $orderB ? 1 : -1);
64 64
             };
65 65
         } else {
66
-            $cmp = function ($a, $b) use ($func) {
66
+            $cmp = function($a, $b) use ($func) {
67 67
                 $orderA = $a['order'];
68 68
                 $orderB = $b['order'];
69 69
                 return $orderA == $orderB ? 0 : ($orderA < $orderB ? -1 : 1);
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
         $data = [];
74 74
         foreach ($iterable as $key => $value) {
75
-            $data []= array('key' => $key, 'value' => $value, 'order' => call_user_func($func, $value, $key));
75
+            $data [] = array('key' => $key, 'value' => $value, 'order' => call_user_func($func, $value, $key));
76 76
         }
77 77
 
78 78
         $this->mergesort($data, $cmp);
Please login to merge, or discard this patch.
Braces   +10 added lines, -6 removed lines patch added patch discarded remove patch
@@ -114,8 +114,9 @@  discard block
 block discarded – undo
114 114
     protected function mergesort(array &$array, \Closure $cmp_function)
115 115
     {
116 116
         // Arrays of size < 2 require no action.
117
-        if (count($array) < 2)
118
-            return;
117
+        if (count($array) < 2) {
118
+                    return;
119
+        }
119 120
 
120 121
         // Split the array in half
121 122
         $halfway = count($array) / 2;
@@ -138,15 +139,18 @@  discard block
 block discarded – undo
138 139
         while ($ptr1 < count($array1) && $ptr2 < count($array2)) {
139 140
             if (call_user_func($cmp_function, $array1[$ptr1], $array2[$ptr2]) < 1) {
140 141
                 $array[] = $array1[$ptr1++];
141
-            }
142
-            else {
142
+            } else {
143 143
                 $array[] = $array2[$ptr2++];
144 144
             }
145 145
         }
146 146
 
147 147
         // Merge the remainder
148
-        while ($ptr1 < count($array1)) $array[] = $array1[$ptr1++];
149
-        while ($ptr2 < count($array2)) $array[] = $array2[$ptr2++];
148
+        while ($ptr1 < count($array1)) {
149
+            $array[] = $array1[$ptr1++];
150
+        }
151
+        while ($ptr2 < count($array2)) {
152
+            $array[] = $array2[$ptr2++];
153
+        }
150 154
         return;
151 155
     }
152 156
 }
Please login to merge, or discard this patch.
src/Zicht/Itertools/lib/MapIterator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 
62 62
     public function __construct(\Closure $valueFunc /* [\Closure $keyFunc], \Iterator $iterable1, [\Iterator $iterable2, [...]] */)
63 63
     {
64
-        parent::__construct(\MultipleIterator::MIT_NEED_ALL| \MultipleIterator::MIT_KEYS_NUMERIC);
64
+        parent::__construct(\MultipleIterator::MIT_NEED_ALL|\MultipleIterator::MIT_KEYS_NUMERIC);
65 65
         $args = func_get_args();
66 66
         $argsContainsKeyFunc = $args[1] instanceof \Closure;
67 67
         $this->valueFunc = $args[0];
68
-        $this->keyFunc = $argsContainsKeyFunc ? $args[1] : function () { return $this->genericKeysToKey(func_get_args()); };
68
+        $this->keyFunc = $argsContainsKeyFunc ? $args[1] : function() { return $this->genericKeysToKey(func_get_args()); };
69 69
         foreach (array_slice($args, $argsContainsKeyFunc ? 2 : 1) as $iterable) {
70 70
             if (!$iterable instanceof \Iterator) {
71 71
                 throw new \InvalidArgumentException(sprintf('Argument %d must be an iterator'));
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         foreach ($keys as $key) {
87 87
             if ($key !== $value) {
88 88
                 // the keys are different, we will make a new string identifying this entry
89
-                return join(':', array_map(function ($key) { return (string)$key; }, $keys));
89
+                return join(':', array_map(function($key) { return (string)$key; }, $keys));
90 90
             }
91 91
         }
92 92
 
Please login to merge, or discard this patch.
src/Zicht/Itertools/lib/GroupbyIterator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -160,7 +160,7 @@
 block discarded – undo
160 160
         $array = iterator_to_array($this);
161 161
         array_walk(
162 162
             $array,
163
-            function (&$value) {
163
+            function(&$value) {
164 164
                 /** @var GroupedIterator $value */
165 165
                 $value = $value->toArray();
166 166
             }
Please login to merge, or discard this patch.