Skip to content

Commit f8e7b61

Browse files
committed
[DX] Fix message on callable filter returns union or intersection
1 parent 717d56a commit f8e7b61

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Assert/Filter.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ public static function boolean(callable $filter): void
3636

3737
if ($returnType instanceof ReflectionUnionType || $returnType instanceof ReflectionIntersectionType) {
3838
$separator = $returnType instanceof ReflectionUnionType ? '|' : '&';
39+
/** @var ReflectionNamedType[] $types */
40+
$types = $returnType->getTypes();
3941
throw new InvalidArgumentException(
4042
sprintf(
4143
'Expected a bool return type on callable filter, %s given',
4244
implode($separator, array_map(
43-
static fn (ReflectionNamedType $type): string => $type->getName(),
44-
$returnType->getTypes()
45+
static fn (ReflectionNamedType $reflectionNamedType): string => $reflectionNamedType->getName(),
46+
$types
4547
))
4648
)
4749
);

0 commit comments

Comments
 (0)