Skip to content

Commit dd9b21f

Browse files
committed
Finder: collect() returns list
1 parent 4520494 commit dd9b21f

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/Utils/Finder.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,11 @@ public function date(string $operator, string|int|\DateTimeInterface|null $date
309309

310310
/**
311311
* Returns an array with all found files and directories.
312+
* @return list<FileInfo>
312313
*/
313314
public function collect(): array
314315
{
315-
return iterator_to_array($this->getIterator());
316+
return iterator_to_array($this->getIterator(), preserve_keys: false);
316317
}
317318

318319

tests/Utils/Finder.append.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ test('append finder', function () {
3131
"fixtures.finder{$ds}subdir",
3232
"fixtures.finder{$ds}subdir{$ds}subdir2",
3333
"fixtures.finder{$ds}subdir{$ds}subdir2{$ds}file.txt",
34-
], array_keys($finder->collect()));
34+
], array_map('strval', $finder->collect()));
3535
});
3636

3737
test('append files', function () {
@@ -40,7 +40,7 @@ test('append files', function () {
4040
->append(FileSystem::unixSlashes(__DIR__));
4141

4242
Assert::equal([
43-
__FILE__ => new Nette\Utils\FileInfo(__FILE__),
44-
__DIR__ => new Nette\Utils\FileInfo(__DIR__),
43+
new Nette\Utils\FileInfo(__FILE__),
44+
new Nette\Utils\FileInfo(__DIR__),
4545
], $finder->collect());
4646
});

tests/Utils/Finder.fileInfo.phpt

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test('absolute path', function () {
2020
->collect();
2121

2222
Assert::equal(
23-
[__FILE__ => new FileInfo(__FILE__)],
23+
[new FileInfo(__FILE__)],
2424
$files,
2525
);
2626

@@ -36,7 +36,6 @@ test('relative path', function () {
3636
->from('fixtures.finder')
3737
->collect();
3838

39-
$files = array_values($files);
4039
$ds = DIRECTORY_SEPARATOR;
4140
Assert::same('subdir', $files[0]->getRelativePath());
4241
Assert::same("subdir{$ds}readme", $files[0]->getRelativePathname());

0 commit comments

Comments
 (0)