问题
I have noticed a pattern among some of my team's developers where we will do a self-assignment of an array in a foreach loop, and I am looking for the proper search parameters to pass into PhpStorm's structural search to match the first workflow, but not the second in the following example:
public function example()
{
$array = [];
foreach ($array as $a) {
$array[$a] = 1; //Match this one
}
$someOtherVariable = [];
foreach($array as $ab) {
$someOtherVariable[] = 2; //Don't match this one
}
}
The basic structural search foreach($c$){$c$}
matches them both, and I cannot figure out if there is a filter to apply to the variable $c$
such that the interior variable is detected to be the same as the inherited loop variable.
来源:https://stackoverflow.com/questions/62805674/phpstorm-structural-searching-to-find-a-self-assignment-in-a-foreach-loop