Skip to content

Commit 3fbcbd7

Browse files
committed
refactor(support): use first-class callable syntax
1 parent bceb79a commit 3fbcbd7

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/Support/Metadata/Schema/Field/Rule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __toString(): string
3737
if (empty($arguments)) {
3838
return $this->spec->name;
3939
}
40-
$arguments = array_map(fn (mixed $item): string => $this->enforce($item), $arguments);
40+
$arguments = array_map($this->enforce(...), $arguments);
4141
$definition = implode(',', $arguments);
4242
return sprintf('%s:%s', $this->spec->name, $definition);
4343
}
@@ -54,7 +54,7 @@ private function enforce(mixed $item): string
5454
is_iterable($item) => implode(
5555
',',
5656
array_map(
57-
fn ($element): string => $this->enforce($element),
57+
$this->enforce(...),
5858
is_array($item)
5959
? $item
6060
: iterator_to_array($item, false)

src/Support/Payload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function resolve(string $name): mixed
5050
return $value;
5151
}
5252
$keys = array_keys($value);
53-
$filtered = array_filter($keys, fn (mixed $item) => is_string($item));
53+
$filtered = array_filter($keys, is_string(...));
5454
if (count($keys) !== count($filtered)) {
5555
return $value;
5656
}

src/Support/Reflective/Engine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ protected function detectCollectionType(ReflectionClass $collection): ?string
102102
*/
103103
private function joinReflectionTypeNames(array $types, string $separator): string
104104
{
105-
$array = array_map(fn (ReflectionType $type) => $this->formatTypeName($type), $types);
105+
$array = array_map($this->formatTypeName(...), $types);
106106
sort($array);
107107
return implode($separator, $array);
108108
}

src/Support/Set.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(mixed $data = [])
2828
throw new SchemaException('Values must be an array.');
2929
}
3030
$keys = array_keys($data);
31-
$filtered = array_filter($keys, fn (mixed $item) => is_string($item));
31+
$filtered = array_filter($keys, is_string(...));
3232
if (count($keys) !== count($filtered)) {
3333
throw new SchemaException('All keys must be strings.');
3434
}

0 commit comments

Comments
 (0)