-
-
Notifications
You must be signed in to change notification settings - Fork 741
Closed
rectorphp/rector-src
#3687Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.com/demo/a8c555df-13ab-46b2-abfd-d725cbe72a94
<?php
final class DemoFile
{
/**
* @var string[]
*/
private const VALUES = ['a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e'];
public function run()
{
$arr = [];
foreach (self::VALUES as $key => $value) {
$arr[$value] ??= 0;
$arr[$value] += $key;
}
return $arr;
}
}Responsible rules
ChangeReadOnlyVariableWithDefaultValueToConstantRector
Expected Behavior
Rector shouldn't suggest to convert a local variable into a private const when the local variable is just a temporary one. When the run method is executed twice, the result is not the same.
Reactions are currently unavailable