Skip to content
This repository was archived by the owner on Jun 17, 2020. It is now read-only.

Commit 7f3d031

Browse files
committed
some modify
1 parent 6871acd commit 7f3d031

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

src/FileFinder.php

+21-11
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public static function fromArray(array $config): self
9797
];
9898

9999
foreach ($config as $prop => $values) {
100-
if (isset($allowed[$prop])) {
100+
if ($values && isset($allowed[$prop])) {
101101
$method = $allowed[$prop];
102102
$finder->$method($values);
103103
}
@@ -164,7 +164,9 @@ public function name(string $pattern): self
164164
*/
165165
public function addNames($patterns): self
166166
{
167-
$this->names = \array_merge($this->names, (array)$patterns);
167+
if ($patterns) {
168+
$this->names = \array_merge($this->names, (array)$patterns);
169+
}
168170

169171
return $this;
170172
}
@@ -186,7 +188,9 @@ public function notName(string $pattern): self
186188
*/
187189
public function addNotNames($patterns): self
188190
{
189-
$this->notNames = array_merge($this->notNames, $patterns);
191+
if ($patterns) {
192+
$this->notNames = \array_merge($this->notNames, (array)$patterns);
193+
}
190194

191195
return $this;
192196
}
@@ -210,7 +214,9 @@ public function path(string $pattern): self
210214
*/
211215
public function addPaths($patterns): self
212216
{
213-
$this->paths = array_merge($this->paths, $patterns);
217+
if ($patterns) {
218+
$this->paths = \array_merge($this->paths, (array)$patterns);
219+
}
214220

215221
return $this;
216222
}
@@ -232,7 +238,9 @@ public function notPath(string $pattern): self
232238
*/
233239
public function addNotPaths($patterns): self
234240
{
235-
$this->notPaths = array_merge($this->notPaths, (array)$patterns);
241+
if ($patterns) {
242+
$this->notPaths = \array_merge($this->notPaths, (array)$patterns);
243+
}
236244

237245
return $this;
238246
}
@@ -243,7 +251,9 @@ public function addNotPaths($patterns): self
243251
*/
244252
public function exclude($dirs): self
245253
{
246-
$this->excludes = array_merge($this->excludes, (array)$dirs);
254+
if ($dirs) {
255+
$this->excludes = \array_merge($this->excludes, (array)$dirs);
256+
}
247257

248258
return $this;
249259
}
@@ -281,7 +291,7 @@ public function ignoreDotFiles($ignoreDotFiles): self
281291
* @param bool $followLinks
282292
* @return FileFinder
283293
*/
284-
public function followLinks($followLinks): self
294+
public function followLinks($followLinks = true): self
285295
{
286296
$this->followLinks = (bool)$followLinks;
287297

@@ -305,9 +315,7 @@ public function filter(\Closure $closure): self
305315
*/
306316
public function in($dirs): self
307317
{
308-
$this->dirs = array_merge($this->dirs, (array)$dirs);
309-
310-
return $this;
318+
return $this->inDir($dirs);
311319
}
312320

313321
/**
@@ -317,7 +325,9 @@ public function in($dirs): self
317325
*/
318326
public function inDir($dirs): self
319327
{
320-
$this->dirs = array_merge($this->dirs, (array)$dirs);
328+
if ($dirs) {
329+
$this->dirs = \array_merge($this->dirs, (array)$dirs);
330+
}
321331

322332
return $this;
323333
}

0 commit comments

Comments
 (0)