Completed
Branch master (f41212)
by Rudi
01:59
created
src/Ds/PriorityQueue.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -160,7 +160,7 @@
 block discarded – undo
160 160
      * @param int $a
161 161
      * @param int $b
162 162
      *
163
-     * @return bool
163
+     * @return integer
164 164
      */
165 165
     private function compare(int $a, int $b)
166 166
     {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -282,7 +282,7 @@
 block discarded – undo
282 282
      */
283 283
     private function siftUp(int $leaf)
284 284
     {
285
-         for (; $leaf > 0; $leaf = $parent) {
285
+            for (; $leaf > 0; $leaf = $parent) {
286 286
 
287 287
             $parent = $this->parent($leaf);
288 288
 
Please login to merge, or discard this patch.
src/Ds/Traits/Sequence.php 3 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -236,14 +236,14 @@  discard block
 block discarded – undo
236 236
             return;
237 237
         }
238 238
 
239
-        $swap = function (&$a, &$b) {
239
+        $swap = function(&$a, &$b) {
240 240
             $t = $a;
241 241
             $a = $b;
242 242
             $b = $t;
243 243
         };
244 244
 
245 245
         // Reverses a range within the internal array
246
-        $reverse = function (int $a, int $b) use ($swap) {
246
+        $reverse = function(int $a, int $b) use ($swap) {
247 247
             while (--$b > $a) {
248 248
                 $swap($this->internal[$a++], $this->internal[$b--]);
249 249
             }
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
         }
261 261
 
262 262
         if ($r > 0) {
263
-            $reverse(0,  $r);
263
+            $reverse(0, $r);
264 264
             $reverse($r, $n);
265
-            $reverse(0,  $n);
265
+            $reverse(0, $n);
266 266
         }
267 267
     }
268 268
 
Please login to merge, or discard this patch.
Unused Use Statements   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Ds\Traits;
3 3
 
4
+use Error;
4 5
 use OutOfRangeException;
5
-use UnderflowException;
6 6
 use Traversable;
7
-use Error;
7
+use UnderflowException;
8 8
 
9 9
 /**
10 10
  * Sequence
Please login to merge, or discard this patch.
Upper-Lower-Casing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     /**
22 22
      * @inheritDoc
23 23
      */
24
-    public function __construct($values = null)
24
+    public function __construct($values = NULL)
25 25
     {
26 26
         if ($values) {
27 27
             if (is_integer($values)) {
@@ -65,22 +65,22 @@  discard block
 block discarded – undo
65 65
     public function contains(...$values): bool
66 66
     {
67 67
         if ( ! $values) {
68
-            return false;
68
+            return FALSE;
69 69
         }
70 70
 
71 71
         foreach ($values as $value) {
72
-            if ($this->find($value) === false) {
73
-                return false;
72
+            if ($this->find($value) === FALSE) {
73
+                return FALSE;
74 74
             }
75 75
         }
76 76
 
77
-        return true;
77
+        return TRUE;
78 78
     }
79 79
 
80 80
     /**
81 81
      * @inheritDoc
82 82
      */
83
-    public function filter(callable $callback = null): \Ds\Sequence
83
+    public function filter(callable $callback = NULL): \Ds\Sequence
84 84
     {
85 85
         if ($callback) {
86 86
             return new self(array_filter($this->internal, $callback));
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public function find($value)
96 96
     {
97
-        return array_search($value, $this->internal, true);
97
+        return array_search($value, $this->internal, TRUE);
98 98
     }
99 99
 
100 100
     /**
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     /**
135 135
      * @inheritDoc
136 136
      */
137
-    public function join(string $glue = null): string
137
+    public function join(string $glue = NULL): string
138 138
     {
139 139
         return implode($glue, $this->internal);
140 140
     }
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     /**
201 201
      * @inheritDoc
202 202
      */
203
-    public function reduce(callable $callback, $initial = null)
203
+    public function reduce(callable $callback, $initial = NULL)
204 204
     {
205 205
         return array_reduce($this->internal, $callback, $initial);
206 206
     }
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
     {
213 213
         $this->checkRange($index);
214 214
 
215
-        $value = array_splice($this->internal, $index, 1, null)[0];
215
+        $value = array_splice($this->internal, $index, 1, NULL)[0];
216 216
         $this->adjustCapacity();
217 217
 
218 218
         return $value;
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
     /**
294 294
      * @inheritDoc
295 295
      */
296
-    public function slice(int $offset, int $length = null): \Ds\Sequence
296
+    public function slice(int $offset, int $length = NULL): \Ds\Sequence
297 297
     {
298 298
         if (func_num_args() === 1) {
299 299
             return new self(array_slice($this->internal, $offset));
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
     /**
306 306
      * @inheritDoc
307 307
      */
308
-    public function sort(callable $comparator = null): \Ds\Sequence
308
+    public function sort(callable $comparator = NULL): \Ds\Sequence
309 309
     {
310 310
         $internal = $this->internal;
311 311
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
      */
366 366
     public function offsetSet($offset, $value)
367 367
     {
368
-        if ($offset === null) {
368
+        if ($offset === NULL) {
369 369
             $this->push($value);
370 370
         } else {
371 371
             $this->set($offset, $value);
@@ -398,9 +398,9 @@  discard block
 block discarded – undo
398 398
     public function offsetExists($offset)
399 399
     {
400 400
         if ($offset < 0 || $offset >= count($this)) {
401
-            return false;
401
+            return FALSE;
402 402
         }
403 403
 
404
-        return $this->get($offset) !== null;
404
+        return $this->get($offset) !== NULL;
405 405
     }
406 406
 }
Please login to merge, or discard this patch.
src/Ds/Map.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function clear()
45 45
     {
46
-        $this->pairs  = [];
46
+        $this->pairs = [];
47 47
         $this->capacity = self::MIN_CAPACITY;
48 48
     }
49 49
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
      */
210 210
     private function identical($a, $b): bool
211 211
     {
212
-        if (is_object($a) && $a instanceof Hashable){
212
+        if (is_object($a) && $a instanceof Hashable) {
213 213
             return $a->equals($b);
214 214
         }
215 215
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@
 block discarded – undo
209 209
      */
210 210
     private function identical($a, $b): bool
211 211
     {
212
-        if (is_object($a) && $a instanceof Hashable){
212
+        if (is_object($a) && $a instanceof Hashable) {
213 213
             return $a->equals($b);
214 214
         }
215 215
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      *
28 28
      * @param array|\Traversable $values
29 29
      */
30
-    public function __construct($values = null)
30
+    public function __construct($values = NULL)
31 31
     {
32 32
         if ($values) {
33 33
             if (is_integer($values)) {
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
             }
232 232
         }
233 233
 
234
-        $pair = null;
234
+        $pair = NULL;
235 235
 
236 236
         return $pair;
237 237
     }
@@ -247,16 +247,16 @@  discard block
 block discarded – undo
247 247
     public function containsKey(...$keys): bool
248 248
     {
249 249
         if ( ! $keys) {
250
-            return false;
250
+            return FALSE;
251 251
         }
252 252
 
253 253
         foreach ($keys as $key) {
254 254
             if ( ! $this->lookup($key)) {
255
-                return false;
255
+                return FALSE;
256 256
             }
257 257
         }
258 258
 
259
-        return true;
259
+        return TRUE;
260 260
     }
261 261
 
262 262
     /**
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
     public function containsValue(...$values): bool
271 271
     {
272 272
         if ( ! $values) {
273
-            return false;
273
+            return FALSE;
274 274
         }
275 275
 
276 276
         foreach ($values as $value) {
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
                 }
281 281
             }
282 282
 
283
-            return false;
283
+            return FALSE;
284 284
         }
285 285
 
286
-        return true;
286
+        return TRUE;
287 287
     }
288 288
 
289 289
     /**
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
      *
313 313
      * @return Map
314 314
      */
315
-    public function filter(callable $callback = null): Map
315
+    public function filter(callable $callback = NULL): Map
316 316
     {
317 317
         $filtered = new self();
318 318
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
      * @throws OutOfBoundsException if no default was provided and the key is
341 341
      *                               not associated with a value.
342 342
      */
343
-    public function get($key, $default = null)
343
+    public function get($key, $default = NULL)
344 344
     {
345 345
         if (($pair = $this->lookup($key))) {
346 346
             return $pair->value;
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
      * @return mixed The carry value of the final iteration, or the initial
450 450
      *               value if the map was empty.
451 451
      */
452
-    public function reduce(callable $callback, $initial = null)
452
+    public function reduce(callable $callback, $initial = NULL)
453 453
     {
454 454
         $carry = $initial;
455 455
 
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
      * @throws \OutOfBoundsException if no default was provided and the key is
473 473
      *                               not associated with a value.
474 474
      */
475
-    public function remove($key, $default = null)
475
+    public function remove($key, $default = NULL)
476 476
     {
477 477
         foreach ($this->pairs as $position => $pair) {
478 478
 
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
                 // Delete pair, return its value
483 483
                 $value = $pair->value;
484 484
 
485
-                array_splice($this->pairs, $position, 1, null);
485
+                array_splice($this->pairs, $position, 1, NULL);
486 486
                 $this->adjustCapacity();
487 487
 
488 488
                 return $value;
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
      *
533 533
      * @return Map
534 534
      */
535
-    public function slice(int $offset, int $length = null): Map
535
+    public function slice(int $offset, int $length = NULL): Map
536 536
     {
537 537
         $map = new Map();
538 538
 
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
      *
559 559
      * @return Map
560 560
      */
561
-    public function sort(callable $comparator = null): Map
561
+    public function sort(callable $comparator = NULL): Map
562 562
     {
563 563
         $copy = $this->copy();
564 564
 
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
      */
657 657
     public function offsetUnset($offset)
658 658
     {
659
-        $this->remove($offset, null);
659
+        $this->remove($offset, NULL);
660 660
     }
661 661
 
662 662
     /**
@@ -664,6 +664,6 @@  discard block
 block discarded – undo
664 664
      */
665 665
     public function offsetExists($offset)
666 666
     {
667
-        return $this->get($offset, null) !== null;
667
+        return $this->get($offset, NULL) !== NULL;
668 668
     }
669 669
 }
Please login to merge, or discard this patch.
src/Ds/Collection.php 1 patch
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -10,6 +10,7 @@
 block discarded – undo
10 10
 {
11 11
     /**
12 12
      * Clears all elements in the Collection.
13
+     * @return void
13 14
      */
14 15
     function clear();
15 16
 
Please login to merge, or discard this patch.
src/Ds/Sequence.php 2 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -13,6 +13,7 @@  discard block
 block discarded – undo
13 13
      * object. The keys of either will not be preserved.
14 14
      *
15 15
      * @param array|\Traversable $values
16
+     * @return void
16 17
      */
17 18
     function __construct($values = null);
18 19
 
@@ -23,6 +24,7 @@  discard block
 block discarded – undo
23 24
      * @param int $capacity The number of values for which capacity should be
24 25
      *                      allocated. Capacity will stay the same if this value
25 26
      *                      is less than or equal to the current capacity.
27
+     * @return void
26 28
      */
27 29
     function allocate(int $capacity);
28 30
 
@@ -94,6 +96,7 @@  discard block
 block discarded – undo
94 96
      * @param mixed ...$values
95 97
      *
96 98
      * @throws \OutOfRangeException if the index is not in the range [0, n]
99
+     * @return void
97 100
      */
98 101
     function insert(int $index, ...$values);
99 102
 
@@ -148,6 +151,7 @@  discard block
 block discarded – undo
148 151
      * Adds zero or more values to the end of the sequence.
149 152
      *
150 153
      * @param mixed ...$values
154
+     * @return void
151 155
      */
152 156
     function push(...$values);
153 157
 
@@ -155,6 +159,7 @@  discard block
 block discarded – undo
155 159
      * Adds all values in an array or iterable object to the sequence.
156 160
      *
157 161
      * @param array|\Traversable $values
162
+     * @return void
158 163
      */
159 164
     function pushAll($values);
160 165
 
@@ -195,6 +200,7 @@  discard block
 block discarded – undo
195 200
      * positive, or 'pop' and 'unshift' if negative.
196 201
      *
197 202
      * @param int $rotations The number of rotations (can be negative).
203
+     * @return void
198 204
      */
199 205
     function rotate(int $rotations);
200 206
 
@@ -205,6 +211,7 @@  discard block
 block discarded – undo
205 211
      * @param mixed $value
206 212
      *
207 213
      * @throws \OutOfRangeException if the index is not in the range [0, size-1]
214
+     * @return void
208 215
      */
209 216
     function set(int $index, $value);
210 217
 
@@ -255,6 +262,7 @@  discard block
 block discarded – undo
255 262
      * Adds zero or more values to the front of the sequence.
256 263
      *
257 264
      * @param mixed ...$values
265
+     * @return void
258 266
      */
259 267
     function unshift(...$values);
260 268
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
      *
15 15
      * @param array|\Traversable $values
16 16
      */
17
-    function __construct($values = null);
17
+    function __construct($values = NULL);
18 18
 
19 19
     /**
20 20
      * Ensures that enough memory is allocated for a specified capacity. This
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      *
54 54
      * @return Sequence
55 55
      */
56
-    function filter(callable $callback = null): Sequence;
56
+    function filter(callable $callback = NULL): Sequence;
57 57
 
58 58
     /**
59 59
      * Returns the index of a given value, or false if it could not be found.
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      *
106 106
      * @return string
107 107
      */
108
-    function join(string $glue = null): string;
108
+    function join(string $glue = NULL): string;
109 109
 
110 110
     /**
111 111
      * Returns the last value in the sequence.
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      * @return mixed The carry value of the final iteration, or the initial
170 170
      *               value if the sequence was empty.
171 171
      */
172
-    function reduce(callable $callback, $initial = null);
172
+    function reduce(callable $callback, $initial = NULL);
173 173
 
174 174
     /**
175 175
      * Removes and returns the value at a given index in the sequence.
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
      *
239 239
      * @return Sequence
240 240
      */
241
-    function slice(int $offset, int $length = null): Sequence;
241
+    function slice(int $offset, int $length = NULL): Sequence;
242 242
 
243 243
     /**
244 244
      * Returns a sorted copy of the sequence, based on an optional callable
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
      *
250 250
      * @return Sequence
251 251
      */
252
-    function sort(callable $comparator = null): Sequence;
252
+    function sort(callable $comparator = NULL): Sequence;
253 253
 
254 254
     /**
255 255
      * Adds zero or more values to the front of the sequence.
Please login to merge, or discard this patch.
src/Ds/Queue.php 1 patch
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      *
22 22
      * @param array|\Traversable $values
23 23
      */
24
-    public function __construct($values = null)
24
+    public function __construct($values = NULL)
25 25
     {
26 26
         $this->internal = new Deque($values);
27 27
     }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      */
142 142
     public function offsetSet($offset, $value)
143 143
     {
144
-        if ($offset === null) {
144
+        if ($offset === NULL) {
145 145
             $this->push($value);
146 146
         } else {
147 147
             throw new Error();
Please login to merge, or discard this patch.
src/Ds/Stack.php 1 patch
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      *
24 24
      * @param array|\Traversable $values
25 25
      */
26
-    public function __construct($values = null)
26
+    public function __construct($values = NULL)
27 27
     {
28 28
         $this->internal = new Vector($values);
29 29
     }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function getIterator()
138 138
     {
139
-        while ($this->isEmpty() === false) {
139
+        while ($this->isEmpty() === FALSE) {
140 140
             yield $this->pop();
141 141
         }
142 142
     }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      */
149 149
     public function offsetSet($offset, $value)
150 150
     {
151
-        if ($offset === null) {
151
+        if ($offset === NULL) {
152 152
             $this->push($value);
153 153
         } else {
154 154
             throw new Error();
Please login to merge, or discard this patch.
src/Ds/Set.php 1 patch
Upper-Lower-Casing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      *
28 28
      * @param array|\Traversable $values
29 29
      */
30
-    public function __construct($values = null)
30
+    public function __construct($values = NULL)
31 31
     {
32 32
         $this->internal = new Map();
33 33
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     public function add(...$values)
49 49
     {
50 50
         foreach ($values as $value) {
51
-            $this->internal[$value] = null;
51
+            $this->internal[$value] = NULL;
52 52
         }
53 53
     }
54 54
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     {
62 62
         if ($values) {
63 63
             foreach ($values as $value) {
64
-                $this->internal[$value] = null;
64
+                $this->internal[$value] = NULL;
65 65
             }
66 66
         }
67 67
     }
@@ -108,16 +108,16 @@  discard block
 block discarded – undo
108 108
     public function contains(...$values): bool
109 109
     {
110 110
         if ( ! $values) {
111
-            return false;
111
+            return FALSE;
112 112
         }
113 113
 
114 114
         foreach ($values as $value) {
115 115
             if ( ! $this->internal->containsKey($value)) {
116
-                return false;
116
+                return FALSE;
117 117
             }
118 118
         }
119 119
 
120
-        return true;
120
+        return TRUE;
121 121
     }
122 122
 
123 123
     /**
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
      *
202 202
      * @return Set
203 203
      */
204
-    public function filter(callable $callback = null): Set
204
+    public function filter(callable $callback = NULL): Set
205 205
     {
206 206
         $filtered = new Set();
207 207
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
      *
291 291
      * @return string
292 292
      */
293
-    public function join(string $glue = null): string
293
+    public function join(string $glue = NULL): string
294 294
     {
295 295
         return implode($glue, $this->toArray());
296 296
     }
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
      * @return mixed The carry value of the final iteration, or the initial
317 317
      *               value if the set was empty.
318 318
      */
319
-    public function reduce(callable $callback, $initial = null)
319
+    public function reduce(callable $callback, $initial = NULL)
320 320
     {
321 321
         $carry = $initial;
322 322
 
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
     public function remove(...$values)
336 336
     {
337 337
         foreach ($values as $value) {
338
-            $this->internal->remove($value, null);
338
+            $this->internal->remove($value, NULL);
339 339
         }
340 340
     }
341 341
 
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
      *
374 374
      * @return Set
375 375
      */
376
-    public function slice(int $offset, int $length = null): Set
376
+    public function slice(int $offset, int $length = NULL): Set
377 377
     {
378 378
         $sliced = new Set();
379 379
         $sliced->internal = $this->internal->slice($offset, $length);
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
      *
391 391
      * @return Set
392 392
      */
393
-    public function sort(callable $comparator = null): Set
393
+    public function sort(callable $comparator = NULL): Set
394 394
     {
395 395
         $set = new Set();
396 396
         $set->internal = $this->internal->sort($comparator);
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
      */
449 449
     public function offsetSet($offset, $value)
450 450
     {
451
-        if ($offset === null) {
451
+        if ($offset === NULL) {
452 452
             $this->add($value);
453 453
             return;
454 454
         }
Please login to merge, or discard this patch.
src/Ds/Pair.php 1 patch
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      * @param mixed $key
25 25
      * @param mixed $value
26 26
      */
27
-    public function __construct($key = null, $value = null)
27
+    public function __construct($key = NULL, $value = NULL)
28 28
     {
29 29
         $this->key = $key;
30 30
         $this->value = $value;
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
     public function __get($name)
41 41
     {
42 42
         if ($name === 'key') {
43
-            $this->key = null;
43
+            $this->key = NULL;
44 44
             return $this->key;
45 45
         }
46 46
 
47 47
         if ($name === 'value') {
48
-            $this->value = null;
48
+            $this->value = NULL;
49 49
             return $this->value;
50 50
         }
51 51
     }
Please login to merge, or discard this patch.