Symplify form rendering by not calling ->createView()
on render
function
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class ReplaceFormCreateViewFunctionCall extends AbstractController
{
public function form(): Response
{
return $this->render('form.html.twig', [
- 'form' => $form->createView(),
+ 'form' => $form,
]);
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\Symfony\Symfony62\Rector\MethodCall\SimplifyFormRenderingRector;
return RectorConfig::configure()
->withRules([
SimplifyFormRenderingRector::class,
]);