humanmade / humanmade/coding-standards

Update and review usage of the PSR-2-R PHP coding standard

Open
#245 0 comments 0 reactions 1 assignee Claimed by @tfrommen View on GitHub
enhancement phpcs
Dominant language
PHP
Stars
160
Forks
17
PR merge metrics
No merged PRs in 30d

Description

The HM Coding Standards make use of the external [PSR-2-R](https://github.com/php-fig-rectified/psr2r-sniffer) standard. There are some issues with this.

Currently, we are using the following three rules as part of the HM standard:

- `PSR2R.ControlStructures.NoInlineAssignment`
- `PSR2R.Namespaces.UnusedUseStatement`
- `PSR2R.Namespaces.UseInAlphabeticalOrder`

Our current version constraint for this standard is `^0.5.0`. Since this is a non-stable version (i.e., below 1.0.0), the caret notation will be treated differently, and actually only allow for patch-level updates. This means anything up to, but not including 0.6.0.

Now, there have been quite a few updates—to be precise: **7**—that we will never see with our current constraint. Some of these releases include breaking changes, and the current version is (stable) [1.0.1](https://github.com/php-fig-rectified/psr2r-sniffer/releases/tag/1.0.1).

One of these breaking changes was to [remove the `PSR2R.Namespaces.UseInAlphabeticalOrder` rule](https://github.com/php-fig-rectified/psr2r-sniffer/commit/3f602977f4eb9cb1c2bfadeef0f0131ee15986fb) as it was conflicting with other tooling such as IDE (as it was technically incorrectly implemented). We should **remove this rule from our standard**.

Then, I was wondering why we are currently only using these three select rules. Overall, [the PSR-2-R standard looks pretty solid](https://github.com/php-fig-rectified/fig-rectified-standards/blob/master/PSR-2-R-coding-style-guide.md) to me, and should be very much in line with everything we already do or want to do.

I see the following items to discuss and action:

- [ ] Remove the `PSR2R.Namespaces.UseInAlphabeticalOrder` rule from the HM standard.
- [ ] Review the PSR-2-R standard for any breaking changes in the rules we use.
- [ ] Update the PSR-2-R standard by specifying the `^1.0` version constraint.
- [ ] Address or document all breaking changes, if any.
- [ ] Consider adding more/all of the PSR-2-R standard to the `HM` standard.
- [ ] Consider adding select PSR-2-R rules to `HM-Minimum`, where this makes sense and is in line with what this standard is about (e.g., security, performance, error prevention, but **no** formatting etc.).

Any thoughts on any of the above?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.