-
-
Notifications
You must be signed in to change notification settings - Fork 737
Closed
rectorphp/rector-src
#3146Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
| PHP | 7.3 |
Minimal PHP Code Causing Issue
See https://getrector.org/demo/91353eb4-621a-42a9-89f2-a45f7605b514
<?php
class FilterDefaultValue
{
public function filter(array $records, $defaultValue): array
{
$nonDefault = [];
foreach ($records as $key => $value) {
if ($defaultValue !== $value) {
$nonDefault[$key] = $value;
}
}
return $nonDefault;
}
}Responsible rules
SimplifyForeachToArrayFilterRector
Expected Behavior
The refactored code will work with PHP >= 7.4
https://3v4l.org/CHTtV
But for PHP 7.3, which don't support arrow function, the use statement for $defaultValue is missing
https://3v4l.org/1ORPl