Bug Report
| Subject |
Details |
| Rector version |
last master |
| Installed as |
composer dependency |
I tried to run MoveVariableDeclarationNearReferenceRector on my code but had a false positive when a variable is used multiple time in a switch where each case can return. The issue is that the rector moves the variable on the first case so it's undefined later
Minimal PHP Code Causing Issue
public static function get_price($do_trt): array {
- $do_sfe = $do_trt->get_sfe_do();
switch($do_trt->get_mar_do()->get_cod_s()) {
case 'MAR1':
+ $do_sfe = $do_trt->get_sfe_do();
return class1::get_price_all($do_sfe);
case 'MAR2':
return class1::get_price_all($do_sfe);
Expected Behaviour
The variable shouldn't move in this case
Bug Report
I tried to run MoveVariableDeclarationNearReferenceRector on my code but had a false positive when a variable is used multiple time in a switch where each case can return. The issue is that the rector moves the variable on the first case so it's undefined later
Minimal PHP Code Causing Issue
Expected Behaviour
The variable shouldn't move in this case