logo

Why we don't use return types on controller actions

But we do like return types in general!

Joel Clermont
Joel Clermont
2025-11-21

I find a lot of value in static analysis tools like PHPStan, that will analyze your code and find potential issues before they happen at runtime.

But there's one place in our applications where we avoid using return types, even though we like them in general: controller actions.

In today's video, I walk you through my reasoning for this decision, and why I think it's the right call.

Watch Now (4 min)

And after watching, don't forget to subscribe to our YouTube channel, so you don't miss future videos.

Here to help,

Joel

P.S. Want help setting up PHPStan in your project? We've done it many times, and can get you set up quickly.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
email
No spam. Only real-world advice you can use.