Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DeadCode] Handle RemoveUnusedConstructorParamRector + RemoveUnusedPrivatePropertyRector #1714

Merged
merged 5 commits into from
Jan 22, 2022

Conversation

samsonasik
Copy link
Member

Given the following code:

final class DoNotRemoveParameterInMiddle
{
    private $propertyA;
    private $propertyB;
    private $propertyC;

    public function __construct($propertyA, $propertyB, $propertyC)
    {
        $this->propertyA = $propertyA;
        $this->propertyB = $propertyB;
        $this->propertyC = $propertyC;
    }

    public function run()
    {
        echo $this->propertyA;
        echo $this->propertyC;
    }
}

It currently produce:

 final class DoNotRemoveParameterInMiddle
 {
     private $propertyA;
-    private $propertyB;
     private $propertyC;
 
-    public function __construct($propertyA, $propertyB, $propertyC)
+    public function __construct($propertyA, $propertyC)
     {
         $this->propertyA = $propertyA;
-        $this->propertyB = $propertyB;
         $this->propertyC = $propertyC;
     }

which middle parameter is removed, and cause a BC break. The middle parameter should not be deleted.

Applied rules:

Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector;
Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector;

@samsonasik
Copy link
Member Author

Fixed 🎉

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@TomasVotruba TomasVotruba merged commit 081958a into main Jan 22, 2022
@TomasVotruba TomasVotruba deleted the do-not-remove-parameter-middle branch January 22, 2022 15:55
@TomasVotruba
Copy link
Member

Thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants