Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Finder] Case insensitive file sort#46126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
carsonbot commentedApr 20, 2022
Hey! I see that this is your first PR. That is great! Welcome! Symfony has acontribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
4b9ad93 to5b30852Compare
GromNaN left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks for this very complete PR with tests and docs.
I think we can improve the interface.
Uh oh!
There was an error while loading.Please reload this page.
| * @see SortableIterator | ||
| */ | ||
| publicfunctionsortByName(bool$useNaturalSort =false):static | ||
| publicfunctionsortByName(bool$useNaturalSort =false,bool$useCaseInsensitive =false):static |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
A list of Boolean arguments is not an expressive method signature. Alternatively, I propose that we allow the sort flag to be passed as argument; but I'm not sure our backward compatibility policy allows to modify the type of the 1st argument frombool tobool|int.
Instead, we can add the methodsortByNameCaseInsensitive(bool $useNaturalSort = false) (name to be discussed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thank you for your comments.
I will work on a dedicated sort function and correct the changelog.
Is this method name good enough ?sortByNameCaseInsensitive(bool $useNaturalSort = false) It seems a bit long but it is self explanatory.
How aboutsortByCaseName(bool $useNaturalSort = false) which is closer to the php functionsstrcasecmpandstrnatcasecmp ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
3rd alternative, theFinder::sort() accepts a closure, but could also accept a value from a dedicated Enum.
@symfony/mergers I'm not sure if we can add a 2nd allowed type to an existing argument. From\Closure $arg toMyEnum|\Closure $arg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Meanwhile I have moved the code tosortByCaseName(bool $useNaturalSort = false)
Uh oh!
There was an error while loading.Please reload this page.
| publicfunctionsortByCaseName(bool$useNaturalSort =false):static | ||
| { | ||
| $this->sort =$useNaturalSort ?Iterator\SortableIterator::SORT_BY_NAME_NATURAL_CASE_INSENSITIVE : | ||
| Iterator\SortableIterator::SORT_BY_NAME_CASE_INSENSITIVE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
this should stay on the same line
| CHANGELOG | ||
| ========= | ||
| 6.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
this will likely be 6.2 as we are past the feature freeze for 6.1
Uh oh!
There was an error while loading.Please reload this page.
82d04f6 to2f26995Comparehmoreau commentedApr 27, 2022
I made the change to |
fabpot left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Can you rebase on current 6.2 to eliminate the merge commits (we don't merge PRs with merge commits)?
Uh oh!
There was an error while loading.Please reload this page.
ee5661b to7fdbb61Comparefabpot commentedJul 22, 2022
Thank you@hmoreau. |
hmoreau commentedJul 22, 2022
Thank you@fabpot ,@GromNaN ,@javiereguiluz ,@nicolas-grekas and@stof |
This PR was squashed before being merged into the 6.2 branch.Discussion----------[Finder] Add case insensitive sortAdd a new sortByCaseInsensitiveName() method to have case insensitive sorting results.Like the sortByName(), pass true as its argument to use PHP's case insensitive natural sort order algorithm instead.Related tosymfony/symfony#46126 PRReplace#16735 PRCommits-------df9281f [Finder] Add case insensitive sort
Uh oh!
There was an error while loading.Please reload this page.
Add a second argument$useCaseInsensitive to sortByName() method to select between case sensitive and case insensitive sort.