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 4d97385

Browse filesBrowse files
committed
Minor updates and some cleanup.
1 parent f2e47df commit 4d97385
Copy full SHA for 4d97385

File tree

Expand file treeCollapse file tree

4 files changed

+24
-21
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+24
-21
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/FilterIterator.php
+14-15Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* This iterator just overrides the rewind method in order to correct a PHP bug,
1616
* which existed before version 5.5.23/5.6.7.
1717
*
18-
* @see https://bugs.php.net/bug.php?id=68557
18+
* @see https://bugs.php.net/68557
1919
*
2020
* @author Alex Bogomazov
2121
*/
@@ -29,23 +29,22 @@ abstract class FilterIterator extends \FilterIterator
2929
*/
3030
public function rewind()
3131
{
32-
if (PHP_VERSION_ID < 50523 || PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50607) {
33-
$iterator = $this;
34-
while ($iterator instanceof \OuterIterator) {
35-
$innerIterator = $iterator->getInnerIterator();
32+
if (PHP_VERSION_ID > 50607 || (PHP_VERSION_ID > 50523 && PHP_VERSION_ID < 50600)) {
33+
parent::rewind();
34+
return;
35+
}
36+
37+
$iterator = $this;
38+
while ($iterator instanceof \OuterIterator) {
39+
$innerIterator = $iterator->getInnerIterator();
3640

37-
if ($innerIterator instanceof RecursiveDirectoryIterator) {
38-
if ($innerIterator->isRewindable()) {
39-
$innerIterator->next();
40-
$innerIterator->rewind();
41-
}
42-
} elseif ($iterator->getInnerIterator() instanceof \FilesystemIterator) {
43-
$iterator->getInnerIterator()->next();
44-
$iterator->getInnerIterator()->rewind();
45-
}
46-
$iterator = $iterator->getInnerIterator();
41+
if ($innerIterator instanceof \FilesystemIterator) {
42+
$innerIterator->next();
43+
$innerIterator->rewind();
4744
}
45+
$iterator = $iterator->getInnerIterator();
4846
}
47+
4948
parent::rewind();
5049
}
5150
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function rewind()
118118
return;
119119
}
120120

121-
// @see https://bugs.php.net/bug.php?id=68557
121+
// @see https://bugs.php.net/68557
122122
if (PHP_VERSION_ID < 50523 || PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50607) {
123123
parent::next();
124124
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Tests/FinderTest.php
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ public function testNotContainsOnDirectory()
458458
* Searching in multiple locations involves AppendIterator which does an unnecessary rewind which leaves FilterIterator
459459
* with inner FilesystemIterator in an invalid state.
460460
*
461-
* @see https://bugs.php.net/bug.php?id=49104
461+
* @see https://bugs.php.net/68557
462462
*/
463463
public function testMultipleLocations()
464464
{
@@ -468,8 +468,12 @@ public function testMultipleLocations()
468468
);
469469

470470
// it is expected that there are test.py test.php in the tmpDir
471-
$finder = $this->buildFinder();
472-
$finder->in($locations)->depth('< 1')->name('test.php');
471+
$finder = new Finder();
472+
$finder->in($locations)
473+
// the default flag IGNORE_DOT_FILES fixes the problem indirectly
474+
// so we set it to false for better isolation
475+
->ignoreDotFiles(false)
476+
->depth('< 1')->name('test.php');
473477

474478
$this->assertCount(1, $finder);
475479
}
@@ -479,7 +483,7 @@ public function testMultipleLocations()
479483
* AppendIterator which does an unnecessary rewind which leaves
480484
* FilterIterator with inner FilesystemIterator in an invalid state.
481485
*
482-
* @see https://bugs.php.net/bug.php?id=49104
486+
* @see https://bugs.php.net/68557
483487
*/
484488
public function testMultipleLocationsWithSubDirectories()
485489
{

‎src/Symfony/Component/Finder/Tests/Iterator/FilterIteratorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Tests/Iterator/FilterIteratorTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testFilterFilesystemIterators()
4545

4646
// This would fail in php older than 5.5.23/5.6.7 with \FilterIterator
4747
// but works with Symfony\Component\Finder\Iterator\FilterIterator
48-
// see https://bugs.php.net/bug.php?id=68557
48+
// see https://bugs.php.net/68557
4949
$this->assertEquals(1, $c);
5050
}
5151
}

0 commit comments

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