Skip to content

Commit

Permalink
prevent CollectionTrait::combine keypath being used with non-backed e…
Browse files Browse the repository at this point in the history
…nums
  • Loading branch information
LordSimal committed Jan 5, 2024
1 parent b886c3a commit 1d3fa10
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CollectionTrait.php
Expand Up @@ -40,6 +40,7 @@
use OuterIterator;
use RecursiveIteratorIterator;
use Traversable;
use UnitEnum;
use const SORT_ASC;
use const SORT_DESC;
use const SORT_NUMERIC;
Expand Down Expand Up @@ -615,6 +616,8 @@ public function combine(

if ($mapKey instanceof BackedEnum) {
$mapKey = $mapKey->value;
} elseif ($mapKey instanceof UnitEnum) {
throw new InvalidArgumentException('Cannot index by path on a non-backed enum.');
}

$mapReduce->emit($rowVal($value, $key), $mapKey);
Expand Down

0 comments on commit 1d3fa10

Please sign in to comment.