Skip to content

RemoveUnusedPrivatePropertyRector: removes properties used in trait #1341

@msvrtan

Description

@msvrtan

Given we have a set of classes that use a ExampleTrait that needs ExampleDependency, RemoveUnusedPrivatePropertyRector removes ExampleDependency from Example

class Example{
   use ExampleTrait;
   private $dep;
    public function __constructor(ExampleDependency $dep)
    {
       $this->dep = $dep;
    }
}

trait ExampleTrait{
   
    private function doSomething()
    {
       $this->dep->doWork();
    }
}

would result in

class Example{
   use ExampleTrait;
    public function __constructor(ExampleDependency $dep)
    {
    }
}

and together with RemoveUnusedPrivateMethodRector bug reported in #1334 would result in:

trait ExampleTrait{
   
}

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