diff --git a/src/FileFinder.php b/src/FileFinder.php index 1e66e80..018016b 100644 --- a/src/FileFinder.php +++ b/src/FileFinder.php @@ -97,7 +97,7 @@ public static function fromArray(array $config): self ]; foreach ($config as $prop => $values) { - if (isset($allowed[$prop])) { + if ($values && isset($allowed[$prop])) { $method = $allowed[$prop]; $finder->$method($values); } @@ -164,7 +164,9 @@ public function name(string $pattern): self */ public function addNames($patterns): self { - $this->names = \array_merge($this->names, (array)$patterns); + if ($patterns) { + $this->names = \array_merge($this->names, (array)$patterns); + } return $this; } @@ -186,7 +188,9 @@ public function notName(string $pattern): self */ public function addNotNames($patterns): self { - $this->notNames = array_merge($this->notNames, $patterns); + if ($patterns) { + $this->notNames = \array_merge($this->notNames, (array)$patterns); + } return $this; } @@ -210,7 +214,9 @@ public function path(string $pattern): self */ public function addPaths($patterns): self { - $this->paths = array_merge($this->paths, $patterns); + if ($patterns) { + $this->paths = \array_merge($this->paths, (array)$patterns); + } return $this; } @@ -232,7 +238,9 @@ public function notPath(string $pattern): self */ public function addNotPaths($patterns): self { - $this->notPaths = array_merge($this->notPaths, (array)$patterns); + if ($patterns) { + $this->notPaths = \array_merge($this->notPaths, (array)$patterns); + } return $this; } @@ -243,7 +251,9 @@ public function addNotPaths($patterns): self */ public function exclude($dirs): self { - $this->excludes = array_merge($this->excludes, (array)$dirs); + if ($dirs) { + $this->excludes = \array_merge($this->excludes, (array)$dirs); + } return $this; } @@ -281,7 +291,7 @@ public function ignoreDotFiles($ignoreDotFiles): self * @param bool $followLinks * @return FileFinder */ - public function followLinks($followLinks): self + public function followLinks($followLinks = true): self { $this->followLinks = (bool)$followLinks; @@ -305,9 +315,7 @@ public function filter(\Closure $closure): self */ public function in($dirs): self { - $this->dirs = array_merge($this->dirs, (array)$dirs); - - return $this; + return $this->inDir($dirs); } /** @@ -317,7 +325,9 @@ public function in($dirs): self */ public function inDir($dirs): self { - $this->dirs = array_merge($this->dirs, (array)$dirs); + if ($dirs) { + $this->dirs = \array_merge($this->dirs, (array)$dirs); + } return $this; }