Upgrade to 3.9.2

This commit is contained in:
Bastian Allgeier
2023-03-08 12:24:06 +01:00
parent c58864a585
commit 3b0b4feb16
44 changed files with 672 additions and 201 deletions

View File

@@ -57,7 +57,7 @@ class Dir
string $dir,
string $target,
bool $recursive = true,
array|bool $ignore = []
array|false $ignore = []
): bool {
if (is_dir($dir) === false) {
throw new Exception('The directory "' . $dir . '" does not exist');
@@ -139,19 +139,32 @@ class Dir
/**
* Read the directory and all subdirectories
*
* @todo Remove support for `$ignore = null` in a major release
* @param array|false|null $ignore Array of absolut file paths;
* `false` to disable `Dir::$ignore` list
* (passing null is deprecated)
*/
public static function index(
string $dir,
bool $recursive = false,
array|null $ignore = null,
array|false|null $ignore = [],
string $path = null
): array {
$result = [];
$dir = realpath($dir);
$items = static::read($dir);
$items = static::read($dir, $ignore === false ? [] : null);
foreach ($items as $item) {
$root = $dir . '/' . $item;
$root = $dir . '/' . $item;
if (
is_array($ignore) === true &&
in_array($root, $ignore) === true
) {
continue;
}
$entry = $path !== null ? $path . '/' . $item : $item;
$result[] = $entry;