$ignore * @return bool true — обошли всё; false — остановились по просьбе колбэка */ public static function walk(string $directory, callable $onFile, array $ignore = self::DEFAULT_IGNORE): bool { $entries = @scandir($directory); if ($entries === false) { return true; } foreach ($entries as $name) { if ($name === '.' || $name === '..' || in_array($name, $ignore, true)) { continue; } $path = $directory . DIRECTORY_SEPARATOR . $name; if (is_dir($path)) { if (!self::walk($path, $onFile, $ignore)) { return false; } continue; } if (is_file($path) && $onFile($path) === false) { return false; } } return true; } }