@@ -97,7 +97,7 @@ public static function fromArray(array $config): self
97
97
];
98
98
99
99
foreach ($ config as $ prop => $ values ) {
100
- if (isset ($ allowed [$ prop ])) {
100
+ if ($ values && isset ($ allowed [$ prop ])) {
101
101
$ method = $ allowed [$ prop ];
102
102
$ finder ->$ method ($ values );
103
103
}
@@ -164,7 +164,9 @@ public function name(string $pattern): self
164
164
*/
165
165
public function addNames ($ patterns ): self
166
166
{
167
- $ this ->names = \array_merge ($ this ->names , (array )$ patterns );
167
+ if ($ patterns ) {
168
+ $ this ->names = \array_merge ($ this ->names , (array )$ patterns );
169
+ }
168
170
169
171
return $ this ;
170
172
}
@@ -186,7 +188,9 @@ public function notName(string $pattern): self
186
188
*/
187
189
public function addNotNames ($ patterns ): self
188
190
{
189
- $ this ->notNames = array_merge ($ this ->notNames , $ patterns );
191
+ if ($ patterns ) {
192
+ $ this ->notNames = \array_merge ($ this ->notNames , (array )$ patterns );
193
+ }
190
194
191
195
return $ this ;
192
196
}
@@ -210,7 +214,9 @@ public function path(string $pattern): self
210
214
*/
211
215
public function addPaths ($ patterns ): self
212
216
{
213
- $ this ->paths = array_merge ($ this ->paths , $ patterns );
217
+ if ($ patterns ) {
218
+ $ this ->paths = \array_merge ($ this ->paths , (array )$ patterns );
219
+ }
214
220
215
221
return $ this ;
216
222
}
@@ -232,7 +238,9 @@ public function notPath(string $pattern): self
232
238
*/
233
239
public function addNotPaths ($ patterns ): self
234
240
{
235
- $ this ->notPaths = array_merge ($ this ->notPaths , (array )$ patterns );
241
+ if ($ patterns ) {
242
+ $ this ->notPaths = \array_merge ($ this ->notPaths , (array )$ patterns );
243
+ }
236
244
237
245
return $ this ;
238
246
}
@@ -243,7 +251,9 @@ public function addNotPaths($patterns): self
243
251
*/
244
252
public function exclude ($ dirs ): self
245
253
{
246
- $ this ->excludes = array_merge ($ this ->excludes , (array )$ dirs );
254
+ if ($ dirs ) {
255
+ $ this ->excludes = \array_merge ($ this ->excludes , (array )$ dirs );
256
+ }
247
257
248
258
return $ this ;
249
259
}
@@ -281,7 +291,7 @@ public function ignoreDotFiles($ignoreDotFiles): self
281
291
* @param bool $followLinks
282
292
* @return FileFinder
283
293
*/
284
- public function followLinks ($ followLinks ): self
294
+ public function followLinks ($ followLinks = true ): self
285
295
{
286
296
$ this ->followLinks = (bool )$ followLinks ;
287
297
@@ -305,9 +315,7 @@ public function filter(\Closure $closure): self
305
315
*/
306
316
public function in ($ dirs ): self
307
317
{
308
- $ this ->dirs = array_merge ($ this ->dirs , (array )$ dirs );
309
-
310
- return $ this ;
318
+ return $ this ->inDir ($ dirs );
311
319
}
312
320
313
321
/**
@@ -317,7 +325,9 @@ public function in($dirs): self
317
325
*/
318
326
public function inDir ($ dirs ): self
319
327
{
320
- $ this ->dirs = array_merge ($ this ->dirs , (array )$ dirs );
328
+ if ($ dirs ) {
329
+ $ this ->dirs = \array_merge ($ this ->dirs , (array )$ dirs );
330
+ }
321
331
322
332
return $ this ;
323
333
}
0 commit comments