Skip to content

Incorrect behavior of RenameMethodRector when using traits #9196

@LordSimal

Description

@LordSimal

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.com/demo/246236c7-2daa-4aad-ba2f-1610d6e0b7f4

<?php

trait MyTrait
{
    public function _test()
    {
	return 'trait';
    }
}

class DemoFile
{
    use MyTrait;
    
    public function _test()
    {
        return 'overwritten';
    }
}

Responsible rules

  • RenameMethodRector

Expected Behavior

Refs: rectorphp/rector-src#6928

In my PR it seems I haven't tested it correctly, since it just renames the methods inside classes which use the trait but not the trait method itself.

I would expect the config to also rename the trait method itself as well

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