Skip to content

ControllerMethodInjectionToConstructorRector ignores DocumentService #9794

Description

@Andrew-Staves-Activ

Bug Report

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

The ControllerMethodInjectionToConstructorRector rule seems to ignore a service named DocumentService.

Minimal PHP Code Causing Issue

https://getrector.com/demo/bdbe963e-9283-4ce7-aca0-75777c24ec33

Expected Behaviour

<?php
 
use App\Service\DocumentService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

 class ExampleController extends AbstractController
 {
+	public function __construct(private readonly DocumentService $documentService)
+	{
+	}
+
-	public function example(DocumentService $documentService): void
+	public function example(): void
	{
-		$documentService->someMethod();
+		$this->documentService->someMethod();
	}
 }

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions