@@ -31,10 +31,13 @@ public function searchInDirectory($dir)
31
31
$ flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS ;
32
32
}
33
33
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 );
38
41
39
42
if ($ this ->minDepth > 0 || $ this ->maxDepth < PHP_INT_MAX ) {
40
43
$ iterator = new Iterator \DepthRangeFilterIterator ($ iterator , $ this ->minDepth , $ this ->maxDepth );
@@ -44,10 +47,6 @@ public function searchInDirectory($dir)
44
47
$ iterator = new Iterator \FileTypeFilterIterator ($ iterator , $ this ->mode );
45
48
}
46
49
47
- if ($ this ->exclude ) {
48
- $ iterator = new Iterator \ExcludeDirectoryFilterIterator ($ iterator , $ this ->exclude );
49
- }
50
-
51
50
if ($ this ->names || $ this ->notNames ) {
52
51
$ iterator = new Iterator \FilenameFilterIterator ($ iterator , $ this ->names , $ this ->notNames );
53
52
}
@@ -68,15 +67,15 @@ public function searchInDirectory($dir)
68
67
$ iterator = new Iterator \CustomFilterIterator ($ iterator , $ this ->filters );
69
68
}
70
69
70
+ if ($ this ->paths || $ this ->notPaths ) {
71
+ $ iterator = new Iterator \PathFilterIterator ($ iterator , $ this ->paths , $ this ->notPaths );
72
+ }
73
+
71
74
if ($ this ->sort ) {
72
75
$ iteratorAggregate = new Iterator \SortableIterator ($ iterator , $ this ->sort );
73
76
$ iterator = $ iteratorAggregate ->getIterator ();
74
77
}
75
78
76
- if ($ this ->paths || $ this ->notPaths ) {
77
- $ iterator = new Iterator \PathFilterIterator ($ iterator , $ this ->paths , $ this ->notPaths );
78
- }
79
-
80
79
return $ iterator ;
81
80
}
82
81
0 commit comments