phpstan / phpstan-symfony

Symfony extension for PHPStan
MIT License
698 stars 89 forks source link

Detection of invalid route names (and perhaps even missing/invalid params) #359

Open Seldaek opened 1 year ago

Seldaek commented 1 year ago

Just a feature idea:

UrlGeneratorInterface::generate as well as proxy methods in the base controller could check if the given route name is part of the defined routes in the application.

When refactoring routes it happens once in a while something gets missed and it occurred to me that PHPStan probably could have saved my ass. If the route is not commonly used it can otherwise go missed for a while until it fails at runtime.

One could even push this further to check param types by looking at the route pattern and what types the linked action require I guess.