Open
Description
Symfony version(s) affected
v7.1.4
Description
Symfony finder allows the user to manipulate files with /
regardless of environment, but because /
and \
are in different parts of the ASCII table the results of sortByName
are inconsistent depending on platform.
How to reproduce
mkdir('Folder');
touch('FolderBase.php');
touch('Folder/Sub.php');
$files = Symfony\Component\Finder\Finder::create()->files()->in(['Folder'])->append(['FolderBase.php'])->sortByName();
foreach ($files as $file) {
echo (string) $file.PHP_EOL;
}
Possible Solution
Normalize paths in SortableIterator
Additional Context
Linux output:
Folder/Sub.php
FolderBase.php
Windows output:
FolderBase.php
Folder\Sub.php
First reproduced at kint-php/kint#425