From c50396a2c5cd5c9f94f27f001c29f0a85a73be81 Mon Sep 17 00:00:00 2001 From: jiannei Date: Tue, 3 Jan 2023 11:42:52 +0800 Subject: [PATCH] fix: league\fractal array serializer --- src/Support/Serializers/ArraySerializer.php | 6 +++--- src/Support/Serializers/SimpleArraySerializer.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Support/Serializers/ArraySerializer.php b/src/Support/Serializers/ArraySerializer.php index 992c4c0..948c9cb 100644 --- a/src/Support/Serializers/ArraySerializer.php +++ b/src/Support/Serializers/ArraySerializer.php @@ -20,11 +20,11 @@ class ArraySerializer extends FractalArraySerializer /** * Serialize a collection. * - * @param string $resourceKey + * @param string|null $resourceKey * @param array $data * @return array */ - public function collection($resourceKey, array $data) + public function collection(?string $resourceKey, array $data):array { $paginationDataField = Config::get('response.format.fields.data.fields.data.alias', 'data'); @@ -37,7 +37,7 @@ public function collection($resourceKey, array $data) * @param PaginatorInterface $paginator * @return array */ - public function paginator(PaginatorInterface $paginator) + public function paginator(PaginatorInterface $paginator): array { $currentPage = (int) $paginator->getCurrentPage(); $lastPage = (int) $paginator->getLastPage(); diff --git a/src/Support/Serializers/SimpleArraySerializer.php b/src/Support/Serializers/SimpleArraySerializer.php index 9c6e466..1a3bb0b 100644 --- a/src/Support/Serializers/SimpleArraySerializer.php +++ b/src/Support/Serializers/SimpleArraySerializer.php @@ -16,11 +16,11 @@ class SimpleArraySerializer extends ArraySerializer /** * Serialize a collection. * - * @param string $resourceKey + * @param string|null $resourceKey * @param array $data * @return array */ - public function collection($resourceKey, array $data) + public function collection(?string $resourceKey, array $data):array { return $data; }