Skip to content

Commit a1b9842

Browse files
NGSTACK-1017 fix phpstan
1 parent 864a8fe commit a1b9842

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

src/ApiPlatform/Hydra/Serializer/PartialCollectionViewNormalizerDecorator.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use function array_key_exists;
1313
use function is_array;
1414
use function max;
15-
use function method_exists;
1615
use function min;
1716

1817
final class PartialCollectionViewNormalizerDecorator implements NormalizerInterface, NormalizerAwareInterface
@@ -21,7 +20,7 @@ public function __construct(
2120
private readonly NormalizerInterface $decorated,
2221
) {}
2322

24-
/** @param array<mixed> $context */
23+
/** @param array<string, mixed> $context */
2524
public function normalize(mixed $data, ?string $format = null, array $context = []): array|\ArrayObject|bool|float|int|string|null
2625
{
2726
$normalized = $this->decorated->normalize($data, $format, $context);
@@ -45,27 +44,22 @@ public function normalize(mixed $data, ?string $format = null, array $context =
4544
$normalized[$viewKey]['lastPage'] ??= $lastPage;
4645
$normalized[$viewKey]['currentPage'] ??= $currentPage;
4746
$normalized[$viewKey]['previousPage'] ??= max(1, $currentPage - 1);
48-
$normalized[$viewKey]['nextPage'] ??= (int) min($currentPage + 1, $lastPage);
47+
$normalized[$viewKey]['nextPage'] ??= min($currentPage + 1, $lastPage);
4948
$normalized[$viewKey]['itemsPerPage'] ??= (int) $data->getItemsPerPage();
5049

5150
return $normalized;
5251
}
5352

54-
/** @param array<mixed> $context */
53+
/** @param array<string, mixed> $context */
5554
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
5655
{
5756
return $this->decorated->supportsNormalization($data, $format, $context);
5857
}
5958

60-
/** @return array<string, bool>|array<string, null> */
59+
/** @return array<string, bool|null> */
6160
public function getSupportedTypes(?string $format): array
6261
{
63-
if (method_exists($this->decorated, 'getSupportedTypes')) {
64-
/* @var array<string, bool>|array<string, null> $supportedTypes */
65-
return $this->decorated->getSupportedTypes($format);
66-
}
67-
68-
return ['*' => false];
62+
return $this->decorated->getSupportedTypes($format);
6963
}
7064

7165
public function setNormalizer(NormalizerInterface $normalizer): void
@@ -75,7 +69,7 @@ public function setNormalizer(NormalizerInterface $normalizer): void
7569
}
7670
}
7771

78-
/** @return array<string, bool>|array<string, null> */
72+
/** @param array<string, mixed> $context */
7973
private function isCursorPaginationEnabled(array $context): bool
8074
{
8175
$operation = $context['operation'] ?? null;

0 commit comments

Comments
 (0)