Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Level Up Your Code Quality

Level Up Your Code Quality

It's dangerous to go alone! Just as Link was warned and equipped before setting off on his first quest, there are tools that can assist a PHP developer to level up and write better quality code. Join me as I demonstrate a few of these tools and show how easy it is to set them up to work well in a PHP project, regardless of what framework you use.

Joel Clermont

October 16, 2021
Tweet

More Decks by Joel Clermont

Other Decks in Technology

Transcript

  1. Getting started https://github.com/overtrue/phplint • Composer install as dev dependency •

    Ignore .phplint - cache in version control • Setup .phplint.yml con fi guration • What directories to scan • What to ignore, vendor for example • Enable warnings @jclermont
  2. Summary https://github.com/overtrue/phplint @jclermont Setup e ff ort: Easy Risk: None

    Impact on quality: Relatively low Recommendation: Install on every project
  3. Different philosophies • “Tell me to fi x it” versus

    “ fi x it for me” • Local versus remote @jclermont
  4. Getting started https://github.com/squizlabs/PHP_CodeSni ff er • Composer install as dev

    dependency • Pick a standard (I like PSR-12) • Add a few tweaks as needed (slevomat) @jclermont
  5. Summary https://github.com/squizlabs/PHP_CodeSni ff er @jclermont Setup e ff ort: Easy

    (if you’re not too opinionated) Risk: Minimal Impact on quality: Higher than you’d expect Recommendation: Install on every project
  6. Summary https://github.com/sebastianbergmann/phpcpd @jclermont Setup e ff ort: Easy Risk: None

    Impact on quality: Minimal Recommendation: Don’t blindly follow advice
  7. Summary https://phpmd.org @jclermont Setup e ff ort: Easy Risk: None

    Impact on quality: Low Recommendation: Numbers are nice, but aren’t everything
  8. Summary https://phpunit.de @jclermont Setup e ff ort: Depends Risk: Writing

    tests is addictive Impact on quality: To the moon! Recommendation: If you only do one thing, this should be it.
  9. Summary https://phpinsights.com @jclermont Setup e ff ort: Easy Risk: None

    Impact on quality: Pretty good Recommendation: Scores are nice top-level metric
  10. Getting started https://phpstan.org • So many errors to start •

    Establish baseline • Pick a level • Rinse and repeat with new versions of PHPStan @jclermont
  11. Summary https://phpstan.org @jclermont Setup e ff ort: Medium-to-high Risk: Minimal

    Impact on quality: Signi fi cant Recommendation: Even better with tests
  12. Summary https://getrector.org @jclermont Setup e ff ort: Prepare for pain

    Risk: Only your time Impact on quality: Signi fi cant Recommendation: Start with Shift Workbench