Skip to content

Incorrect behavior of AddParamBasedOnParentClassMethodRector #9223

@sbdfh

Description

@sbdfh

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.com/demo/c4c1b0c6-74f7-4487-ab78-a7943e090797

<?php

trait DemoTrait {
    private array $values = [];
    
	public function addValue(int $value) {
    	$this->values[] = $value;    
    }
}

trait DefaultDemoTrait {
    use DemoTrait {
        addValue as addAnyValue;
    }
    
    public function addValue() {
        $this->addAnyValue(0);
    }
}

Responsible rules

  • AddParamBasedOnParentClassMethodRector

Expected Behavior

I think Rector should not modify this code. Traits are about composition and not inheritance. It is totally legitimate to rename (and then "overwrite") a method when a trait uses another trait.

Unless there is something I am completely missing here?

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