@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | /** |
134 | 134 | * Easy access iterator apply for processing an entire file. |
135 | 135 | * |
136 | - * @param Iterator $input [description] |
|
136 | + * @param \Iterator $input [description] |
|
137 | 137 | * @param callable $callback [description] |
138 | 138 | */ |
139 | 139 | public function process(\Iterator $input, callable $callback) |
@@ -169,8 +169,6 @@ discard block |
||
169 | 169 | /** |
170 | 170 | * File comparison |
171 | 171 | * |
172 | - * @param string $filename |
|
173 | - * The file to check against. |
|
174 | 172 | * |
175 | 173 | * @return bool |
176 | 174 | * True if the contents of this file matches the contents of $filename. |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | { |
141 | 141 | $callback = \Closure::fromCallable($callback); |
142 | 142 | $input->rewind(); |
143 | - iterator_apply($input, function (\Iterator $iterator) use ($callback) { |
|
143 | + iterator_apply($input, function(\Iterator $iterator) use ($callback) { |
|
144 | 144 | $callback($iterator->current(), $iterator->key(), $iterator, $this); |
145 | 145 | return true; |
146 | 146 | }, [$input]); |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | // Rewind this temp file and compare it with the specified file. |
195 | 195 | $identical = true; |
196 | 196 | $tempFile->fseek(0); |
197 | - while(!$file->eof()) { |
|
198 | - if($file->fread(8192) != $tempFile->fread(8192)) { |
|
197 | + while (!$file->eof()) { |
|
198 | + if ($file->fread(8192) != $tempFile->fread(8192)) { |
|
199 | 199 | $identical = false; |
200 | 200 | break; |
201 | 201 | } |
@@ -115,15 +115,12 @@ |
||
115 | 115 | if ($this->persist == self::PERSIST || $this->persist == self::PERSIST_UNCHANGED) { |
116 | 116 | if ($this->persist == self::PERSIST_UNCHANGED || !$this->doCompare()) { |
117 | 117 | $this->doPersist(); |
118 | - } |
|
119 | - else { |
|
118 | + } else { |
|
120 | 119 | $this->doDiscard(); |
121 | 120 | } |
122 | - } |
|
123 | - elseif ($this->persist & self::DISCARD) { |
|
121 | + } elseif ($this->persist & self::DISCARD) { |
|
124 | 122 | $this->doDiscard(); |
125 | - } |
|
126 | - else { |
|
123 | + } else { |
|
127 | 124 | // @codeCoverageIgnoreStart |
128 | 125 | trigger_error("Temp file left on device: " . $this->getRealPath(), E_USER_WARNING); |
129 | 126 | // @codeCoverageIgnoreEnd |
@@ -16,6 +16,9 @@ |
||
16 | 16 | self::$root = $root; |
17 | 17 | } |
18 | 18 | |
19 | + /** |
|
20 | + * @param string $path |
|
21 | + */ |
|
19 | 22 | protected static function getRootedPath($path) |
20 | 23 | { |
21 | 24 | // Avoid infinite recursion. |
@@ -30,6 +30,9 @@ |
||
30 | 30 | return $iterators ? end($iterators) : false; |
31 | 31 | } |
32 | 32 | |
33 | + /** |
|
34 | + * @return string |
|
35 | + */ |
|
33 | 36 | public static function reduce(\Traversable $iterator, callable $callback, $initial = null) |
34 | 37 | { |
35 | 38 | $callback = \Closure::fromCallable($callback); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | public static function reduce(\Traversable $iterator, callable $callback, $initial = null) |
34 | 34 | { |
35 | 35 | $callback = \Closure::fromCallable($callback); |
36 | - iterator_apply($iterator, function ($iterator) use (&$initial, $callback) { |
|
36 | + iterator_apply($iterator, function($iterator) use (&$initial, $callback) { |
|
37 | 37 | $initial = $callback($initial, $iterator->current(), $iterator->key()); |
38 | 38 | return true; |
39 | 39 | }, [$iterator]); |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | |
43 | 43 | public static function sum(\Traversable $iterator) |
44 | 44 | { |
45 | - return self::reduce($iterator, function ($carry, $value, $key) { |
|
45 | + return self::reduce($iterator, function($carry, $value, $key) { |
|
46 | 46 | return $carry + $value; |
47 | 47 | }, 0); |
48 | 48 | } |
49 | 49 | |
50 | 50 | public static function product(\Traversable $iterator) |
51 | 51 | { |
52 | - return self::reduce($iterator, function ($carry, $value, $key) { |
|
52 | + return self::reduce($iterator, function($carry, $value, $key) { |
|
53 | 53 | return $carry * $value; |
54 | 54 | }, 1); |
55 | 55 | } |
@@ -61,28 +61,28 @@ discard block |
||
61 | 61 | |
62 | 62 | public static function min(\Traversable $iterator) |
63 | 63 | { |
64 | - return self::reduce($iterator, function ($carry, $value, $key) { |
|
64 | + return self::reduce($iterator, function($carry, $value, $key) { |
|
65 | 65 | return $carry < $value ? $carry : $value; |
66 | 66 | }, INF); |
67 | 67 | } |
68 | 68 | |
69 | 69 | public static function max(\Traversable $iterator) |
70 | 70 | { |
71 | - return self::reduce($iterator, function ($carry, $value, $key) { |
|
71 | + return self::reduce($iterator, function($carry, $value, $key) { |
|
72 | 72 | return $carry > $value ? $carry : $value; |
73 | 73 | }, -INF); |
74 | 74 | } |
75 | 75 | |
76 | 76 | public static function concatenate(\Traversable $iterator) |
77 | 77 | { |
78 | - return self::reduce($iterator, function ($carry, $value, $key) { |
|
78 | + return self::reduce($iterator, function($carry, $value, $key) { |
|
79 | 79 | return $carry . $value; |
80 | 80 | }, ''); |
81 | 81 | } |
82 | 82 | |
83 | 83 | public static function implode($separator, \Traversable $iterator) |
84 | 84 | { |
85 | - $result = self::reduce($iterator, function ($carry, $value, $key) use ($separator) { |
|
85 | + $result = self::reduce($iterator, function($carry, $value, $key) use ($separator) { |
|
86 | 86 | return $carry . $value . $separator; |
87 | 87 | }, ''); |
88 | 88 | $result = mb_substr($result, 0, -mb_strlen($separator)); |
@@ -96,8 +96,7 @@ |
||
96 | 96 | $value = $value instanceof \Traversable ? self::iterator_to_array_deep($value, $use_keys) : $value; |
97 | 97 | if ($use_keys) { |
98 | 98 | $result[$key] = $value; |
99 | - } |
|
100 | - else { |
|
99 | + } else { |
|
101 | 100 | $result[] = $value; |
102 | 101 | } |
103 | 102 | } |
@@ -27,6 +27,9 @@ |
||
27 | 27 | parent::__construct($this->getSortedIterator($iterator)); |
28 | 28 | } |
29 | 29 | |
30 | + /** |
|
31 | + * @param \Traversable $iterator |
|
32 | + */ |
|
30 | 33 | public function getSortedIterator($iterator) |
31 | 34 | { |
32 | 35 | $sortedIterator = new \ArrayIterator(); |
@@ -21,7 +21,7 @@ |
||
21 | 21 | $this->direction = $direction; |
22 | 22 | $this->flags = $flags; |
23 | 23 | $this->callback = \Closure::fromCallable($callback); |
24 | - $this->realCallback = $direction == self::SORT_ASC ? $this->callback : function ($cmpA, $cmpB) { |
|
24 | + $this->realCallback = $direction == self::SORT_ASC ? $this->callback : function($cmpA, $cmpB) { |
|
25 | 25 | return ($this->callback)($cmpB, $cmpA); |
26 | 26 | }; |
27 | 27 | parent::__construct($this->getSortedIterator($iterator)); |
@@ -18,8 +18,7 @@ |
||
18 | 18 | |
19 | 19 | if ($flags & self::ASSUME_SORTED) { |
20 | 20 | $this->method = \Closure::fromCallable([$this, 'filterAssumeSorted']); |
21 | - } |
|
22 | - else { |
|
21 | + } else { |
|
23 | 22 | $this->method = \Closure::fromCallable([$this, 'filterAssumeUnsorted']); |
24 | 23 | } |
25 | 24 | } |
@@ -88,8 +88,7 @@ |
||
88 | 88 | parent::rewind(); |
89 | 89 | return $this->valid(); |
90 | 90 | } |
91 | - } |
|
92 | - elseif ( |
|
91 | + } elseif ( |
|
93 | 92 | isset($this->innerLimit) && $this->innerPos >= $this->innerLimit |
94 | 93 | && $this->currentIteration == $this->count - 1 |
95 | 94 | ) { |
@@ -31,7 +31,7 @@ |
||
31 | 31 | } |
32 | 32 | } |
33 | 33 | return true; |
34 | - } |
|
34 | + } |
|
35 | 35 | |
36 | 36 | public static function diffCurrent($iterator, $key, $value) |
37 | 37 | { |
@@ -23,14 +23,12 @@ |
||
23 | 23 | if (is_numeric($this->currentKey) && intval($this->currentKey) >= $this->idx) { |
24 | 24 | $this->idx = intval($this->currentKey) + 1; |
25 | 25 | } |
26 | - } |
|
27 | - else { |
|
26 | + } else { |
|
28 | 27 | $this->currentKey = $this->idx++; |
29 | 28 | $this->currentValue = $result; |
30 | 29 | } |
31 | 30 | |
32 | - } |
|
33 | - else { |
|
31 | + } else { |
|
34 | 32 | $this->currentKey = null; |
35 | 33 | $this->currentValue = null; |
36 | 34 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $realPath = $path ? $path : './'; |
37 | 37 | $realPath = rtrim($realPath, '/') . '/'; |
38 | 38 | |
39 | - $flags = $flags &~ \FilesystemIterator::CURRENT_AS_PATHNAME; |
|
39 | + $flags = $flags & ~ \FilesystemIterator::CURRENT_AS_PATHNAME; |
|
40 | 40 | $flags |= \FilesystemIterator::KEY_AS_PATHNAME; |
41 | 41 | $iterator = new \RecursiveDirectoryIterator($realPath, $flags); |
42 | 42 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | GlobIteratorFileInfo::setPath($iteratorId, $path, $realPath); |
58 | 58 | |
59 | 59 | // Actual glob filtering. |
60 | - $fIterator = new \CallbackFilterIterator($rIterator, function (&$current, &$key, $iterator) use ($iteratorId, $regexPattern) { |
|
60 | + $fIterator = new \CallbackFilterIterator($rIterator, function(&$current, &$key, $iterator) use ($iteratorId, $regexPattern) { |
|
61 | 61 | GlobIteratorFileInfo::setIteratorId($iteratorId); |
62 | 62 | $fileInfo = $current->getFileInfo(GlobIteratorFileInfo::class); |
63 | 63 | if ($this->flags & \FilesystemIterator::CURRENT_AS_PATHNAME) { |
@@ -62,15 +62,13 @@ |
||
62 | 62 | $fileInfo = $current->getFileInfo(GlobIteratorFileInfo::class); |
63 | 63 | if ($this->flags & \FilesystemIterator::CURRENT_AS_PATHNAME) { |
64 | 64 | $current = $fileInfo->getPathname(); |
65 | - } |
|
66 | - else { |
|
65 | + } else { |
|
67 | 66 | $current = $fileInfo; |
68 | 67 | } |
69 | 68 | |
70 | 69 | if ($this->flags & \FilesystemIterator::KEY_AS_FILENAME) { |
71 | 70 | $key = $fileInfo->getFilename(); |
72 | - } |
|
73 | - else { |
|
71 | + } else { |
|
74 | 72 | $key = $fileInfo->getPathname(); |
75 | 73 | } |
76 | 74 | return preg_match($regexPattern, $fileInfo->getPathname()); |