I have started playing with PHPUnit and am quite perplexed with a foreach statement. I have created a simple function:
public function testForEach(array $x): void {
foreach($x as $k => $v) ; //empty foreach
}
I applied PHPUnit and it says that there are 3 paths in the function. The paths that I know about are:
- The empty array []
- An single item array, e.g. [1]
I tried to input an array with 2 elements [1, 2] and an associative array ['x' => 1], but the tool states that I have found 2 out of three paths. I even tried [1, 2, 3, 4, 5] to no avail.
Does anyone know what the 3rd path is?
If I change the empty statement to a simple echo $x;
, the result is still 3 paths, so it has nothing to do with the empty statement.
Thanks