Improve explanation

This commit is contained in:
Andrea Marco Sartori 2023-02-05 16:12:33 +10:00
parent f585d2bb64
commit 79656e3f55

View File

@ -30,8 +30,8 @@ expect()->extend('toPointTo', function (array $expected) {
foreach ($this->value as $parsedKey => $parsedValue) {
$itemsCount[$parsedKey] = empty($itemsCount[$parsedKey]) ? 1 : $itemsCount[$parsedKey] + 1;
// the following match is required as we may deal with parsed values that are arrays
// and unpacking a parsed value that is an array may lead to unexpected results
// associate $parsedKey to $parsedValue if $parsedKey occurs once
// associate $parsedKey to an array of $parsedValue if $parsedKey occurs multiple times
$actual[$parsedKey] = match ($itemsCount[$parsedKey]) {
1 => $parsedValue,
2 => [$actual[$parsedKey], $parsedValue],