coding-standards
coding-standards copied to clipboard
Update and review usage of the PSR-2-R PHP coding standard
The HM Coding Standards make use of the external PSR-2-R 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.
One of these breaking changes was to remove the PSR2R.Namespaces.UseInAlphabeticalOrder
rule 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 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?