Turns fetching of Request via $this->getRequest()
to action injection
+use Symfony\Component\HttpFoundation\Request;
+
class SomeController
{
- public function someAction()
+ public function someAction(Request $request)
{
- $this->getRequest()->...();
+ $request->...();
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\Symfony\Symfony30\Rector\ClassMethod\GetRequestRector;
return RectorConfig::configure()
->withRules([
GetRequestRector::class,
]);