rector
rector copied to clipboard
Incorrect behavior of RemoveUnusedVariableAssignRector, RemoveAlwaysElseRector
Bug Report
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.org/demo/2c6bc559-8a6d-4272-988a-83cc5b9d46f8
<?php
class Get
{
private $dummyProperty;
public function __construct()
{
$this->dummyProperty = 1;
}
private function getLowestPriceItem($value): int
{
$newValue = $value + 1;
if ($value > 100) {
return $value;
} else {
return $newValue;
}
}
}
Responsible rules
-
RemoveUnusedVariableAssignRector -
RemoveAlwaysElseRector
Expected Behavior
The variable definition of $newValue will be removed. The Problem only occurs with at least one property assignment in the constructor.