-
Notifications
You must be signed in to change notification settings - Fork 359
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
Enhancement: Use friendsofphp/php-cs-fixer instead of StyleCI #157
Conversation
9828b61
to
67a4fde
Compare
I agree with this to not be dependant on external. Running it locally is also a big advantage |
👎 here. We are just adding more maintenance for us here. We should stop messing with the code style, and just leave StyleCI to enforce it. Contributors and maintainers alike should not ever be running code style tooling. |
This is an advantage. Nobody should be wasting their time with that. |
Though, StyleCI can be run locally, if really wanted (https://github.com/StyleCI/CLI). |
I prefer to use and run But, I understand your opinion and your argumentation - after all, StyleCI is your pet project. |
{ | ||
"require": { | ||
"php": "^7.1 || ^8.0", | ||
"friendsofphp/php-cs-fixer": "^2.17.2" |
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.
Require-dev?
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.
no
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.
Ah its vendor-bin nvm
I agree with it being more transparant to run php-cs-fixer. The idea of relying on an external service always worries me a bit personally. I don't agree with the fact that developers shouldn't be doing code style. Using editorconfig file, phpstan and php-cs-fixer/StyleCI should be part of the IDE workflow. Adding our own code to commit php-cs-fixer changes in GH Actions feels like too much overhead, though. My opinion is that a PR owner should be responsible for not following code style, not an external service. This should also make the build fail. |
I am also in favor for php-cs-fixer as direct a dev dependency. The PR should be blocked unless everything is green. Changing any code afterwards seems weird to me. I on my part only allow valid code to be merged into the main branch of repositories. So fine my me 👍 |
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.
The code looks fine.
I don't really mind either way. PHP-CS-fixer may have some benefits, but the same is true with StyleCI. If I were to decide, I would have solved this in a third way...
However, I feel like I am a better resource if I focus on code changes.
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.
I would always prefer a Style Checker locally. I want to provide as clean as possible code when pushing to what ever repository.
I think it's important to see the changes done by a code style checker to learn from it. A lot of people just ignores code style, and if the CI does it for you, you will more and more often ignore what code you actually write.
My preferred option is having the phpcs for locally and what ever tool for pipeline taking care of the fixes not already done, but the two tools should follow the exact same ruleset of course.
I see the benefit's of both strategies, but I also prefer using a "native" local tool for the following reasons:
|
Quick heads-up, after merging this pull request, StyleCI applied the following changes: Looks like a failure to me, to apply fixes when a configuration has been removed, and a great example for a violation of the principle of least astonishment as well. |
This is because StyleCI is still enabled on the repo, and uses the default configuration when none is provided. This is what people expect to happen, based on user feedback. The majority of StyleCI users never set any config. |
strategy: | ||
matrix: | ||
php-version: | ||
- 7.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.
Should this be something like 7.4?
I'm late to the party, true.
uses: shivammathur/setup-php@v2 | ||
with: | ||
coverage: none | ||
extensions: intl |
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.
Is intl
required here?
uses: actions/cache@v2 | ||
with: | ||
path: .php_cs.cache | ||
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }} |
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.
composer.lock
will be all new after each composer update, so this cache might not work as expected.
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.
And if we consider vendor-bin
this should be hashFiles('**/composer.*')
}, | ||
"config": { | ||
"platform": { | ||
"php": "7.1.33" |
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.
It this unavoidable?
This PR
friendsof/php-cs-fixer
and removes the integration with StyleCIStyleCI
The integration with StyleCI has the following advantages:
main
.The integration with StyleCI has the following disadvantages:
A developer can not run StyleCI locally.A developer can run StyleCI locally only by installing a separate package, which however, requires PHP 7.2. We currently support PHP 7.1.friendsofphp/php-cs-fixer
under the hood, but adds obscurity on top. For example, it "invents" new fixers that can be enabled or enabled, but are in reality different configurations for existing fixers). Additionally, fixers that are available today infriendsofphp/php-cs-fixer
cannot be configured in StyleCI without delay (if at all). Furthermore, we do not know which version offriendsofphp/php-cs-fixer
is used under the hood.friendsofphp/php-cs-fixer
Requiring
friendsofphp/php-cs-fixer
as a dependency (similar tophpstan/phpstan
andvimeo/psalm
) alleviates all of these problems. We can use and configure any fixers that is available any time we want.If we wanted to automatically apply coding standard issues (similar to StyleCI), we could easily do that with GitHub Actions. However, I would suggest to refrain from it.
In my opinion, a pull request needs to be in mergeable state before merging it into the mainline of development, and this includes coding standard issues.