Skip to content

[5.6] FileSystem returns files and directories sorted by name - #23387

Merged
taylorotwell merged 1 commit into
laravel:5.6from
jamesggordon:filesystem-sort-files-by-name
Mar 5, 2018
Merged

[5.6] FileSystem returns files and directories sorted by name#23387
taylorotwell merged 1 commit into
laravel:5.6from
jamesggordon:filesystem-sort-files-by-name

Conversation

@jamesggordon

Copy link
Copy Markdown
Contributor

A change made last year to version 5.5 changed the behavior of the FileSystem files() method:

0665f95#diff-3aea724aa0501a58dc0f933de2be07e7

Previously files() would return the list of files in alphabetical order. Since that change, the returned array is no longer sorted alphabetically by name. As the returned object is an array of SplFileSystem objects, sorting the result set in userland isn't as simple as just calling sort(). However, sorting the result set inside the FileSystem class is dead easy.

Many developers may prefer the FileSystem class to return arrays of things sorted by name, as per the original behavior. At the very least it seems like a nice convenience that shouldn't negatively impact anybody who doesn't need this behavior.

@sisve

sisve commented Mar 5, 2018

Copy link
Copy Markdown
Contributor

Would this need any tests so that it stays this way?

@taylorotwell
taylorotwell merged commit c34164f into laravel:5.6 Mar 5, 2018
@GrahamCampbell GrahamCampbell changed the title FileSystem returns files and directories sorted by name [5.6] FileSystem returns files and directories sorted by name Mar 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants