Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Sort options in documentation #7345

Merged
merged 10 commits into from
Oct 12, 2023

Conversation

localheinz
Copy link
Member

@localheinz localheinz commented Sep 29, 2023

This pull request

  • adjusts the FixerConfigurationResolver to keep options sorted by name
  • regenerates the documentation

@localheinz localheinz force-pushed the feature/sort branch 2 times, most recently from 42bf395 to c58b835 Compare September 29, 2023 14:30
@localheinz localheinz marked this pull request as ready for review September 29, 2023 14:37
@localheinz localheinz removed their assignment Sep 29, 2023
@SpacePossum
Copy link
Contributor

SpacePossum commented Oct 4, 2023

Code looks clean and good to me.
I do wonder, options sorted like these:

after_argument_assignments
after_array_assignments_colon
after_array_assignments_equals
around_commas
around_parentheses
before_argument_assignments
before_array_assignments_colon
before_array_assignments_equals
ignored_tags

is that more helpful than lets say:

before_argument_assignments
after_argument_assignments
before_array_assignments_colon
after_array_assignments_colon
before_array_assignments_equals
after_array_assignments_equals
around_commas
around_parentheses
ignored_tags

point could be made that maybe the name could've been better in hindsight

argument_assignments_after
argument_assignments_before
[...]

but yeah, don't know, just wanted to share my thoughts on it

@keradus
Copy link
Member

keradus commented Oct 7, 2023

argument_assignments_after
argument_assignments_before

I like this idea, if it's would also fit on the grammar side (i hope for most cases it would). maybe worth to create a follow up - but it could be bigger effort have all those proxy/deprecated options, for not that big gain.

Without having this in place, I would suggest to keep alpha sorting as simples option

@keradus keradus changed the title feat: Sort options in documentation docs: Sort options in documentation Oct 7, 2023
Copy link
Member

@keradus keradus left a comment

Choose a reason for hiding this comment

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

Like the idea and your own suggestion how to improve further ;)

@localheinz localheinz self-assigned this Oct 9, 2023
@localheinz localheinz marked this pull request as draft October 9, 2023 19:35
@localheinz localheinz force-pushed the feature/sort branch 2 times, most recently from c9e27ee to 62f5847 Compare October 9, 2023 21:09
@localheinz localheinz marked this pull request as ready for review October 9, 2023 21:14
@localheinz
Copy link
Member Author

@keradus @SpacePossum

There are also other options, e.g.

  • max_line_breaks
  • min_line_breaks

where special ordering could make sense.

Comment on lines +33 to -37
'inline_constructor_arguments' => true,
'multi_line_extends_each_single_line' => false,
'single_item_single_line' => false,
'single_line' => false,
'space_before_parenthesis' => false,
'inline_constructor_arguments' => true,
Copy link
Member Author

Choose a reason for hiding this comment

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

@keradus @SpacePossum

As an alternative to this change, I could extract a FixerOptionSorter and use it in both the FixerConfigurationResolver and ClassDefinitionFixerTest::assertSame().

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I think we either have a low-level test that options are always sorted,
or we have a sorter mechanism that is used on that low-level (ref #7345 (comment) )

Copy link
Contributor

Choose a reason for hiding this comment

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

Having a test that checks all options for all fixers seems the way to go for me. Than there is no need to test order of the options @ runtime. (likely in FixerConfigurationResolverTest.php)

There are also other options, e.g.

    max_line_breaks
    min_line_breaks

where special ordering could make sense.

👍 that could be added to the tests, I think I a saw an option called default somewhere as well, maybe it might make sense to have that one as first as well for example. I just thinking out loud here

Copy link
Member Author

Choose a reason for hiding this comment

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

@keradus @SpacePossum

Not sure I understand - would you like me to to make any changes here? If so, which? Thank you!

Copy link
Contributor

Choose a reason for hiding this comment

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

Think keradus has other idea than I ;)
I have no strong opinion on the implementation of this, I think the idea is great!
So I'll leave the implementation details to you two :)

@localheinz localheinz removed their assignment Oct 9, 2023
@coveralls
Copy link

coveralls commented Oct 9, 2023

Coverage Status

coverage: 94.597% (+0.02%) from 94.581% when pulling aa9e14d on localheinz:feature/sort into 0607649 on PHP-CS-Fixer:master.

@@ -65,13 +65,22 @@ public function testWithDuplicateAliasOptions(): void

public function testGetOptions(): void
Copy link
Member

Choose a reason for hiding this comment

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

👍

@localheinz localheinz force-pushed the feature/sort branch 2 times, most recently from 82abf43 to 9443801 Compare October 11, 2023 09:37
Copy link
Member

@keradus keradus left a comment

Choose a reason for hiding this comment

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

please look into failing CI

@keradus keradus merged commit 6d3c3bc into PHP-CS-Fixer:master Oct 12, 2023
15 checks passed
@localheinz localheinz deleted the feature/sort branch October 12, 2023 13:14
@localheinz
Copy link
Member Author

Thank you, @keradus and @SpacePossum!

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.

4 participants