-
-
Notifications
You must be signed in to change notification settings - Fork 708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ForeachItemsAssignToEmptyArrayToAssignRector] apply on code it should not #2587
[ForeachItemsAssignToEmptyArrayToAssignRector] apply on code it should not #2587
Conversation
Could add fix as well? |
Again, I might be able to - provided some context. What is this rector rule really about ? What are all the edge cases that might be broken, except the two I had in my code base ? What's the vision for it and how to implement it ? I know nothing of it right now, and as I only have a small amount of time to dedicate to OSS, the better the explanation the greater the chances I can contribute efficiently. :) |
Allright :) I'll try my best. Ask whatever you need to know. The rule is about removing foreach of array, that does basically assign of array: class SomeClass
{
public function run($items)
{
$items2 = [];
- foreach ($items as $item) {
- $items2[] = $item;
- }
+ $items2 = $items;
}
} Everything else should be skipped - those edge-cases you've detected. I'll put comment there |
...r/Foreach_/ForeachItemsAssignToEmptyArrayToAssignRector/Fixture/skip_false_positives.php.inc
Outdated
Show resolved
Hide resolved
09636e8
to
0a64874
Compare
All good! :) Thanks for the help. |
.../Foreach_/ForeachItemsAssignToEmptyArrayToAssignRector/Fixture/skip_false_positive_1.php.inc
Outdated
Show resolved
Hide resolved
Great job, thanks 👍 |
rectorphp/rector-src@d180768 [Core] Apply auto fallback to use Scope from File when Node both doesnot has parent Node and Scope (#2587)
No description provided.