@@ -129,8 +129,18 @@ protected function glob($resource, $recursive, &$prefix = null, $ignoreErrors =
129
129
if (false === strpos ($ resource , '/**/ ' ) && (defined ('GLOB_BRACE ' ) || false === strpos ($ resource , '{ ' ))) {
130
130
foreach (glob ($ prefix .$ resource , defined ('GLOB_BRACE ' ) ? GLOB_BRACE : 0 ) as $ path ) {
131
131
if ($ recursive && is_dir ($ path )) {
132
- $ flags = \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS ;
133
- foreach (new \RecursiveIteratorIterator (new \RecursiveDirectoryIterator ($ path , $ flags )) as $ path => $ info ) {
132
+ $ files = iterator_to_array (new \RecursiveIteratorIterator (
133
+ new \RecursiveCallbackFilterIterator (
134
+ new \RecursiveDirectoryIterator ($ path , \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS ),
135
+ function (\SplFileInfo $ file ) { return '. ' !== $ file ->getBasename ()[0 ]; }
136
+ ),
137
+ \RecursiveIteratorIterator::LEAVES_ONLY
138
+ ));
139
+ usort ($ files , function (\SplFileInfo $ a , \SplFileInfo $ b ) {
140
+ return (string ) $ a > (string ) $ b ? 1 : -1 ;
141
+ });
142
+
143
+ foreach ($ files as $ path => $ info ) {
134
144
if ($ info ->isFile ()) {
135
145
yield $ path => $ info ;
136
146
}
@@ -154,7 +164,7 @@ protected function glob($resource, $recursive, &$prefix = null, $ignoreErrors =
154
164
}
155
165
156
166
$ prefixLen = strlen ($ prefix );
157
- foreach ($ finder ->followLinks ()->in ($ prefix ) as $ path => $ info ) {
167
+ foreach ($ finder ->followLinks ()->sortByName ()-> in ($ prefix ) as $ path => $ info ) {
158
168
if (preg_match ($ regex , substr ($ path , $ prefixLen )) && $ info ->isFile ()) {
159
169
yield $ path => $ info ;
160
170
}
0 commit comments