Skip to content

ControllerMethodInjectionToConstructorRector conflates parameters with the same name #9688

@Andrew-Staves-Activ

Description

@Andrew-Staves-Activ

Bug Report

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

When running the ControllerMethodInjectionToConstructorRector rule, Rector conflates parameters with the same name that were originally injecting different services. This results in the wrong service being used.

Minimal PHP Code Causing Issue

See https://getrector.com/demo/2d8eff48-9798-46f7-8b07-ded8716af201

<?php

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class ExampleController extends AbstractController
{
	public function foo(Foo $service): void
	{
		dump($service);
	}

	public function bar(Bar $service): void
	{
		dump($service);
	}
}

Responsible rules

  • ControllerMethodInjectionToConstructorRector

Expected Behaviour

It should skip these cases.

Thanks!

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