public static function listFilesRecursive($dirPath, \Closure $filter = null)
    {
        $files = [];
        foreach (
            new RecursiveIteratorIterator(
                new RecursiveDirectoryIterator($dirPath, FilesystemIterator::SKIP_DOTS),
                RecursiveIteratorIterator::CHILD_FIRST
            ) as $finfo
        ) {
            if ($finfo->isFile()) {
                if ($filter) {
                    if ($filter($finfo)) {
                        $files[] = $finfo;
                    }
                } else {
                    $files[] = $finfo;
                }
            }
        }
        return $files;
    }