diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ac93686ad..fbc9057a4 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -45,6 +45,56 @@ parameters: count: 1 path: src/metadata-service/src/Denormalizer/ExtensionDescriptorDenormalizer.php + - + message: "#^Method Webauthn\\\\MetadataService\\\\Denormalizer\\\\VerificationMethodANDCombinationsDenormalizer\\:\\:normalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" + count: 1 + path: src/metadata-service/src/Denormalizer/VerificationMethodANDCombinationsDenormalizer.php + + - + message: "#^Method Webauthn\\\\MetadataService\\\\Denormalizer\\\\VerificationMethodANDCombinationsDenormalizer\\:\\:normalize\\(\\) never returns ArrayObject so it can be removed from the return type\\.$#" + count: 1 + path: src/metadata-service/src/Denormalizer/VerificationMethodANDCombinationsDenormalizer.php + + - + message: "#^Method Webauthn\\\\MetadataService\\\\Denormalizer\\\\VerificationMethodANDCombinationsDenormalizer\\:\\:normalize\\(\\) never returns bool so it can be removed from the return type\\.$#" + count: 1 + path: src/metadata-service/src/Denormalizer/VerificationMethodANDCombinationsDenormalizer.php + + - + message: "#^Method Webauthn\\\\MetadataService\\\\Denormalizer\\\\VerificationMethodANDCombinationsDenormalizer\\:\\:normalize\\(\\) never returns float so it can be removed from the return type\\.$#" + count: 1 + path: src/metadata-service/src/Denormalizer/VerificationMethodANDCombinationsDenormalizer.php + + - + message: "#^Method Webauthn\\\\MetadataService\\\\Denormalizer\\\\VerificationMethodANDCombinationsDenormalizer\\:\\:normalize\\(\\) never returns int so it can be removed from the return type\\.$#" + count: 1 + path: src/metadata-service/src/Denormalizer/VerificationMethodANDCombinationsDenormalizer.php + + - + message: "#^Method Webauthn\\\\MetadataService\\\\Denormalizer\\\\VerificationMethodANDCombinationsDenormalizer\\:\\:normalize\\(\\) never returns null so it can be removed from the return type\\.$#" + count: 1 + path: src/metadata-service/src/Denormalizer/VerificationMethodANDCombinationsDenormalizer.php + + - + message: "#^Method Webauthn\\\\MetadataService\\\\Denormalizer\\\\VerificationMethodANDCombinationsDenormalizer\\:\\:normalize\\(\\) never returns string so it can be removed from the return type\\.$#" + count: 1 + path: src/metadata-service/src/Denormalizer/VerificationMethodANDCombinationsDenormalizer.php + + - + message: "#^Method Webauthn\\\\MetadataService\\\\Denormalizer\\\\VerificationMethodANDCombinationsDenormalizer\\:\\:normalize\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/metadata-service/src/Denormalizer/VerificationMethodANDCombinationsDenormalizer.php + + - + message: "#^Method Webauthn\\\\MetadataService\\\\Denormalizer\\\\VerificationMethodANDCombinationsDenormalizer\\:\\:normalize\\(\\) return type with generic class ArrayObject does not specify its types\\: TKey, TValue$#" + count: 1 + path: src/metadata-service/src/Denormalizer/VerificationMethodANDCombinationsDenormalizer.php + + - + message: "#^Method Webauthn\\\\MetadataService\\\\Denormalizer\\\\VerificationMethodANDCombinationsDenormalizer\\:\\:supportsNormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" + count: 1 + path: src/metadata-service/src/Denormalizer/VerificationMethodANDCombinationsDenormalizer.php + - message: "#^Method Webauthn\\\\MetadataService\\\\Psr18HttpClient\\:\\:request\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#" count: 1 diff --git a/src/metadata-service/src/Denormalizer/MetadataStatementSerializerFactory.php b/src/metadata-service/src/Denormalizer/MetadataStatementSerializerFactory.php index e751c8bba..c961ec2f7 100644 --- a/src/metadata-service/src/Denormalizer/MetadataStatementSerializerFactory.php +++ b/src/metadata-service/src/Denormalizer/MetadataStatementSerializerFactory.php @@ -31,6 +31,7 @@ public static function create(): ?SerializerInterface } $denormalizers = [ + new VerificationMethodANDCombinationsDenormalizer(), new ExtensionDescriptorDenormalizer(), new UidNormalizer(), new ArrayDenormalizer(), diff --git a/src/metadata-service/src/Denormalizer/VerificationMethodANDCombinationsDenormalizer.php b/src/metadata-service/src/Denormalizer/VerificationMethodANDCombinationsDenormalizer.php new file mode 100644 index 000000000..89e22f43b --- /dev/null +++ b/src/metadata-service/src/Denormalizer/VerificationMethodANDCombinationsDenormalizer.php @@ -0,0 +1,45 @@ + + */ + public function getSupportedTypes(?string $format): array + { + return [ + VerificationMethodANDCombinations::class => true, + ]; + } + + public function normalize( + mixed $object, + ?string $format = null, + array $context = [] + ): array|string|int|float|bool|ArrayObject|null { + assert($object instanceof VerificationMethodANDCombinations); + + return array_map( + fn ($verificationMethod) => $this->normalizer->normalize($verificationMethod, $format, $context), + $object->verificationMethods + ); + } + + public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool + { + return $data instanceof VerificationMethodANDCombinations; + } +} diff --git a/src/metadata-service/src/Service/MetadataBLOBPayload.php b/src/metadata-service/src/Service/MetadataBLOBPayload.php index 3ab82458d..7a55947eb 100644 --- a/src/metadata-service/src/Service/MetadataBLOBPayload.php +++ b/src/metadata-service/src/Service/MetadataBLOBPayload.php @@ -116,6 +116,18 @@ public static function createFromArray(array $data): self */ public function jsonSerialize(): array { + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); $data = [ 'legalHeader' => $this->legalHeader, 'nextUpdate' => $this->nextUpdate, diff --git a/src/metadata-service/src/Service/MetadataBLOBPayloadEntry.php b/src/metadata-service/src/Service/MetadataBLOBPayloadEntry.php index f1d9011a7..be8653bd6 100644 --- a/src/metadata-service/src/Service/MetadataBLOBPayloadEntry.php +++ b/src/metadata-service/src/Service/MetadataBLOBPayloadEntry.php @@ -210,6 +210,12 @@ public static function createFromArray(array $data): self */ public function jsonSerialize(): array { + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); $data = [ 'aaid' => $this->aaid, 'aaguid' => $this->aaguid, diff --git a/src/metadata-service/src/Statement/AlternativeDescriptions.php b/src/metadata-service/src/Statement/AlternativeDescriptions.php index 228811e08..0baf0f2f4 100644 --- a/src/metadata-service/src/Statement/AlternativeDescriptions.php +++ b/src/metadata-service/src/Statement/AlternativeDescriptions.php @@ -50,6 +50,12 @@ public function add(string $locale, string $description): self */ public function jsonSerialize(): array { + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); return $this->descriptions; } } diff --git a/src/metadata-service/src/Statement/AuthenticatorGetInfo.php b/src/metadata-service/src/Statement/AuthenticatorGetInfo.php index a39f98309..c1360a61b 100644 --- a/src/metadata-service/src/Statement/AuthenticatorGetInfo.php +++ b/src/metadata-service/src/Statement/AuthenticatorGetInfo.php @@ -40,6 +40,12 @@ public function add(string|int $key, mixed $value): self */ public function jsonSerialize(): array { + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); return $this->info; } } diff --git a/src/metadata-service/src/Statement/BiometricAccuracyDescriptor.php b/src/metadata-service/src/Statement/BiometricAccuracyDescriptor.php index 14c0e34d4..916398c82 100644 --- a/src/metadata-service/src/Statement/BiometricAccuracyDescriptor.php +++ b/src/metadata-service/src/Statement/BiometricAccuracyDescriptor.php @@ -74,6 +74,12 @@ public static function createFromArray(array $data): self */ public function jsonSerialize(): array { + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); $data = [ 'selfAttestedFRR' => $this->selfAttestedFRR, 'selfAttestedFAR' => $this->selfAttestedFAR, diff --git a/src/metadata-service/src/Statement/BiometricStatusReport.php b/src/metadata-service/src/Statement/BiometricStatusReport.php index a6b0f3a93..ab5472f82 100644 --- a/src/metadata-service/src/Statement/BiometricStatusReport.php +++ b/src/metadata-service/src/Statement/BiometricStatusReport.php @@ -125,6 +125,12 @@ public static function createFromArray(array $data): self */ public function jsonSerialize(): array { + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); $data = [ 'certLevel' => $this->certLevel, 'modality' => $this->modality, diff --git a/src/metadata-service/src/Statement/CodeAccuracyDescriptor.php b/src/metadata-service/src/Statement/CodeAccuracyDescriptor.php index cb15d7609..62cff9d58 100644 --- a/src/metadata-service/src/Statement/CodeAccuracyDescriptor.php +++ b/src/metadata-service/src/Statement/CodeAccuracyDescriptor.php @@ -77,6 +77,12 @@ public static function createFromArray(array $data): self */ public function jsonSerialize(): array { + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); $data = [ 'base' => $this->base, 'minLength' => $this->minLength, diff --git a/src/metadata-service/src/Statement/DisplayPNGCharacteristicsDescriptor.php b/src/metadata-service/src/Statement/DisplayPNGCharacteristicsDescriptor.php index 202264702..6ffcbdab7 100644 --- a/src/metadata-service/src/Statement/DisplayPNGCharacteristicsDescriptor.php +++ b/src/metadata-service/src/Statement/DisplayPNGCharacteristicsDescriptor.php @@ -184,6 +184,12 @@ public static function createFromArray(array $data): self */ public function jsonSerialize(): array { + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); $data = [ 'width' => $this->width, 'height' => $this->height, diff --git a/src/metadata-service/src/Statement/EcdaaTrustAnchor.php b/src/metadata-service/src/Statement/EcdaaTrustAnchor.php index fd426c13a..0fc307a64 100644 --- a/src/metadata-service/src/Statement/EcdaaTrustAnchor.php +++ b/src/metadata-service/src/Statement/EcdaaTrustAnchor.php @@ -87,6 +87,12 @@ public static function createFromArray(array $data): self */ public function jsonSerialize(): array { + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); $data = [ 'X' => Base64UrlSafe::encodeUnpadded($this->X), 'Y' => Base64UrlSafe::encodeUnpadded($this->Y), diff --git a/src/metadata-service/src/Statement/ExtensionDescriptor.php b/src/metadata-service/src/Statement/ExtensionDescriptor.php index 4b0404367..29333f187 100644 --- a/src/metadata-service/src/Statement/ExtensionDescriptor.php +++ b/src/metadata-service/src/Statement/ExtensionDescriptor.php @@ -94,6 +94,12 @@ public static function createFromArray(array $data): self */ public function jsonSerialize(): array { + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); $result = [ 'id' => $this->id, 'tag' => $this->tag, diff --git a/src/metadata-service/src/Statement/MetadataStatement.php b/src/metadata-service/src/Statement/MetadataStatement.php index d14f1e41f..dd6ccc5b0 100644 --- a/src/metadata-service/src/Statement/MetadataStatement.php +++ b/src/metadata-service/src/Statement/MetadataStatement.php @@ -658,6 +658,12 @@ public static function createFromArray(array $data): self */ public function jsonSerialize(): array { + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); $data = [ 'legalHeader' => $this->legalHeader, 'aaid' => $this->aaid, diff --git a/src/metadata-service/src/Statement/PatternAccuracyDescriptor.php b/src/metadata-service/src/Statement/PatternAccuracyDescriptor.php index 9838e1db2..c151ec6c9 100644 --- a/src/metadata-service/src/Statement/PatternAccuracyDescriptor.php +++ b/src/metadata-service/src/Statement/PatternAccuracyDescriptor.php @@ -65,6 +65,12 @@ public static function createFromArray(array $data): self */ public function jsonSerialize(): array { + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); $data = [ 'minComplexity' => $this->minComplexity, 'maxRetries' => $this->maxRetries, diff --git a/src/metadata-service/src/Statement/RgbPaletteEntry.php b/src/metadata-service/src/Statement/RgbPaletteEntry.php index a2bd1ea32..2ed58cbd5 100644 --- a/src/metadata-service/src/Statement/RgbPaletteEntry.php +++ b/src/metadata-service/src/Statement/RgbPaletteEntry.php @@ -78,6 +78,12 @@ public static function createFromArray(array $data): self */ public function jsonSerialize(): array { + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); return [ 'r' => $this->r, 'g' => $this->g, diff --git a/src/metadata-service/src/Statement/RogueListEntry.php b/src/metadata-service/src/Statement/RogueListEntry.php index bea96c6ad..6624d318e 100644 --- a/src/metadata-service/src/Statement/RogueListEntry.php +++ b/src/metadata-service/src/Statement/RogueListEntry.php @@ -62,6 +62,12 @@ public static function createFromArray(array $data): self */ public function jsonSerialize(): array { + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); return [ 'sk' => $this->sk, 'date' => $this->date, diff --git a/src/metadata-service/src/Statement/StatusReport.php b/src/metadata-service/src/Statement/StatusReport.php index 45b78f6ae..2a8b8377d 100644 --- a/src/metadata-service/src/Statement/StatusReport.php +++ b/src/metadata-service/src/Statement/StatusReport.php @@ -183,6 +183,12 @@ public static function createFromArray(array $data): self */ public function jsonSerialize(): array { + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); $data = [ 'status' => $this->status, 'effectiveDate' => $this->effectiveDate, diff --git a/src/metadata-service/src/Statement/VerificationMethodANDCombinations.php b/src/metadata-service/src/Statement/VerificationMethodANDCombinations.php index 174dcc83a..581d5f596 100644 --- a/src/metadata-service/src/Statement/VerificationMethodANDCombinations.php +++ b/src/metadata-service/src/Statement/VerificationMethodANDCombinations.php @@ -68,6 +68,12 @@ public static function createFromArray(array $data): self */ public function jsonSerialize(): array { + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); return $this->verificationMethods; } } diff --git a/src/metadata-service/src/Statement/VerificationMethodDescriptor.php b/src/metadata-service/src/Statement/VerificationMethodDescriptor.php index 3fb2aeb92..0f2a228cf 100644 --- a/src/metadata-service/src/Statement/VerificationMethodDescriptor.php +++ b/src/metadata-service/src/Statement/VerificationMethodDescriptor.php @@ -255,6 +255,12 @@ public static function createFromArray(array $data): self */ public function jsonSerialize(): array { + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); $data = [ 'userVerificationMethod' => $this->userVerificationMethod, 'caDesc' => $this->caDesc, diff --git a/src/metadata-service/src/Statement/Version.php b/src/metadata-service/src/Statement/Version.php index 8588e6201..f01619cd2 100644 --- a/src/metadata-service/src/Statement/Version.php +++ b/src/metadata-service/src/Statement/Version.php @@ -72,6 +72,12 @@ public static function createFromArray(array $data): self */ public function jsonSerialize(): array { + trigger_deprecation( + 'web-auth/webauthn-bundle', + '4.9.0', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', + __METHOD__ + ); $data = [ 'major' => $this->major, 'minor' => $this->minor, diff --git a/src/symfony/src/Resources/config/services.php b/src/symfony/src/Resources/config/services.php index 7f337d611..340625910 100644 --- a/src/symfony/src/Resources/config/services.php +++ b/src/symfony/src/Resources/config/services.php @@ -49,6 +49,7 @@ use Webauthn\FakeCredentialGenerator; use Webauthn\MetadataService\Denormalizer\ExtensionDescriptorDenormalizer; use Webauthn\MetadataService\Denormalizer\MetadataStatementSerializerFactory; +use Webauthn\MetadataService\Denormalizer\VerificationMethodANDCombinationsDenormalizer; use Webauthn\PublicKeyCredentialLoader; use Webauthn\PublicKeyCredentialSourceRepository; use Webauthn\SimpleFakeCredentialGenerator; @@ -196,6 +197,11 @@ $container ->alias('webauthn.request_factory.default', RequestFactoryInterface::class); + $container + ->set(VerificationMethodANDCombinationsDenormalizer::class) + ->tag('serializer.normalizer', [ + 'priority' => 1024, + ]); $container ->set(ExtensionDescriptorDenormalizer::class) ->tag('serializer.normalizer', [ diff --git a/src/webauthn/src/AttestationStatement/AttestationStatement.php b/src/webauthn/src/AttestationStatement/AttestationStatement.php index 4f3004478..5285de2eb 100644 --- a/src/webauthn/src/AttestationStatement/AttestationStatement.php +++ b/src/webauthn/src/AttestationStatement/AttestationStatement.php @@ -177,7 +177,7 @@ public function jsonSerialize(): array trigger_deprecation( 'web-auth/webauthn-bundle', '4.9.0', - 'The "%s" method is deprecated and will be removed in 5.0. The serializer instead.', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', __METHOD__ ); return [ diff --git a/src/webauthn/src/AttestedCredentialData.php b/src/webauthn/src/AttestedCredentialData.php index 2f5d74f41..cb226a3f5 100644 --- a/src/webauthn/src/AttestedCredentialData.php +++ b/src/webauthn/src/AttestedCredentialData.php @@ -111,7 +111,7 @@ public function jsonSerialize(): array trigger_deprecation( 'web-auth/webauthn-bundle', '4.9.0', - 'The "%s" method is deprecated and will be removed in 5.0. The serializer instead.', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', __METHOD__ ); $result = [ diff --git a/src/webauthn/src/AuthenticationExtensions/AuthenticationExtension.php b/src/webauthn/src/AuthenticationExtensions/AuthenticationExtension.php index 3ed9dc0c9..384476a1e 100644 --- a/src/webauthn/src/AuthenticationExtensions/AuthenticationExtension.php +++ b/src/webauthn/src/AuthenticationExtensions/AuthenticationExtension.php @@ -42,7 +42,7 @@ public function jsonSerialize(): mixed trigger_deprecation( 'web-auth/webauthn-bundle', '4.9.0', - 'The "%s" method is deprecated and will be removed in 5.0. The serializer instead.', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', __METHOD__ ); return $this->value; diff --git a/src/webauthn/src/AuthenticationExtensions/AuthenticationExtensions.php b/src/webauthn/src/AuthenticationExtensions/AuthenticationExtensions.php index 9d7b2bedb..2ef2bc65e 100644 --- a/src/webauthn/src/AuthenticationExtensions/AuthenticationExtensions.php +++ b/src/webauthn/src/AuthenticationExtensions/AuthenticationExtensions.php @@ -112,7 +112,7 @@ public function jsonSerialize(): array trigger_deprecation( 'web-auth/webauthn-bundle', '4.9.0', - 'The "%s" method is deprecated and will be removed in 5.0. The serializer instead.', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', __METHOD__ ); return $this->extensions; diff --git a/src/webauthn/src/AuthenticatorSelectionCriteria.php b/src/webauthn/src/AuthenticatorSelectionCriteria.php index 8e47e92ee..ac794688c 100644 --- a/src/webauthn/src/AuthenticatorSelectionCriteria.php +++ b/src/webauthn/src/AuthenticatorSelectionCriteria.php @@ -232,7 +232,7 @@ public function jsonSerialize(): array trigger_deprecation( 'web-auth/webauthn-bundle', '4.9.0', - 'The "%s" method is deprecated and will be removed in 5.0. The serializer instead.', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', __METHOD__ ); $json = [ diff --git a/src/webauthn/src/PublicKeyCredentialCreationOptions.php b/src/webauthn/src/PublicKeyCredentialCreationOptions.php index d6088e97a..3e1377eb5 100644 --- a/src/webauthn/src/PublicKeyCredentialCreationOptions.php +++ b/src/webauthn/src/PublicKeyCredentialCreationOptions.php @@ -316,7 +316,7 @@ public function jsonSerialize(): array trigger_deprecation( 'web-auth/webauthn-bundle', '4.9.0', - 'The "%s" method is deprecated and will be removed in 5.0. The serializer instead.', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', __METHOD__ ); $json = [ diff --git a/src/webauthn/src/PublicKeyCredentialDescriptor.php b/src/webauthn/src/PublicKeyCredentialDescriptor.php index eac256903..eedddf500 100644 --- a/src/webauthn/src/PublicKeyCredentialDescriptor.php +++ b/src/webauthn/src/PublicKeyCredentialDescriptor.php @@ -110,7 +110,7 @@ public function jsonSerialize(): array trigger_deprecation( 'web-auth/webauthn-bundle', '4.9.0', - 'The "%s" method is deprecated and will be removed in 5.0. The serializer instead.', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', __METHOD__ ); $json = [ diff --git a/src/webauthn/src/PublicKeyCredentialParameters.php b/src/webauthn/src/PublicKeyCredentialParameters.php index 1eab10d57..7ea3cea8f 100644 --- a/src/webauthn/src/PublicKeyCredentialParameters.php +++ b/src/webauthn/src/PublicKeyCredentialParameters.php @@ -86,7 +86,7 @@ public function jsonSerialize(): array trigger_deprecation( 'web-auth/webauthn-bundle', '4.9.0', - 'The "%s" method is deprecated and will be removed in 5.0. The serializer instead.', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', __METHOD__ ); return [ diff --git a/src/webauthn/src/PublicKeyCredentialRequestOptions.php b/src/webauthn/src/PublicKeyCredentialRequestOptions.php index a74d97b38..46b6777d5 100644 --- a/src/webauthn/src/PublicKeyCredentialRequestOptions.php +++ b/src/webauthn/src/PublicKeyCredentialRequestOptions.php @@ -207,7 +207,7 @@ public function jsonSerialize(): array trigger_deprecation( 'web-auth/webauthn-bundle', '4.9.0', - 'The "%s" method is deprecated and will be removed in 5.0. The serializer instead.', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', __METHOD__ ); $json = [ diff --git a/src/webauthn/src/PublicKeyCredentialRpEntity.php b/src/webauthn/src/PublicKeyCredentialRpEntity.php index bb40b5395..670daefae 100644 --- a/src/webauthn/src/PublicKeyCredentialRpEntity.php +++ b/src/webauthn/src/PublicKeyCredentialRpEntity.php @@ -54,7 +54,7 @@ public function jsonSerialize(): array trigger_deprecation( 'web-auth/webauthn-bundle', '4.9.0', - 'The "%s" method is deprecated and will be removed in 5.0. The serializer instead.', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', __METHOD__ ); $json = parent::jsonSerialize(); diff --git a/src/webauthn/src/PublicKeyCredentialSource.php b/src/webauthn/src/PublicKeyCredentialSource.php index ca94d8a5c..2aef84ef0 100644 --- a/src/webauthn/src/PublicKeyCredentialSource.php +++ b/src/webauthn/src/PublicKeyCredentialSource.php @@ -251,7 +251,7 @@ public function jsonSerialize(): array trigger_deprecation( 'web-auth/webauthn-bundle', '4.9.0', - 'The "%s" method is deprecated and will be removed in 5.0. The serializer instead.', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', __METHOD__ ); $result = [ diff --git a/src/webauthn/src/PublicKeyCredentialUserEntity.php b/src/webauthn/src/PublicKeyCredentialUserEntity.php index b5c75ee3f..43cdca2eb 100644 --- a/src/webauthn/src/PublicKeyCredentialUserEntity.php +++ b/src/webauthn/src/PublicKeyCredentialUserEntity.php @@ -90,7 +90,7 @@ public function jsonSerialize(): array trigger_deprecation( 'web-auth/webauthn-bundle', '4.9.0', - 'The "%s" method is deprecated and will be removed in 5.0. The serializer instead.', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', __METHOD__ ); $json = parent::jsonSerialize(); diff --git a/src/webauthn/src/TrustPath/CertificateTrustPath.php b/src/webauthn/src/TrustPath/CertificateTrustPath.php index 5bc39fbf6..31d250c2e 100644 --- a/src/webauthn/src/TrustPath/CertificateTrustPath.php +++ b/src/webauthn/src/TrustPath/CertificateTrustPath.php @@ -59,7 +59,7 @@ public function jsonSerialize(): array trigger_deprecation( 'web-auth/webauthn-bundle', '4.9.0', - 'The "%s" method is deprecated and will be removed in 5.0. The serializer instead.', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', __METHOD__ ); return [ diff --git a/src/webauthn/src/TrustPath/EmptyTrustPath.php b/src/webauthn/src/TrustPath/EmptyTrustPath.php index a91a6121d..e1acb0aba 100644 --- a/src/webauthn/src/TrustPath/EmptyTrustPath.php +++ b/src/webauthn/src/TrustPath/EmptyTrustPath.php @@ -19,7 +19,7 @@ public function jsonSerialize(): array trigger_deprecation( 'web-auth/webauthn-bundle', '4.9.0', - 'The "%s" method is deprecated and will be removed in 5.0. The serializer instead.', + 'The "%s" method is deprecated and will be removed in 5.0. Please use the serializer instead.', __METHOD__ ); return [ diff --git a/tests/MDS/Unit/BiometricAccuracyDescriptorObjectTest.php b/tests/MDS/Unit/BiometricAccuracyDescriptorObjectTest.php index dee6dfd34..92a993480 100644 --- a/tests/MDS/Unit/BiometricAccuracyDescriptorObjectTest.php +++ b/tests/MDS/Unit/BiometricAccuracyDescriptorObjectTest.php @@ -6,15 +6,14 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use PHPUnit\Framework\TestCase; +use Symfony\Component\Serializer\Encoder\JsonEncoder; +use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; use Webauthn\MetadataService\Statement\BiometricAccuracyDescriptor; -use const JSON_THROW_ON_ERROR; -use const JSON_UNESCAPED_SLASHES; /** * @internal */ -final class BiometricAccuracyDescriptorObjectTest extends TestCase +final class BiometricAccuracyDescriptorObjectTest extends MdsTestCase { #[Test] #[DataProvider('validObjectData')] @@ -32,7 +31,9 @@ public function validObject( static::assertSame($maxTemplates, $object->maxTemplates); static::assertSame($maxRetries, $object->maxRetries); static::assertSame($blockSlowdown, $object->blockSlowdown); - static::assertSame($expectedJson, json_encode($object, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES)); + static::assertSame($expectedJson, $this->getSerializer()->serialize($object, JsonEncoder::FORMAT, [ + AbstractObjectNormalizer::SKIP_NULL_VALUES => true, + ])); } public static function validObjectData(): iterable diff --git a/tests/MDS/Unit/CodeAccuracyDescriptorObjectTest.php b/tests/MDS/Unit/CodeAccuracyDescriptorObjectTest.php index bfd100a40..344f0832c 100644 --- a/tests/MDS/Unit/CodeAccuracyDescriptorObjectTest.php +++ b/tests/MDS/Unit/CodeAccuracyDescriptorObjectTest.php @@ -6,15 +6,15 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use PHPUnit\Framework\TestCase; +use Symfony\Component\Serializer\Encoder\JsonEncoder; +use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; use Webauthn\MetadataService\Exception\MetadataStatementLoadingException; use Webauthn\MetadataService\Statement\CodeAccuracyDescriptor; -use const JSON_UNESCAPED_SLASHES; /** * @internal */ -final class CodeAccuracyDescriptorObjectTest extends TestCase +final class CodeAccuracyDescriptorObjectTest extends MdsTestCase { #[Test] #[DataProvider('validObjectData')] @@ -30,7 +30,9 @@ public function validObject( static::assertSame($minLength, $object->minLength); static::assertSame($maxRetries, $object->maxRetries); static::assertSame($blockSlowdown, $object->blockSlowdown); - static::assertSame($expectedJson, json_encode($object, JSON_UNESCAPED_SLASHES)); + static::assertSame($expectedJson, $this->getSerializer()->serialize($object, JsonEncoder::FORMAT, [ + AbstractObjectNormalizer::SKIP_NULL_VALUES => true, + ])); } public static function validObjectData(): iterable diff --git a/tests/MDS/Unit/DisplayPNGCharacteristicsDescriptorTest.php b/tests/MDS/Unit/DisplayPNGCharacteristicsDescriptorTest.php index f64911f8c..e7a9016f6 100644 --- a/tests/MDS/Unit/DisplayPNGCharacteristicsDescriptorTest.php +++ b/tests/MDS/Unit/DisplayPNGCharacteristicsDescriptorTest.php @@ -6,14 +6,13 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use PHPUnit\Framework\TestCase; use Webauthn\MetadataService\Exception\MetadataStatementLoadingException; use Webauthn\MetadataService\Statement\DisplayPNGCharacteristicsDescriptor; /** * @internal */ -final class DisplayPNGCharacteristicsDescriptorTest extends TestCase +final class DisplayPNGCharacteristicsDescriptorTest extends MdsTestCase { #[Test] #[DataProvider('getInvalidValues')] diff --git a/tests/MDS/Unit/MdsTestCase.php b/tests/MDS/Unit/MdsTestCase.php new file mode 100644 index 000000000..681ea97ce --- /dev/null +++ b/tests/MDS/Unit/MdsTestCase.php @@ -0,0 +1,20 @@ +minComplexity); static::assertSame($maxRetries, $object->maxRetries); static::assertSame($blockSlowdown, $object->blockSlowdown); - static::assertSame($expectedJson, json_encode($object, JSON_UNESCAPED_SLASHES)); + static::assertSame($expectedJson, $this->getSerializer()->serialize($object, JsonEncoder::FORMAT, [ + AbstractObjectNormalizer::SKIP_NULL_VALUES => true, + ])); } public static function validObjectData(): iterable diff --git a/tests/MDS/Unit/VerificationMethodANDCombinationsObjectTest.php b/tests/MDS/Unit/VerificationMethodANDCombinationsObjectTest.php index b2f03a02d..84295f4d9 100644 --- a/tests/MDS/Unit/VerificationMethodANDCombinationsObjectTest.php +++ b/tests/MDS/Unit/VerificationMethodANDCombinationsObjectTest.php @@ -6,25 +6,26 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use PHPUnit\Framework\TestCase; +use Symfony\Component\Serializer\Encoder\JsonEncoder; +use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; use Webauthn\MetadataService\Statement\BiometricAccuracyDescriptor; use Webauthn\MetadataService\Statement\CodeAccuracyDescriptor; use Webauthn\MetadataService\Statement\PatternAccuracyDescriptor; use Webauthn\MetadataService\Statement\VerificationMethodANDCombinations; use Webauthn\MetadataService\Statement\VerificationMethodDescriptor; -use const JSON_THROW_ON_ERROR; -use const JSON_UNESCAPED_SLASHES; /** * @internal */ -final class VerificationMethodANDCombinationsObjectTest extends TestCase +final class VerificationMethodANDCombinationsObjectTest extends MdsTestCase { #[Test] #[DataProvider('validObjectData')] public function validObject(VerificationMethodANDCombinations $object, string $expectedJson): void { - static::assertSame($expectedJson, json_encode($object, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES)); + static::assertSame($expectedJson, $this->getSerializer()->serialize($object, JsonEncoder::FORMAT, [ + AbstractObjectNormalizer::SKIP_NULL_VALUES => true, + ])); } public static function validObjectData(): iterable diff --git a/tests/MDS/Unit/VerificationMethodDescriptorObjectTest.php b/tests/MDS/Unit/VerificationMethodDescriptorObjectTest.php index e505671ad..e87862d0a 100644 --- a/tests/MDS/Unit/VerificationMethodDescriptorObjectTest.php +++ b/tests/MDS/Unit/VerificationMethodDescriptorObjectTest.php @@ -6,24 +6,25 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use PHPUnit\Framework\TestCase; +use Symfony\Component\Serializer\Encoder\JsonEncoder; +use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; use Webauthn\MetadataService\Statement\BiometricAccuracyDescriptor; use Webauthn\MetadataService\Statement\CodeAccuracyDescriptor; use Webauthn\MetadataService\Statement\PatternAccuracyDescriptor; use Webauthn\MetadataService\Statement\VerificationMethodDescriptor; -use const JSON_THROW_ON_ERROR; -use const JSON_UNESCAPED_SLASHES; /** * @internal */ -final class VerificationMethodDescriptorObjectTest extends TestCase +final class VerificationMethodDescriptorObjectTest extends MdsTestCase { #[Test] #[DataProvider('validObjectData')] public function validObject(VerificationMethodDescriptor $object, string $expectedJson): void { - static::assertSame($expectedJson, json_encode($object, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES)); + static::assertSame($expectedJson, $this->getSerializer()->serialize($object, JsonEncoder::FORMAT, [ + AbstractObjectNormalizer::SKIP_NULL_VALUES => true, + ])); } public static function validObjectData(): iterable diff --git a/tests/MDS/Unit/VersionObjectTest.php b/tests/MDS/Unit/VersionObjectTest.php index 1de8eab24..7d250b6fe 100644 --- a/tests/MDS/Unit/VersionObjectTest.php +++ b/tests/MDS/Unit/VersionObjectTest.php @@ -6,16 +6,15 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use PHPUnit\Framework\TestCase; +use Symfony\Component\Serializer\Encoder\JsonEncoder; +use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; use Webauthn\MetadataService\Exception\MetadataStatementLoadingException; use Webauthn\MetadataService\Statement\Version; -use const JSON_THROW_ON_ERROR; -use const JSON_UNESCAPED_SLASHES; /** * @internal */ -final class VersionObjectTest extends TestCase +final class VersionObjectTest extends MdsTestCase { #[Test] #[DataProvider('validObjectData')] @@ -23,7 +22,9 @@ public function validObject(Version $object, ?int $major, ?int $minor, string $e { static::assertSame($major, $object->major); static::assertSame($minor, $object->minor); - static::assertSame($expectedJson, json_encode($object, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES)); + static::assertSame($expectedJson, $this->getSerializer()->serialize($object, JsonEncoder::FORMAT, [ + AbstractObjectNormalizer::SKIP_NULL_VALUES => true, + ])); } public static function validObjectData(): iterable