Skip to content

Dir::index - ignore argument doesn't do anything #5010

@adamkiss

Description

@adamkiss

Description

One of the parameters of Dir::index doesn't do anything other than being pass along to a recursive, call where it doesn't do anything again.

Expected behavior
Makes Dir::index ignore file, either by relative name (file.txt), or absolute name.

To reproduce

Just look at the source:

public static function index(
string $dir,
bool $recursive = false,
array|null $ignore = null,
string $path = null
): array {
$result = [];
$dir = realpath($dir);
$items = static::read($dir);
foreach ($items as $item) {
$root = $dir . '/' . $item;
$entry = $path !== null ? $path . '/' . $item : $item;
$result[] = $entry;
if ($recursive === true && is_dir($root) === true) {
$result = array_merge($result, static::index($root, true, $ignore, $entry));
}
}
return $result;
}

$ignore is used only once, and that's when the recursion is called.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions