Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 036c8d7

Browse filesBrowse files
committed
use proper keys to not override appended files
1 parent 8533ea2 commit 036c8d7
Copy full SHA for 036c8d7

File tree

2 files changed

+13
-1
lines changed
Filter options

2 files changed

+13
-1
lines changed

‎src/Symfony/Component/Finder/Finder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Finder.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,8 @@ public function append($iterator)
669669
} elseif ($iterator instanceof \Traversable || \is_array($iterator)) {
670670
$it = new \ArrayIterator();
671671
foreach ($iterator as $file) {
672-
$it->append($file instanceof \SplFileInfo ? $file : new \SplFileInfo($file));
672+
$file = $file instanceof \SplFileInfo ? $file : new \SplFileInfo($file);
673+
$it[$file->getPathname()] = $file;
673674
}
674675
$this->iterators[] = $it;
675676
} else {

‎src/Symfony/Component/Finder/Tests/FinderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Tests/FinderTest.php
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,17 @@ public function testAppendDoesNotRequireIn()
11191119
$this->assertIterator(iterator_to_array($finder->getIterator()), $finder1->getIterator());
11201120
}
11211121

1122+
public function testMultipleAppendCallsWithSorting()
1123+
{
1124+
$finder = $this->buildFinder()
1125+
->sortByName()
1126+
->append([self::$tmpDir.\DIRECTORY_SEPARATOR.'qux_1000_1.php'])
1127+
->append([self::$tmpDir.\DIRECTORY_SEPARATOR.'qux_1002_0.php'])
1128+
;
1129+
1130+
$this->assertOrderedIterator($this->toAbsolute(['qux_1000_1.php', 'qux_1002_0.php']), $finder->getIterator());
1131+
}
1132+
11221133
public function testCountDirectories()
11231134
{
11241135
$directory = Finder::create()->directories()->in(self::$tmpDir);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.