Skip to content

Incorrect behavior of RemoveUnusedPromotedPropertyRector, RemoveUnusedPrivatePropertyRector #6822

@alpipego

Description

@alpipego

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.org/demo/1ec4aa74-578d-6c44-b454-a334ad2f1c73

<?php

final class DemoSetting extends AbstractSetting
{
    private PageInterface $page;
    private SectionInterface $section;
    
	public function __construct(PageInterface $page, SectionInterface $section)
    {
        $this->page = $page;
        $this->section = $section;
        
        parent::__construct($page, $section);
    }
    
    public function getPage()
    {
        return $this->page;
    }
}

abstract class AbstractSetting
{
	public function __construct(PageInterface $page, SectionInterface $section)
    {
        // do something with $page and $section
        $page->runSomething();
        $section->runSomething();
    }  
}

Responsible rules

  • RemoveUnusedPromotedPropertyRector

  • RemoveUnusedPrivatePropertyRector

Expected Behavior

Rector should not remove the constructor parameter $section from DemoSetting, since this gets passed to the parent::__construct.

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