From 624fb61f0d38a1aa2e91bb98207f3e0f16c08528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Thu, 17 Oct 2024 00:05:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E6=89=AB=E6=8F=8F=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/extend/ToolsExtend.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/extend/ToolsExtend.php b/src/extend/ToolsExtend.php index d199a51a..50af9912 100644 --- a/src/extend/ToolsExtend.php +++ b/src/extend/ToolsExtend.php @@ -87,8 +87,8 @@ public static function removeEmptyDirectory(string $path): bool */ public static function scanDirectory(string $path, ?int $depth = null, string $filterExt = '', bool $shortPath = true): array { - return static::findFilesArray($path, $depth, static function (SplFileInfo $info) use ($filterExt) { - return !$filterExt || $info->getExtension() === $filterExt; + return static::findFilesArray($path, $depth, function (SplFileInfo $info) use ($filterExt, &$files) { + return $info->isDir() || $filterExt === '' || strtolower($info->getExtension()) === strtolower($filterExt); }, $shortPath); } @@ -120,7 +120,7 @@ public static function findFilesArray(string $path, ?int $depth = null, ?Closure * @param ?integer $depth 扫描深度 * @param \Closure|null $filter 文件过滤,返回 false 表示放弃 * @param boolean $appendPath 是否包含目录本身在结果中。 - * @param integer $currDepth 当前递归深度,初始值为 0。 + * @param integer $currDepth 当前深度,临时变量递归时使用。 * @return \Generator 返回 SplFileInfo 对象的生成器。 */ private static function findFilesYield(string $path, ?int $depth = null, ?Closure $filter = null, bool $appendPath = false, int $currDepth = 1): Generator