<?php
final class DemoFile
{
private function getOtherValues(): array {
return [];
}
public function getValues(bool $condition): array
{
$values = [];
if ($condition) {
$values[] = 'hello';
}
// Append other values to list.
// FIXME: Rule changes code to overwrite 'hello'.
foreach ($this->getOtherValues() as $value) {
$values[] = $value;
}
return $values;
}
}
Bug Report
Minimal PHP Code Causing Issue
See https://getrector.com/demo/a3014949-2478-48ef-bb13-be09ff14abc4
Responsible rules
ForeachItemsAssignToEmptyArrayToAssignRectorExpected Behavior
I guess in this case Rector should do nothing