Skip to content

Commit

Permalink
Add sprintf utility usage across multiple classes
Browse files Browse the repository at this point in the history
Introduced `sprintf` function in various classes to improve code consistency and formatting operations. Additionally, minor adjustments were made to PHP versions in workflows and the removal of unnecessary PHPUnit configurations.
  • Loading branch information
Spomky committed Jan 4, 2025
1 parent 3cd37d3 commit 64690c4
Show file tree
Hide file tree
Showing 78 changed files with 178 additions and 42 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ jobs:
- "8.1"
- "8.2"
- "8.3"
dependencies:
- "lowest"
- "highest"
- "8.4"
runs-on: ${{ matrix.operating-system }}
steps:
- name: "Set up PHP"
Expand Down Expand Up @@ -98,7 +96,7 @@ jobs:
operating-system:
- "ubuntu-latest"
php-version:
- "8.2"
- "8.3"
runs-on: ${{ matrix.operating-system }}
steps:
- name: "Set up PHP"
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
"symfony/filesystem": "^6.4|^7.0",
"symfony/finder": "^6.4|^7.0",
"symfony/monolog-bundle": "^3.8",
"symfony/phpunit-bridge": "^6.4|^7.0",
"symfony/var-dumper": "^6.4|^7.0",
"symfony/yaml": "^6.4|^7.0",
"symplify/easy-coding-standard": "^12.0"
Expand Down
25 changes: 25 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2706,6 +2706,11 @@ parameters:
count: 1
path: src/webauthn/src/MetadataService/Service/DistantResourceMetadataService.php

-
message: "#^Property Webauthn\\\\MetadataService\\\\Service\\\\DistantResourceMetadataService\\:\\:\\$serializer \\(Symfony\\\\Component\\\\Serializer\\\\SerializerInterface\\|null\\) is never assigned null so it can be removed from the property type\\.$#"
count: 1
path: src/webauthn/src/MetadataService/Service/DistantResourceMetadataService.php

-
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
count: 1
Expand Down Expand Up @@ -2759,6 +2764,11 @@ parameters:
count: 1
path: src/webauthn/src/MetadataService/Service/FidoAllianceCompliantMetadataService.php

-
message: "#^Property Webauthn\\\\MetadataService\\\\Service\\\\FidoAllianceCompliantMetadataService\\:\\:\\$serializer \\(Symfony\\\\Component\\\\Serializer\\\\SerializerInterface\\|null\\) is never assigned null so it can be removed from the property type\\.$#"
count: 1
path: src/webauthn/src/MetadataService/Service/FidoAllianceCompliantMetadataService.php

-
message: """
#^Call to deprecated method createFromString\\(\\) of class Webauthn\\\\MetadataService\\\\Statement\\\\MetadataStatement\\:
Expand All @@ -2772,6 +2782,11 @@ parameters:
count: 1
path: src/webauthn/src/MetadataService/Service/FolderResourceMetadataService.php

-
message: "#^Property Webauthn\\\\MetadataService\\\\Service\\\\FolderResourceMetadataService\\:\\:\\$serializer \\(Symfony\\\\Component\\\\Serializer\\\\SerializerInterface\\|null\\) is never assigned null so it can be removed from the property type\\.$#"
count: 1
path: src/webauthn/src/MetadataService/Service/FolderResourceMetadataService.php

-
message: """
#^Call to deprecated method createFromString\\(\\) of class Webauthn\\\\MetadataService\\\\Statement\\\\MetadataStatement\\:
Expand All @@ -2780,6 +2795,11 @@ parameters:
count: 1
path: src/webauthn/src/MetadataService/Service/JsonMetadataService.php

-
message: "#^Property Webauthn\\\\MetadataService\\\\Service\\\\JsonMetadataService\\:\\:\\$serializer \\(Symfony\\\\Component\\\\Serializer\\\\SerializerInterface\\|null\\) is never assigned null so it can be removed from the property type\\.$#"
count: 1
path: src/webauthn/src/MetadataService/Service/JsonMetadataService.php

-
message: """
#^Call to deprecated method createFromString\\(\\) of class Webauthn\\\\MetadataService\\\\Statement\\\\MetadataStatement\\:
Expand All @@ -2798,6 +2818,11 @@ parameters:
count: 1
path: src/webauthn/src/MetadataService/Service/LocalResourceMetadataService.php

-
message: "#^Property Webauthn\\\\MetadataService\\\\Service\\\\LocalResourceMetadataService\\:\\:\\$serializer \\(Symfony\\\\Component\\\\Serializer\\\\SerializerInterface\\|null\\) is never assigned null so it can be removed from the property type\\.$#"
count: 1
path: src/webauthn/src/MetadataService/Service/LocalResourceMetadataService.php

-
message: "#^Parameter \\#1 \\$data of static method Webauthn\\\\MetadataService\\\\Service\\\\MetadataBLOBPayloadEntry\\:\\:createFromArray\\(\\) expects array\\<string, mixed\\>, mixed given\\.$#"
count: 1
Expand Down
3 changes: 0 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
<ini name="error_reporting" value="-1"/>
<server name="APP_ENV" value="test" force="true"/>
<server name="SHELL_VERBOSITY" value="-1"/>
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
<server name="SYMFONY_PHPUNIT_VERSION" value="10.1"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/>
<env name="APP_DEBUG" value="true"/>
<server name="KERNEL_CLASS" value="Webauthn\Tests\Bundle\Functional\AppKernel"/>
<ini name="memory_limit" value="-1"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Webauthn\PublicKeyCredentialLoader;
use Webauthn\PublicKeyCredentialSourceRepository;
use Webauthn\PublicKeyCredentialUserEntity;
use function sprintf;

final class AttestationResponseController
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Webauthn\PublicKeyCredentialUserEntity;
use function count;
use function is_array;
use function sprintf;
use const FILTER_VALIDATE_BOOLEAN;

final class ProfileBasedCreationOptionsBuilder implements PublicKeyCredentialCreationOptionsBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Webauthn\PublicKeyCredentialUserEntity;
use function count;
use function is_array;
use function sprintf;

final class ProfileBasedRequestOptionsBuilder implements PublicKeyCredentialRequestOptionsBuilder
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Webauthn\Bundle\Routing\Loader;
use function array_key_exists;
use function sprintf;

final class DynamicRouteCompilerPass implements CompilerPassInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use Webauthn\FakeCredentialGenerator;
use function array_key_exists;
use function assert;
use function sprintf;

final class WebauthnFactory implements FirewallListenerFactoryInterface, AuthenticatorFactoryInterface
{
Expand Down
1 change: 1 addition & 0 deletions src/symfony/src/DependencyInjection/WebauthnExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
use function array_key_exists;
use function count;
use function is_array;
use function sprintf;

final class WebauthnExtension extends Extension implements PrependExtensionInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\DBAL\Types\Type;
use InvalidArgumentException;
use function is_string;
use function sprintf;
use const JSON_THROW_ON_ERROR;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Webauthn\Event\AuthenticatorAssertionResponseValidationFailedEvent as BaseAuthenticatorAssertionResponseValidationFailedEvent;
use Webauthn\PublicKeyCredentialRequestOptions;
use Webauthn\PublicKeyCredentialSource;
use function sprintf;

/**
* @deprecated since 4.3.0, use {@link \Webauthn\Event\AuthenticatorAssertionResponseValidationFailedEvent} instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Webauthn\Event\AuthenticatorAssertionResponseValidationSucceededEvent as BaseAuthenticatorAssertionResponseValidationSucceededEvent;
use Webauthn\PublicKeyCredentialRequestOptions;
use Webauthn\PublicKeyCredentialSource;
use function sprintf;

/**
* @deprecated since 4.3.0, use {@link \Webauthn\Event\AuthenticatorAssertionResponseValidationSucceededEvent} instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Webauthn\AuthenticatorAttestationResponse;
use Webauthn\Event\AuthenticatorAttestationResponseValidationFailedEvent as BaseAuthenticatorAttestationResponseValidationFailedEvent;
use Webauthn\PublicKeyCredentialCreationOptions;
use function sprintf;

/**
* @deprecated since 4.3.0, use {@link \Webauthn\Event\AuthenticatorAttestationResponseValidationFailedEvent} instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Webauthn\Event\AuthenticatorAttestationResponseValidationSucceededEvent as BaseAuthenticatorAttestationResponseValidationSucceededEvent;
use Webauthn\PublicKeyCredentialCreationOptions;
use Webauthn\PublicKeyCredentialSource;
use function sprintf;

/**
* @deprecated since 4.3.0, use {@link \Webauthn\Event\AuthenticatorAttestationResponseValidationSucceededEvent} instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use InvalidArgumentException;
use Webauthn\PublicKeyCredentialSource;
use Webauthn\PublicKeyCredentialUserEntity;
use function sprintf;

/**
* @template T of PublicKeyCredentialSource
Expand Down
1 change: 1 addition & 0 deletions src/symfony/src/Routing/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Symfony\Component\Config\Loader\Loader as SymfonyLoader;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use function sprintf;

class Loader extends SymfonyLoader
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use Webauthn\PublicKeyCredentialRequestOptions;
use Webauthn\PublicKeyCredentialSourceRepository;
use Webauthn\PublicKeyCredentialUserEntity;
use function sprintf;

final class WebauthnAuthenticator implements AuthenticatorInterface, InteractiveAuthenticatorInterface, CanLogData
{
Expand Down
1 change: 1 addition & 0 deletions src/symfony/src/Security/Storage/CacheStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use function sprintf;

final class CacheStorage implements OptionsStorage
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Webauthn\PublicKeyCredentialRequestOptions;
use Webauthn\PublicKeyCredentialSource;
use Webauthn\TokenBinding\TokenBindingHandler;
use function sprintf;

/**
* @deprecated since 4.3.0. The class is deprecated and will be removed in 5.0.0. Please use "Webauthn\AuthenticatorAssertionResponseValidator" instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Webauthn\PublicKeyCredentialCreationOptions;
use Webauthn\PublicKeyCredentialSource;
use Webauthn\TokenBinding\TokenBindingHandler;
use function sprintf;

/**
* @deprecated since 4.3.0. The class is deprecated and will be removed in 5.0.0. Please use "Webauthn\BaseAuthenticatorAttestationResponseValidator" instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use function gettype;
use function is_int;
use function is_string;
use function sprintf;

final class PublicKeyCredentialCreationOptionsFactory implements CanDispatchEvents
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use function gettype;
use function is_int;
use function is_string;
use function sprintf;

final class PublicKeyCredentialRequestOptionsFactory implements CanDispatchEvents
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use function is_array;
use function openssl_pkey_get_public;
use function openssl_verify;
use function sprintf;

final class AndroidKeyAttestationStatementSupport implements AttestationStatementSupport, CanDispatchEvents
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use function is_array;
use function is_int;
use function is_string;
use function sprintf;
use const JSON_THROW_ON_ERROR;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Webauthn\TrustPath\TrustPath;
use Webauthn\TrustPath\TrustPathLoader;
use function array_key_exists;
use function sprintf;

class AttestationStatement implements JsonSerializable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Webauthn\Exception\InvalidDataException;
use function array_key_exists;
use function sprintf;

class AttestationStatementSupportManager
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use function is_array;
use function openssl_pkey_get_public;
use function openssl_verify;
use function sprintf;
use const OPENSSL_ALGO_SHA256;

final class FidoU2FAttestationStatementSupport implements AttestationStatementSupport, CanDispatchEvents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use function is_array;
use function is_int;
use function openssl_verify;
use function sprintf;
use function unpack;

final class TPMAttestationStatementSupport implements AttestationStatementSupport, CanDispatchEvents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use function array_key_exists;
use function count;
use function is_string;
use function sprintf;
use const COUNT_NORMAL;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Webauthn\MetadataService\CanLogData;
use Webauthn\TokenBinding\TokenBindingHandler;
use function is_string;
use function sprintf;

class AuthenticatorAssertionResponseValidator implements CanLogData, CanDispatchEvents
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Webauthn\MetadataService\StatusReportRepository;
use Webauthn\TokenBinding\TokenBindingHandler;
use function is_string;
use function sprintf;

class AuthenticatorAttestationResponseValidator implements CanLogData, CanDispatchEvents
{
Expand Down
3 changes: 2 additions & 1 deletion src/webauthn/src/CeremonyStep/CheckAlgorithm.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use function count;
use function in_array;
use function is_array;
use function sprintf;

class CheckAlgorithm implements CeremonyStep
{
Expand All @@ -33,7 +34,7 @@ public function process(
return;
}
$credentialPublicKey = $publicKeyCredentialSource->getAttestedCredentialData()
->credentialPublicKey;
->credentialPublicKey;
$credentialPublicKey !== null || throw AuthenticatorResponseVerificationException::create(
'No public key available.'
);
Expand Down
1 change: 1 addition & 0 deletions src/webauthn/src/CeremonyStep/CheckMetadataStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Webauthn\TrustPath\CertificateTrustPath;
use function count;
use function in_array;
use function sprintf;

final class CheckMetadataStatement implements CeremonyStep, CanLogData
{
Expand Down
2 changes: 1 addition & 1 deletion src/webauthn/src/CeremonyStep/CheckSignature.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function process(
return;
}
$credentialPublicKey = $publicKeyCredentialSource->getAttestedCredentialData()
->credentialPublicKey;
->credentialPublicKey;
$credentialPublicKey !== null || throw AuthenticatorResponseVerificationException::create(
'No public key available.'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Webauthn\Exception\AuthenticatorResponseVerificationException;
use Webauthn\PublicKeyCredentialOptions;
use function in_array;
use function sprintf;

final class WebauthnAuthenticationCollector implements ClientDataCollector
{
Expand Down
1 change: 1 addition & 0 deletions src/webauthn/src/CollectedClientData.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use function array_key_exists;
use function is_array;
use function is_string;
use function sprintf;
use const JSON_THROW_ON_ERROR;

class CollectedClientData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ public function denormalize(mixed $data, string $type, ?string $format = null, a
);
}

public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool
{
public function supportsDenormalization(
mixed $data,
string $type,
?string $format = null,
array $context = []
): bool {
return $type === AttestationObject::class;
}

Expand Down
Loading

0 comments on commit 64690c4

Please sign in to comment.