Skip to content

Incorrect behavior of RemoveParentDelegatingConstructorRector #9590

@mvhirsch

Description

@mvhirsch

Bug Report

Subject Details
Rector version v2.3.0
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/57996b15-af81-4b8b-afc1-01690fe4ba79

<?php
final class LivestreamTopicItemsCleaner extends AbstractVideoItemCleaner
{
    public function __construct(private readonly EntityManagerInterface $em, LoggerInterface $logger)
    {
        parent::__construct($em, $logger);
    }
 
    protected function foobar(): array
    {
        $this->em->clear(); // demonstrate usage
    }
}

abstract class AbstractVideoItemCleaner
{
    public function __construct(
        private readonly EntityManagerInterface $em,
        private readonly LoggerInterface $logger,
    ) {
    }
}

Responsible rules

  • RemoveParentDelegatingConstructorRector

Expected Behavior

While I appreciate this change as it raised my attention on this is weirdly defined class (my abstract/base class may defined $em protected instead), I expected no code change at all here.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions