8000 Merge branch '2.3' into 2.7 · symfony/symfony@c67e8b2 · GitHub
[go: up one dir, main page]

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 c67e8b2

Browse files
committed
Merge branch '2.3' into 2.7
* 2.3: [Finder] Handle filtering of recursive iterators and use it to skip looping over excluded directories Exclude files based on path before applying the sorting [Console] fix phpdoc of DialogHelper
2 parents 1abfaba + 150bcc9 commit c67e8b2

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

src/Symfony/Component/Console/Helper/DialogHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ public function setInputStream($stream)
399399
/**
400400
* Returns the helper's input stream.
401401
*
402-
* @return string
402+
* @return resource|null The input stream or null if the default STDIN is used
403403
*/
404404
public function getInputStream()
405405
{

src/Symfony/Component/Finder/Adapter/PhpAdapter.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ public function searchInDirectory($dir)
3131
$flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
3232
}
3333

34-
$iterator = new \RecursiveIteratorIterator(
35-
new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs),
36-
\RecursiveIteratorIterator::SELF_FIRST
37-
);
34+
$iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
35+
36+
if ($this->exclude) {
37+
$iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
38+
}
39+
40+
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
3841

3942
if ($this->minDepth > 0 || $this->maxDepth < PHP_INT_MAX) {
4043
$iterator = new Iterator\DepthRangeFilterIterator($iterator, $this->minDepth, $this->maxDepth);
@@ -44,10 +47,6 @@ public function searchInDirectory($dir)
4447
$iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
4548
}
4649

47-
if ($this->exclude) {
48-
$iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
49-
}
50-
5150
if ($this->names || $this->notNames) {
5251
$iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
5352
}
@@ -68,15 +67,15 @@ public function searchInDirectory($dir)
6867
$iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
6968
}
7069

70+
if ($this->paths || $this->notPaths) {
71+
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
72+
}
73+
7174
if ($this->sort) {
7275
$iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
7376
$iterator = $iteratorAggregate->getIterator();
7477
}
7578

76-
if ($this->paths || $this->notPaths) {
77-
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
78-
}
79-
8079
return $iterator;
8180
}
8281

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,18 @@
1818
*
1919
* @author Alex Bogomazov
2020
*/
21-
abstract class FilterIterator extends \FilterIterator
21+
abstract class FilterIterator extends \FilterIterator implements \RecursiveIterator
2222
{
23+
public function hasChildren()
24+
{
25+
return $this->getInnerIterator() instanceof \RecursiveIterator && $this->getInnerIterator()->hasChildren();
26+
}
27+
28+
public function getChildren()
29+
{
30+
return $this->getInnerIterator()->getChildren();
31+
}
32+
2333
/**
2434
* This is a workaround for the problem with \FilterIterator leaving inner \FilesystemIterator in wrong state after
2535
* rewind in some cases.

0 commit comments

Comments
 (0)
0