Complete strict param type declaration based on route annotation
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
final class SomeController extends Controller
{
/**
* @Route(
* requirements={"number"="\d+"},
* )
*/
- public function detailAction($number)
+ public function detailAction(int $number)
{
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\Symfony\CodeQuality\Rector\ClassMethod\ParamTypeFromRouteRequiredRegexRector;
return RectorConfig::configure()
->withRules([
ParamTypeFromRouteRequiredRegexRector::class,
]);