Skip to content

Incorrect behavior of ControllerMethodInjectionToConstructorRector #9639

@dbannik

Description

@dbannik

Bug Report

Subject Details
Rector version last dev-main
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/6fb8fd61-f7c5-4af9-a1fd-4847ab26da4d

<?php

 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Annotation\Route;

 final class SomeController extends AbstractController
 {
     #[Route('/some-path/{from}/{to}', name: 'some_name')]
     public function someAction(
        \DateTimeImmutable $from,
        \DateTimeImmutable $to,
     ) {
         return $this->render('template.html.twig', ['from' => $from, 'to' => $to]);
     }
 }

Responsible rules

  • ControllerMethodInjectionToConstructorRector

Expected Behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions