Replies: 4 comments 4 replies
-
An interesting article on the subject: https://www.jackfranklin.co.uk/blog/letting-tools-make-choices/ |
Beta Was this translation helpful? Give feedback.
-
I completely agree with you. Default config (marketed as "opinionated coding style") was one of the pillars of Laravel Pint's success. I believe PER-CS v2 should be default configuration to apply, but:
I think we should create milestone for that, create all necessary issues in it, and then deliver 😉. Or one issue with checklist, whatever - anything that can help with tracking the progress. |
Beta Was this translation helpful? Give feedback.
-
I was also thinking to have some kind of "wizard", which would be autosuggesting the rulesets (eg which PHP? ok, so this ruleset. using phpnit? maybe want to use the set for it too" etc) |
Beta Was this translation helpful? Give feedback.
-
Why would it be incompatible? It would be new feature, not conflicting with how Fixer works currently. Right now configuration file is required to run it, so people who currently use Fixer have config file in place (so it will work exactly the same). For new projects it would just run with default config and creating config file would totally override it. Maybe you considered config should extend default config, and yes, then it would be breaking change because people's config would have different base for resolving final rule set. But we could introduce this strategy in v4 (or configurable strategy: choose between starting from scratch or extending default config). In any case, I see it as totally possible in v3 without BC break 🙂. |
Beta Was this translation helpful? Give feedback.
-
PHP-CS-Fixer is an excellent tool that has helped to create a consistent code style across projects and reduce unnecessary bike shedding over ultimately unimportant details. Thank you!
However, I think it could take one step further and ship with more opinionated defaults.
The success of tools such as prettier, gofmt and black suggest that projects appreciate these opinionated tools.
PHP-CS-Fixer currently ships with a relatively small amount of defaults and leaves the rest up to end users to configure. This configuration shifts the bike shedding from a code style document to a configuration file. Today, if projects choose to use the defaults, many aspects of code formatting remain untouched by PHP-CS-Fixer such as extra blank lines between statements, unused
use
statements,use
statement ordering, and many more. If PHP-CS-Fixer were to ship more opinionated defaults, projects may be more willing to simply accept these defaults and avoid the need to waste time deciding which rules to accept and configure.Beyond helping individual projects avoid bike shedding, I think it would also help the wider PHP community. If the opinionated defaults were to become commonly accepted, more PHP projects would use a similar or identical code style. Contributors would easily switch from project to project with less friction as they wouldn't need to think or research the individual project's preferred style. In my experience, this has been the case for other languages and communities.
One potential approach would be to change the default configuration to
@Phpcsfixer
or to introduce a new@default
group of options with all style options turned on.This suggestion isn't to remove the ability to configure PHP-CS-Fixer only to change from a small amount of defaults to an opinionated set.
I recognize that this would be considered a backwards incompatible change, so it might be best to only consider when releasing a new major version.
I also recognize that this suggestion may be controversial or not accepted and that is fine, not a big deal, but thought I'd throw this idea out there. Either way, thank you!
Beta Was this translation helpful? Give feedback.
All reactions