Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[Finder] added "use natural sort" option#27024

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

Merged
fabpot merged 1 commit intosymfony:masterfromvyshkant:finder_natural_ordering
May 30, 2018
Merged

[Finder] added "use natural sort" option#27024

fabpot merged 1 commit intosymfony:masterfromvyshkant:finder_natural_ordering
May 30, 2018

Conversation

@vyshkant
Copy link
Contributor

@vyshkantvyshkant commentedApr 23, 2018
edited
Loading

QA
Branch?3.4
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#26930
LicenseMIT
Doc PRsymfony/symfony-docs#9671

Added$useNaturalSort optional argument toFinder::sortByName() method. If it is specified and equals totrue,"natural sort order" algorithm will be applied, which means thatstrnatcmp function will be used instead ofstrcmp (see#26930 for details).

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Almost good, thank you.

* @see SortableIterator
*/
publicfunctionsortByName()
publicfunctionsortByName($naturalOrdering =false)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

for BC concerns, this should be handled usingfunc_num_args()/func_get_arg(0) (adding a new argument breaks child classes).
The signature should then be written assortByName(/* bool $useNaturalOrdering = false */)

Copy link
Member

@javiereguiluzjaviereguiluzApr 24, 2018
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Most of the times"sort" and "order" are interchangeable. However, given that our method is calledsortByName, we use a$this->sort property and PHP calls this "natsort" for "natural sort" ... could we please rename$useNaturalOrdering to$useNaturalSort ?


* deprecated`Symfony\Component\Finder\Iterator\FilterIterator`
* added Finder::hasResults() method to check if any results were found
* added $naturalOrdering option to Finder::sortByName() method

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

$useNaturalOrdering looks more explicit to me

*
* This can be slow as all the matching files and directories must be retrieved for comparison.
*
* @param bool $naturalOrdering Whether to use natural ordering or not

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@param bool $useNaturalOrdering Whether to use natural ordering or not, disabled by default

publicfunctionsortByName($naturalOrdering =false)
{
$this->sort =Iterator\SortableIterator::SORT_BY_NAME;
$this->sort =$naturalOrdering

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

our CS favors single lines, please adjust

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedApr 24, 2018
edited
Loading

New features should target master (aka 4.2)!

@vyshkant
Copy link
ContributorAuthor

New features should target master (aka 4.2)!

@nicolas-grekas So I have to add a message toCHANGELOG.md under 4.2.0 section (not under 4.1.0)?

@nicolas-grekas
Copy link
Member

add a message to CHANGELOG.md under 4.2.0 section

yes please

@vyshkantvyshkant changed the base branch from3.4 tomasterApril 24, 2018 11:55
@vyshkantvyshkant changed the title[Finder] added "natural ordering" sort option[Finder] added "natural sort" optionApr 24, 2018
@vyshkantvyshkant changed the title[Finder] added "natural sort" option[Finder] added "use natural sort" optionApr 24, 2018
publicfunctionsortByName(/* bool $useNaturalSort = false */)
{
$this->sort =Iterator\SortableIterator::SORT_BY_NAME;
$useNaturalSort =1 ===func_num_args() &&true ===func_get_arg(0);
Copy link
Member

@nicolas-grekasnicolas-grekasApr 24, 2018
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'd be a bit more lax here:0 < func_num_args() && func_get_arg(0)

@vyshkant
Copy link
ContributorAuthor

Does anybody have any idea why AppVeyor build has been failed?

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

(failure unrelated)

@fabpot
Copy link
Member

Thank you@vyshkant.

vyshkant reacted with hooray emoji

@fabpotfabpot merged commite697c7d intosymfony:masterMay 30, 2018
fabpot added a commit that referenced this pull requestMay 30, 2018
This PR was merged into the 4.2-dev branch.Discussion----------[Finder] added "use natural sort" option| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#26930| License       | MIT| Doc PR        |symfony/symfony-docs#9671Added `$useNaturalSort` optional argument to `Finder::sortByName()` method. If it is specified and equals to `true`, ["natural sort order" algorithm](https://en.wikipedia.org/wiki/Natural_sort_order) will be applied, which means that `strnatcmp` function will be used instead of `strcmp` (see#26930 for details).Commits-------e697c7d [Finder] added "use natural sort" option
@nicolas-grekasnicolas-grekas modified the milestones:next,4.2Nov 1, 2018
This was referencedNov 3, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@javiereguiluzjaviereguiluzjaviereguiluz left review comments

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

5 participants

@vyshkant@nicolas-grekas@fabpot@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp