Skip to content

Commit 2048d43

Browse files
committed
Use method() utility for simpler code.
1 parent 87e652f commit 2048d43

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/Analyzer.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use function Crell\fp\afilter;
88
use function Crell\fp\amap;
99
use function Crell\fp\indexBy;
10+
use function Crell\fp\method;
1011
use function Crell\fp\pipe;
1112

1213
class Analyzer implements ClassAnalyzer
@@ -91,7 +92,7 @@ protected function getDefinitions(array $reflections, callable $deriver): array
9192
// The Reflector interface is insufficient, but getName() is defined
9293
// on all types we care about. This is a reflection API limitation.
9394
// @phpstan-ignore-next-line
94-
indexBy(static fn (\Reflector $r): string => $r->getName()),
95+
indexBy(method('getName')),
9596
amap($deriver),
9697
afilter(static fn (?object $attr): bool => $attr && !($attr instanceof Excludable && $attr->exclude())),
9798
);

src/AttributeParser.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Crell\AttributeUtils;
66

77
use function Crell\fp\firstValue;
8+
use function Crell\fp\method;
89
use function Crell\fp\pipe;
910

1011
class AttributeParser
@@ -26,9 +27,8 @@ public function getAttribute(\Reflector $target, string $name): ?object
2627
*/
2728
public function getAttributes(\Reflector $target, string $name): array
2829
{
29-
return array_map(static fn (\ReflectionAttribute $attrib)
30-
// @phpstan-ignore-next-line
31-
=> $attrib->newInstance(), $target->getAttributes($name, \ReflectionAttribute::IS_INSTANCEOF));
30+
// @phpstan-ignore-next-line.
31+
return array_map(method('newInstance'), $target->getAttributes($name, \ReflectionAttribute::IS_INSTANCEOF));
3232
}
3333

3434
/**

src/TypeDef.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use function Crell\fp\all;
88
use function Crell\fp\any;
9+
use function Crell\fp\method;
910

1011
class TypeDef
1112
{
@@ -96,8 +97,7 @@ protected function parseUnionType(\ReflectionUnionType $type): array
9697

9798
protected function parseIntersectionType(\ReflectionIntersectionType $type): array
9899
{
99-
$translate = static fn (\ReflectionNamedType $innerType): string => $innerType->getName();
100-
return array_map($translate, $type->getTypes());
100+
return array_map(method('getName'), $type->getTypes());
101101
}
102102

103103

0 commit comments

Comments
 (0)