@@ -94,11 +94,9 @@ private function select(array $masks, string $type): self
9494 {
9595 $ this ->cursor = &$ this ->groups [];
9696 $ pattern = self ::buildPattern ($ masks );
97- $ this ->filter (function (RecursiveDirectoryIterator $ file ) use ($ type , $ pattern ): bool {
98- return !$ file ->isDot ()
97+ $ this ->filter (fn (RecursiveDirectoryIterator $ file ): bool => !$ file ->isDot ()
9998 && $ file ->$ type ()
100- && (!$ pattern || preg_match ($ pattern , '/ ' . strtr ($ file ->getSubPathName (), '\\' , '/ ' )));
101- });
99+ && (!$ pattern || preg_match ($ pattern , '/ ' . strtr ($ file ->getSubPathName (), '\\' , '/ ' ))));
102100 return $ this ;
103101 }
104102
@@ -163,7 +161,7 @@ private static function buildPattern(array $masks): ?string
163161 }
164162 $ pattern [] = $ prefix . strtr (
165163 preg_quote ($ mask , '# ' ),
166- ['\*\* ' => '.* ' , '\* ' => '[^/]* ' , '\? ' => '[^/] ' , '\[\! ' => '[^ ' , '\[ ' => '[ ' , '\] ' => '] ' , '\- ' => '- ' ]
164+ ['\*\* ' => '.* ' , '\* ' => '[^/]* ' , '\? ' => '[^/] ' , '\[\! ' => '[^ ' , '\[ ' => '[ ' , '\] ' => '] ' , '\- ' => '- ' ],
167165 );
168166 }
169167 return $ pattern ? '#/( ' . implode ('| ' , $ pattern ) . ')$#Di ' : null ;
@@ -261,9 +259,7 @@ public function exclude(...$masks): self
261259 $ masks = $ masks && is_array ($ masks [0 ]) ? $ masks [0 ] : $ masks ;
262260 $ pattern = self ::buildPattern ($ masks );
263261 if ($ pattern ) {
264- $ this ->filter (function (RecursiveDirectoryIterator $ file ) use ($ pattern ): bool {
265- return !preg_match ($ pattern , '/ ' . strtr ($ file ->getSubPathName (), '\\' , '/ ' ));
266- });
262+ $ this ->filter (fn (RecursiveDirectoryIterator $ file ): bool => !preg_match ($ pattern , '/ ' . strtr ($ file ->getSubPathName (), '\\' , '/ ' )));
267263 }
268264 return $ this ;
269265 }
@@ -308,9 +304,7 @@ public function size(string $operator, int $size = null): self
308304 $ size *= $ units [strtolower ($ unit )];
309305 $ operator = $ operator ?: '= ' ;
310306 }
311- return $ this ->filter (function (RecursiveDirectoryIterator $ file ) use ($ operator , $ size ): bool {
312- return self ::compare ($ file ->getSize (), $ operator , $ size );
313- });
307+ return $ this ->filter (fn (RecursiveDirectoryIterator $ file ): bool => self ::compare ($ file ->getSize (), $ operator , $ size ));
314308 }
315309
316310
@@ -330,9 +324,7 @@ public function date(string $operator, $date = null): self
330324 $ operator = $ operator ?: '= ' ;
331325 }
332326 $ date = DateTime::from ($ date )->format ('U ' );
333- return $ this ->filter (function (RecursiveDirectoryIterator $ file ) use ($ operator , $ date ): bool {
334- return self ::compare ($ file ->getMTime (), $ operator , $ date );
335- });
327+ return $ this ->filter (fn (RecursiveDirectoryIterator $ file ): bool => self ::compare ($ file ->getMTime (), $ operator , $ date ));
336328 }
337329
338330
0 commit comments