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

chore: allow php-cs-fixer major version 3 #132

Merged
merged 3 commits into from
Aug 27, 2024

Conversation

phil-davis
Copy link
Contributor

@phil-davis phil-davis commented Aug 27, 2024

Add the ability to use php-cs-fixer major version 3.

Add .php-cs-fixer.dist.php (the settings of php-cs-fixer for major version 3) and put the nullable_type_declaration check into it. This is the main reason for the PR - it makes sure that any of these that will emit deprecation messages in PHP 8.4, are found in CI.

Run cs-fixer on PHP 8.4.
Leave the old cs-fixer still running on PHP 7.1.
And run cs-fixer on every PHP version, to be sure. In CI, composer will choose whether to use major version 2 or 3 of php-cs-fixer.

The newer cs-fixer v3 makes various nice fixes that do not break on PHP 7.1.
The old cs-fixer v2 is happy with the changes, it does not try to change them back - that is nice.

This is only needed for this old release series that still has PHP 7.1 support. We can run both cs-fixer and phpstan (and phpunit) on PHP 7.1 through 8.4. I think that helps give confidence that the code works across that range of PHP versions.

Note: when I forward-port all this stuff to later major releases, I won't need to do all this tweaking because we move to supporting only PHP 7.4 and up.

Similar to:
sabre-io/xml#290
sabre-io/http#243
sabre-io/uri#117

Note: for php-cs-fixer v3 I also had to set:

'blank_line_between_import_groups' => false

Because v2 does it like that, and I couldn't find a way to force v2 to put a blank line between each group of "use" statements.

And define ordered_imports for php-cs-fixer v2, so that it works the way that v3 works.

That is fine for this 5.1 branch - in the later major release branches I won't need to fine-tune "odd" php-cs-fixer rules.
The "odd" rules were only relevant to examples/promise.php - that has ordinary use statements and a use function statement. So there was no "real" run-time code that was impacted.

Copy link

codecov bot commented Aug 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.72%. Comparing base (c832947) to head (162d4c6).
Report is 5 commits behind head on 5.1.

Additional details and impacted files
@@            Coverage Diff            @@
##                5.1     #132   +/-   ##
=========================================
  Coverage     99.72%   99.72%           
  Complexity      118      118           
=========================================
  Files             7        7           
  Lines           365      365           
=========================================
  Hits            364      364           
  Misses            1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@phil-davis phil-davis marked this pull request as ready for review August 27, 2024 10:35
@phil-davis phil-davis requested a review from staabm August 27, 2024 10:35
Copy link
Member

@staabm staabm left a comment

Choose a reason for hiding this comment

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

Lgtm

@phil-davis phil-davis merged commit 3bd2083 into sabre-io:5.1 Aug 27, 2024
11 checks passed
@phil-davis phil-davis deleted the php-cs-fixer-3-for-5.1 branch August 27, 2024 11:12
@phil-davis
Copy link
Contributor Author

Part of issue #123

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.

2 participants