phpinspectionsea
phpinspectionsea copied to clipboard
FalsePositive MissUsingForeachInspection
Subject | Details |
---|---|
Plugin | phpInspectionsUltimate-mp (2021.5) |
Language level | PHP 8.0 |
Current behaviour
MissUsingForeachInspection asks me to use array_values(),
if $hotelCombinationRow->resid
was constant, that could have worked, but as that key is dynamic, it's not posible (as far as I know) to replace this foreach with an array_values().
$hotelCombinationRows = DB::select($query);
foreach ($hotelCombinationRows as $hotelCombinationRow) {
$resor[$hotelCombinationRow->resid]->combinatoins[] = $hotelCombinationRow;
}
Expected behaviour
No MissUsingForeachInspection
Environment details
Information from Help - About dialog
PhpStorm 2022.2 EAP
Build #PS-222.3153.10, built on June 22, 2022
Licensed to PhpStorm EAP user:
Non-Bundled Plugins: com.kalessil.phpStorm.phpInspectionsUltimate-mp (2021.5) de.espend.idea.php.toolbox (6.1.0) de.espend.idea.php.annotation (8.2.1) NEON support (0.5.2) com.jetbrains.plugins.jade (222.3153.10) izhangzhihao.rainbow.brackets (6.25) fr.adrienbrault.idea.symfony2plugin (2022.1.230) ru.adelf.idea.dotenv (2022.2)
I just stumbled upon the same FP with this code:
$result = [];
foreach ($this->elements as $element) {
$result[$element->getType()][] = $element;
}
I doubt that I can just use array_values()
instead, as it's a grouping operation.
Plugin version
com.kalessil.phpStorm.phpInspectionsUltimate-mp (2021.5)
Environment details
PhpStorm 2022.2.1 Build #PS-222.3739.61, built on August 18, 2022 Runtime version: 17.0.3+7-b469.37 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Linux 5.4.0-125-generic GC: G1 Young Generation, G1 Old Generation Memory: 6144M Cores: 8
Current Desktop: ubuntu:GNOME