Bug Report
| Subject |
Details |
| Rector version |
Rector version: 366f32 - released at 2025-10-07 00:20 |
In the example code linked below, ChangeSwitchToMatchRector is converting the switch to a match expression, but ignores that the result is used as a reference. References to expressions are not allowed in PHP.
In the original code $this->monday was set to 100 as expected, but the transformed code produces this:
Notice: Only variable references should be returned by reference in /in/7CEb0 on line 12
\Workload::__set_state(array(
'monday' => 0,
'tuesday' => 0,
))
Minimal PHP Code Causing Issue
https://getrector.com/demo/b0da2130-2499-41b8-9d41-5ba38b657ac3
Expected Behaviour
Rector should skip transforming this code.