Image for post
Image for post

Strongly-typed object-oriented code helps me tremendously during refactoring. When I realize I need to pass more information from one place to another, I usually take my first step by changing a return typehint, or adding a required parameter to a method. Running PHPStan after making these changes tells me about all the code I need to fix. So I run it many times an hour during my workday. I don’t even check the web app in the browser until PHPStan’s result is green.

To encourage these types of workflows and to generally speed up feedback, I made massive improvements to its performance in the latest release. You can now run PHPStan comfortably as part of Git hooks or manually on your machine, not just in CI pipelines when you decide to submit your branch for a code review at the end of the day. Even on huge codebases consisting of hundreds of thousands lines of code, it finishes the analysis in seconds! …


This is a massive release that has been in the works for the past six months. We’ve managed to churn out minor releases even during the development of this new major version. This continuous workflow was enabled by feature toggles — people were able to try out the new features even while using the stable version by opting in and give feedback.

But I can’t wait for everyone to get their hands on this new version because it’s so much better. And it’s designed so that everyone is able to upgrade to it immediately without breaking a sweat.

If you’re not familiar with PHPStan, it’s a static analyser for PHP focused on finding bugs in your code. It catches whole classes of bugs even before you run your app at all. See the introductory article if you want to know more about the basics! …


Image for post
Image for post

Two years ago I wrote an impactful article on union and intersection types. It helped the PHP community to familiarize themselves with these concepts which eventually led to intersection types support in PhpStorm.

I wrote that article because the differences between unions and intersections are useful and important for static analysis, and developers should be aware of them.

Today I have a similar goal. Generics are coming to PHPStan 0.12 later this week, I want to explain what they’re all about, and get everyone excited.

Infinite number of signatures

When we’re declaring a function, we’re used to attach a single signature to it. There’s no other option. So we declare that the function accepts an argument of a specific type, and also returns a specific…


Martin Hujer published a write-up on how he uses PHPStan to a full extent in a real-world application that combines Symfony Framework with Doctrine ORM and is tested by PHPUnit.

The benefits are clear — if you make PHPStan understand the code that uses a framework with its own conventions, you get additional type safety and discover more bugs this way.

He included all the configuration files you need to make PHPStan sing (and fly!). Check out the article on Martin’s blog:


The fundamental way of how PHPStan handles and accommodates analysis of codebases of varying quality is the concept of rule levels. It allows developers to start using PHPStan on a project right away, and raise the strictness accompanied by a more confident type-safety as they fix the errors.

The usual workflow when introducing PHPStan to the CI pipeline is to get the number of errors reported on level 0 to zero and merge that into the main branch. …


Once a year, new minor PHP version is released, and every few years, there’s a new major version. And as the language moves forward, the tooling that goes with it has to move forward too. That’s why I just released new version of PHPStan in the 0.11.x series (so everyone can upgrade) that fully supports the upcoming new version of PHP.

And today, I also want to talk about PHP 7.4 itself. You’ll see why.

A little recapitulation

Some PHP releases are more substantial than others.

PHP 7.0 was the biggest release of this decade. Huge performance gains that brought PHP on par with HHVM. Scalar typehints. Return typehints. Strict types. Anonymous classes. …


Image for post
Image for post

PHPStan is a static analyser that focuses on finding bugs in your code before you even run it. Its unique extensibility allows it to correctly interpret common magic behavior of PHP like __call(), __set(), __get(), and offer static analysis in areas where it was considered impossible.

Doctrine ORM is a popular library that allows developers to represent data from the database as objects in their application.

Today is the day they are starting to be meant for each other.

I released a new version of phpstan-doctrine extension that shifts developing with Doctrine to a whole new level. …


PHPStan has had a wonderful year 2018. The adoption increased from 3,200 daily downloads to 9,800. I released 9 new versions, wrote a feature article for php[arch] magazine, and talked about PHPStan at Dutch PHP in Amsterdam.

But the moment I realized how big it has become happened at the phpCE conference in Prague at the end of October. I’ve had a really awesome time there. First, I took advantage of many international speakers who contribute to PHPStan coming to town and organized “PHPStan dinner” at my favourite indian restaurant:

Image for post
Image for post
PHPStan dinner with @Ocramius @carusogabriel @msvrtan @lookyman_ @dantleech @JanTvrdik @VasekPurchart #phpce #phpce18 #phpce2018 If they poison our food, PHP is screwed 😂

We’ve had a really good time. Well, except Marco, who spent the next day on the toilet. …


Two months ago, days before the anticipated release of PHPStan 0.10, I talked about it at PHP Prague, a small conference put together by local PHP enthusiasts.

Watch this 🕗15-minute video about the latest features that we’ve added to PHPStan: 👇

You can also check out comprehensive release notes, although I go into a little bit more detail in the video and it’s also easier to digest. Since PHPStan 0.10 was released on June 24th, there has been three point releases:

I plan to stay in the 0.10.x range for at least a few more releases because it’s very stable and promising. But I’ve got a lot of ideas for the future of PHPStan planned and also some great news to share a little bit later this year! Stay tuned!

If you’re a PHP developer, give PHPStan a shot. If you’re interested in various insights about software development, follow me on Twitter.


PHPStan brings me a lot of joy — I love working on it, the community, the positive feedback and the numbers make it worth while. But it comes with a cost — and that is my time.

I've already been experimenting with different monetization options. The most persistent one is Patreon but the funds justify my work on PHPStan for only about one night per month and that would get us nowhere. Of course I'm pouring more time into it but that's not sustainable long term. There are enough burnout stories out there and I want to be careful about it. …

About

Ondřej Mirtes

Author of PHPStan, static analysis tool for finding bugs in code without running it.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store