|
Hello everyone, I don't know how many of you pay close attention to PHPStan's blog and release notes and whether you are running the latest PHPStan version, which is always the best version. This is me making sure you know how awesome our updates have been this year, and what you're missing out on if you're staying on PHPStan 2.2.*, or worse, 2.1.*, or infinitely worse, some version starting with 1 π± So I'm going to pick a few of my favourite features and improvements that will make you feel like you should run composer update phpstan/phpstan or even composer require --dev phpstan/phpstan:^2.3 if you're still on 1.x. In that case don't forget to follow the upgrading guide too. PHPStan got 7.5Γ faster in 2026We've been hard at work improving PHPStan's performance. What took 60 seconds in January 2026 now takes only 8 seconds. The blue line is improvement in plain PHP, from 60 seconds to 20 seconds over the course of 10 months. The orange line is PHPStan Turbo, a native PHP extension that makes PHPStan faster for everyone by additional 60 percent. If you install PHPStan through Composer, the chances are you're already using it. You can read more about Turbo and you can check out commented slides from my presentation about Turbo. But making raw PHPStan performance faster isn't even the whole story. There's also the result cache. If you run PHPStan, then edit a few files, and run PHPStan again, you're not going to wait the same amount of time as before, it's going to be much faster. PHPStan decides which files need to be analysed since the last time it ran, and over the past year we've been making sure it's faster at that too. Auto-fixable rulesPHPStan now tells you with a little π§ icon when a reported error can be fixed automatically by re-running PHPStan with --fix. Some core PHPStan rules already support fixing their reported errors, like the ones that report missing #[Override] attribute. You can also implement automatic fixes in your custom rules. But the feature currently most shines in cleaning up your obsolete ignoreErrors and the baseline. Having PHPStan reporting: Ignored error pattern was not matched in reported errors.
Ignored error pattern is expected to occur 4 times, but occurred only 3 times.
...was always pretty frustrating, I agree with that. But now you can just run --fix and the ignores will be erased and expected counts will be updated. Unsealed array shapesArray shapes are one of the most popular PHPStan features. I guess because arrays are one of the most popular PHP features π You can use them to precisely describe type of each key in arrays flowing through your application: array{foo: int, bar: string} But for a long time you couldn't describe "an array has this specific keys, but it can have more keys of this type". Well since PHPStan 2.2, you can: array{foo: int, bar:string, ... And if you enable Bleeding Edge, all your array shapes by default become sealed. Learn more about unsealed array shapes here. PHPStan for your Twig templatesTry out TwigStan. It runs PHPStan on your Twig templates compiled into PHP and can point out the same useful errors you're used to when running it on (or over? π§) your code. ...and there's much much moreI feel like this email could be almost infinite, there's so much much more, but I have to stop somewhere. I'll add a few more bullet points for you to check out if you're interested:
Don't hesitate to reply to this email and tell me what you thought about it π Until next time, |
PHPStan finds bugs in your code without writing tests. It's open-source and free.