Skip to main content

This is a past event. Join us for the next Web Summer Camp.

PHP Workshop Duration: 4h

Writing your own custom PHPStan rules

Dave Liddament
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
 

Speaker
Dave Liddament

Dave Liddament

Director @ Lamp Bristol
Director and developer. Dave has been writing software commercially for over 20 years in many languages including C, Python, Java and PHP. Organizer of PHP-SW. Speaker. Author of an open source tool SARB. Creator of the PHP Language extension library.

To make this website run properly and to improve your experience, we use cookies. For more detailed information, please check our Cookie Policy.

  • Necessary cookies enable core functionality. The website cannot function properly without these cookies, and can only be disabled by changing your browser preferences.