@@ -129,8 +129,18 @@ protected function glob($resource, $recursive, &$prefix = null, $ignoreErrors =
129129 if (false === strpos ($ resource , '/**/ ' ) && (defined ('GLOB_BRACE ' ) || false === strpos ($ resource , '{ ' ))) {
130130 foreach (glob ($ prefix .$ resource , defined ('GLOB_BRACE ' ) ? GLOB_BRACE : 0 ) as $ path ) {
131131 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 ) {
134144 if ($ info ->isFile ()) {
135145 yield $ path => $ info ;
136146 }
@@ -154,7 +164,7 @@ protected function glob($resource, $recursive, &$prefix = null, $ignoreErrors =
154164 }
155165
156166 $ prefixLen = strlen ($ prefix );
157- foreach ($ finder ->followLinks ()->in ($ prefix ) as $ path => $ info ) {
167+ foreach ($ finder ->followLinks ()->sortByName ()-> in ($ prefix ) as $ path => $ info ) {
158168 if (preg_match ($ regex , substr ($ path , $ prefixLen )) && $ info ->isFile ()) {
159169 yield $ path => $ info ;
160170 }
0 commit comments