Skip to content

Commit

Permalink
Add VerificationMethodANDCombinationsDenormalizer and trigger depreca…
Browse files Browse the repository at this point in the history
…tion messages (#620)

Added `VerificationMethodANDCombinationsDenormalizer` and included in serializer configuration. Also, implemented trigger_deprecation in jsonSerialize methods marking them as deprecated and suggesting the use of the serializer instead. Further method and class modifications are reflected in the phpstan-baseline.neon file.
  • Loading branch information
Spomky authored Jul 7, 2024
1 parent abd4ca4 commit 26ef755
Show file tree
Hide file tree
Showing 44 changed files with 287 additions and 44 deletions.
50 changes: 50 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static function create(): ?SerializerInterface
}

$denormalizers = [
new VerificationMethodANDCombinationsDenormalizer(),
new ExtensionDescriptorDenormalizer(),
new UidNormalizer(),
new ArrayDenormalizer(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

namespace Webauthn\MetadataService\Denormalizer;

use ArrayObject;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Webauthn\MetadataService\Statement\VerificationMethodANDCombinations;
use function assert;

final class VerificationMethodANDCombinationsDenormalizer implements NormalizerInterface, NormalizerAwareInterface
{
use NormalizerAwareTrait;

/**
* @return array<class-string, bool>
*/
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;
}
}
12 changes: 12 additions & 0 deletions src/metadata-service/src/Service/MetadataBLOBPayload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/metadata-service/src/Service/MetadataBLOBPayloadEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
6 changes: 6 additions & 0 deletions src/metadata-service/src/Statement/AuthenticatorGetInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/metadata-service/src/Statement/BiometricStatusReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/metadata-service/src/Statement/CodeAccuracyDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/metadata-service/src/Statement/EcdaaTrustAnchor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
6 changes: 6 additions & 0 deletions src/metadata-service/src/Statement/ExtensionDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/metadata-service/src/Statement/MetadataStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/metadata-service/src/Statement/RgbPaletteEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/metadata-service/src/Statement/RogueListEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/metadata-service/src/Statement/StatusReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/metadata-service/src/Statement/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/symfony/src/Resources/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down
2 changes: 1 addition & 1 deletion src/webauthn/src/AttestedCredentialData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 26ef755

Please sign in to comment.