Replace php-cs-fixer with Laravel Pint #2780
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
I've started working with this package, and wanted to take a deeper look at how it's built, so I was reviewing the source. One small thing I came upon was that there was a Composer script that would call
php-cs-fixer fix --allow-risky=yes
. There were two issues:I originally made a PR to address this, but then I realized that the GitHub Actions are set up to use Pint, so I made a change that I think could make contributing easier in the future.
Changes
Add dependency
I added the the
laravel/pint
dependency:Configure Laravel Pint
By default, Pint enforces snake_case method names, which will change:
it_throws_an_exception_when_calling_hasPermissionTo_with_an_invalid_type()
to
it_throws_an_exception_when_calling_has_permission_to_with_an_invalid_type()
The actual name of the method being tested is
hasPermissionTo
, so I added apint.json
with the following:Update Composer script
The
format
script is now defined as:Run Laravel Pint
Finally, I ran
composer format
and let it run through the project.Results
The resulting changes are minimal, and all tests are passing. Running
composer format
should now allow contributors to format their code prior to committing and have the same results as the GitHub Action.