Skip to content

Commit

Permalink
ParametersAcceptorSelector - message for ShouldNotHappenException
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jan 9, 2022
1 parent a9881e3 commit d3c3483
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Reflection/ParametersAcceptorSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ public static function selectSingle(
array $parametersAcceptors,
): ParametersAcceptor
{
if (count($parametersAcceptors) !== 1) {
throw new ShouldNotHappenException();
$count = count($parametersAcceptors);
if ($count === 0) {
throw new ShouldNotHappenException(
'getVariants() must return at least one variant.',
);
}
if ($count !== 1) {
throw new ShouldNotHappenException('Multiple variants - use selectFromArgs() instead.');
}

return $parametersAcceptors[0];
Expand Down

0 comments on commit d3c3483

Please sign in to comment.