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 ea1deff

Browse filesBrowse files
[Config] Sort "globbed" paths to make them predictable
1 parent 0413e18 commit ea1deff
Copy full SHA for ea1deff

File tree

1 file changed

+13
-3
lines changed
Filter options

1 file changed

+13
-3
lines changed

‎src/Symfony/Component/Config/Loader/FileLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Loader/FileLoader.php
+13-3Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

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