Writing your own custom PHPStan rules
Description
If you're using tools like PHPStan on your projects, you'll already be reaping the benefits. However, are you using them to their full potential?
Do you have conventions on your project that you have to remember, either when writing or during code review? (E.g. a certain object should only be built by a factory. Or a method should only be used for testing.) Do you wish you could automate the checking of these conventions so they'd never be forgotten?
Or do you wish PHP had features other languages had, e.g. Java's package visibility modifier?
The great news is that PHPStan allows you to write your own custom rules to enforce all kinds of conventions or new language features.
This tutorial will guide you through the basics of writing your own rules for PHPStan. We'll create several rules together, and by the end of the session, you'll be able to start writing your own rules.
Preparations
Clone the repo and complete the setup documented in the README: https://github.com/DaveLiddament/phpstan-rules-tutorial