From 52a3dad099ccc660541438c844d71b8409ba280e Mon Sep 17 00:00:00 2001 From: Florent Morselli Date: Fri, 12 Jul 2024 16:34:39 +0200 Subject: [PATCH] Refactor array filter callbacks in Denormalizers This commit changes the array filter callbacks used in PublicKeyCredentialOptionsDenormalizer and PublicKeyCredentialUserEntityDenormalizer. The old and new conditions ensure that only values that aren't null pass through, whereas previous conditions also checked against empty arrays. The callbacks have also been updated to include return type declarations for better type safety. --- .../src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php | 2 +- .../Denormalizer/PublicKeyCredentialUserEntityDenormalizer.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php b/src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php index 1b59091d..33d229e6 100644 --- a/src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php +++ b/src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php @@ -174,6 +174,6 @@ public function normalize(mixed $data, ?string $format = null, array $context = ]; } - return array_filter($json, static fn ($value) => $value !== null && $value !== []); + return array_filter($json, static fn ($value): bool => $value !== null); } } diff --git a/src/webauthn/src/Denormalizer/PublicKeyCredentialUserEntityDenormalizer.php b/src/webauthn/src/Denormalizer/PublicKeyCredentialUserEntityDenormalizer.php index 275b2548..32e7ca7b 100644 --- a/src/webauthn/src/Denormalizer/PublicKeyCredentialUserEntityDenormalizer.php +++ b/src/webauthn/src/Denormalizer/PublicKeyCredentialUserEntityDenormalizer.php @@ -57,7 +57,7 @@ public function normalize(mixed $data, ?string $format = null, array $context = 'icon' => $data->icon, ]; - return array_filter($normalized, fn ($value) => $value !== null); + return array_filter($normalized, static fn ($value): bool => $value !== null); } public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool