Think Build Implement Repeat
London, UK +44 7367 067226
WhatsApp FOLLOW f in X
PHP Development

What to Enforce and What to Leave Alone

Last updated:

Automate the arguments away

Formatting and style are not worth human attention. A formatter applied automatically ends the discussion permanently and frees code review for the things that actually matter.

Any review comment that a tool could have made is a review comment that should have been made by a tool.

The checks worth having

  1. Automatic formatting on commit or in the pipeline
  2. Static analysis at a level the codebase can actually pass
  3. Dependency vulnerability auditing on every build
  4. Tests, run automatically, blocking on failure
  5. Type coverage increasing over time rather than all at once

Static analysis catches real bugs

Type errors, impossible conditions, undefined properties and unreachable code are all found before running anything. On a legacy codebase the first run is usually alarming and usually correct.

  • Start at a level the codebase passes
  • Increase the level gradually, fixing as you go
  • Never suppress a warning without a comment explaining why
  • Run it in the pipeline, not just locally

Review for design, not style

Worth a review commentNot worth it
Is this the right approach?Bracket placement
What happens when this fails?Variable naming preference
Is this tested?Line length
Will the next person understand it?Quote style
Does it handle the edge case?Import ordering

Consistency beats correctness of style

There is no single right way to format PHP. There is enormous value in a codebase where everything looks the same, because it makes unfamiliar code readable.

Pick a standard, automate it, and stop discussing it.

Frequently asked questions

Which coding standard?

One of the established ones. Which matters far less than applying it consistently and automatically.

Should static analysis block deployment?

Yes, once the codebase passes at your chosen level. A check that can be ignored will be ignored.

How do we introduce this to legacy code?

Start at a permissive level, apply to changed files first, and raise the bar gradually. All at once is unworkable.

Is code review necessary for a solo developer?

Automated checks certainly. An occasional external review is worth it, because a second perspective finds things the author cannot see.

Keep reading

Code reviews spent on formatting?

Automate that and the reviews become about design. A day of setup, permanently.

Book a free 30-minute call Get a project estimate WhatsApp us

Related services

What we build for problems like this one

Web DevelopmentCustom Software Development