Skip to content

Commit f3b22ba

Browse files
authored
Merge pull request #818 from web-auth/fix/reduce-phpstan-baseline-v3
fix: reduce PHPStan baseline from 82 to 67 errors
1 parent 2ef95e6 commit f3b22ba

File tree

16 files changed

+71
-179
lines changed

16 files changed

+71
-179
lines changed

.ci-tools/phpstan-baseline.neon

Lines changed: 0 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ parameters:
5454
count: 1
5555
path: ../src/symfony/src/Controller/AttestationControllerFactory.php
5656

57-
-
58-
rawMessage: 'Method Webauthn\Bundle\CredentialOptionsBuilder\PublicKeyCredentialCreationOptionsBuilder::getFromRequest() invoked with 3 parameters, 2 required.'
59-
identifier: arguments.count
60-
count: 1
61-
path: ../src/symfony/src/Controller/AttestationRequestController.php
62-
6357
-
6458
rawMessage: '''
6559
Instanceof references deprecated interface Webauthn\Bundle\Repository\CanSaveCredentialSource:
@@ -123,18 +117,6 @@ parameters:
123117
count: 1
124118
path: ../src/symfony/src/CredentialOptionsBuilder/ProfileBasedRequestOptionsBuilder.php
125119

126-
-
127-
rawMessage: 'Method Webauthn\Bundle\DataCollector\WebauthnCollector::getData() return type has no value type specified in iterable type array.'
128-
identifier: missingType.iterableValue
129-
count: 1
130-
path: ../src/symfony/src/DataCollector/WebauthnCollector.php
131-
132-
-
133-
rawMessage: 'Method Webauthn\Bundle\DataCollector\WebauthnCollector::getData() return type has no value type specified in iterable type array|Symfony\Component\VarDumper\Cloner\Data.'
134-
identifier: missingType.iterableValue
135-
count: 1
136-
path: ../src/symfony/src/DataCollector/WebauthnCollector.php
137-
138120
-
139121
rawMessage: '''
140122
Call to deprecated method setSecuredRelyingPartyId() of class Webauthn\Bundle\DependencyInjection\Compiler\CeremonyStepManagerFactoryCompilerPass:
@@ -144,12 +126,6 @@ parameters:
144126
count: 1
145127
path: ../src/symfony/src/DependencyInjection/Compiler/CeremonyStepManagerFactoryCompilerPass.php
146128

147-
-
148-
rawMessage: 'Parameter #1 $value of method Webauthn\Bundle\DependencyInjection\Compiler\PasskeyEndpointsCompilerPass::createUrlDefinition() expects array<string, mixed>|string, array|bool|float|int|string given.'
149-
identifier: argument.type
150-
count: 3
151-
path: ../src/symfony/src/DependencyInjection/Compiler/PasskeyEndpointsCompilerPass.php
152-
153129
-
154130
rawMessage: '''
155131
Access to constant on deprecated interface Webauthn\Bundle\Repository\PublicKeyCredentialSourceRepositoryInterface:
@@ -174,48 +150,6 @@ parameters:
174150
count: 3
175151
path: ../src/symfony/src/DependencyInjection/WebauthnExtension.php
176152

177-
-
178-
rawMessage: Cannot access offset 'types' on mixed.
179-
identifier: offsetAccess.nonOffsetAccessible
180-
count: 2
181-
path: ../src/symfony/src/DependencyInjection/WebauthnExtension.php
182-
183-
-
184-
rawMessage: 'Method Webauthn\Bundle\DependencyInjection\WebauthnExtension::loadControllersSupport() has parameter $config with no value type specified in iterable type array.'
185-
identifier: missingType.iterableValue
186-
count: 1
187-
path: ../src/symfony/src/DependencyInjection/WebauthnExtension.php
188-
189-
-
190-
rawMessage: 'Parameter #2 $config of method Webauthn\Bundle\DependencyInjection\WebauthnExtension::loadCreationControllersSupport() expects array<string, array{options_builder: string|null, profile: string, user_entity_guesser: string, options_storage: string|null, options_handler: string, failure_handler: string, success_handler: string, hide_existing_credentials: bool, ...}>, mixed given.'
191-
identifier: argument.type
192-
count: 1
193-
path: ../src/symfony/src/DependencyInjection/WebauthnExtension.php
194-
195-
-
196-
rawMessage: 'Parameter #2 $config of method Webauthn\Bundle\DependencyInjection\WebauthnExtension::loadRequestControllersSupport() expects array<string, array{options_builder: string|null, profile: string, options_storage: string|null, options_handler: string, failure_handler: string, success_handler: string, options_method: string, options_path: string, ...}>, mixed given.'
197-
identifier: argument.type
198-
count: 1
199-
path: ../src/symfony/src/DependencyInjection/WebauthnExtension.php
200-
201-
-
202-
rawMessage: 'Parameter #1 $value (string|Webauthn\AttestedCredentialData|null) of method Webauthn\Bundle\Doctrine\Type\AttestedCredentialDataType::convertToDatabaseValue() should be contravariant with parameter $value (mixed) of method Doctrine\DBAL\Types\JsonType::convertToDatabaseValue()'
203-
identifier: method.childParameterType
204-
count: 1
205-
path: ../src/symfony/src/Doctrine/Type/AttestedCredentialDataType.php
206-
207-
-
208-
rawMessage: 'Parameter #1 $value (string|Webauthn\PublicKeyCredentialDescriptor|null) of method Webauthn\Bundle\Doctrine\Type\PublicKeyCredentialDescriptorType::convertToDatabaseValue() should be contravariant with parameter $value (mixed) of method Doctrine\DBAL\Types\JsonType::convertToDatabaseValue()'
209-
identifier: method.childParameterType
210-
count: 1
211-
path: ../src/symfony/src/Doctrine/Type/PublicKeyCredentialDescriptorType.php
212-
213-
-
214-
rawMessage: 'Parameter #1 $value (string|Webauthn\TrustPath\TrustPath|null) of method Webauthn\Bundle\Doctrine\Type\TrustPathDataType::convertToDatabaseValue() should be contravariant with parameter $value (mixed) of method Doctrine\DBAL\Types\JsonType::convertToDatabaseValue()'
215-
identifier: method.childParameterType
216-
count: 1
217-
path: ../src/symfony/src/Doctrine/Type/TrustPathDataType.php
218-
219153
-
220154
rawMessage: '''
221155
Class Webauthn\Bundle\Repository\DummyPublicKeyCredentialSourceRepository implements deprecated interface Webauthn\Bundle\Repository\PublicKeyCredentialSourceRepositoryInterface:
@@ -255,42 +189,6 @@ parameters:
255189
count: 1
256190
path: ../src/symfony/src/Security/Authentication/WebauthnBadge.php
257191

258-
-
259-
rawMessage: Class Webauthn\Bundle\Security\Authentication\WebauthnBadge has an uninitialized property $authenticatorResponse. Give it default value or assign it in the constructor.
260-
identifier: property.uninitialized
261-
count: 1
262-
path: ../src/symfony/src/Security/Authentication/WebauthnBadge.php
263-
264-
-
265-
rawMessage: Class Webauthn\Bundle\Security\Authentication\WebauthnBadge has an uninitialized property $publicKeyCredentialOptions. Give it default value or assign it in the constructor.
266-
identifier: property.uninitialized
267-
count: 1
268-
path: ../src/symfony/src/Security/Authentication/WebauthnBadge.php
269-
270-
-
271-
rawMessage: Class Webauthn\Bundle\Security\Authentication\WebauthnBadge has an uninitialized property $publicKeyCredentialSource. Give it default value or assign it in the constructor.
272-
identifier: property.uninitialized
273-
count: 1
274-
path: ../src/symfony/src/Security/Authentication/WebauthnBadge.php
275-
276-
-
277-
rawMessage: Class Webauthn\Bundle\Security\Authentication\WebauthnBadge has an uninitialized property $publicKeyCredentialUserEntity. Give it default value or assign it in the constructor.
278-
identifier: property.uninitialized
279-
count: 1
280-
path: ../src/symfony/src/Security/Authentication/WebauthnBadge.php
281-
282-
-
283-
rawMessage: Class Webauthn\Bundle\Security\Authentication\WebauthnBadge has an uninitialized property $user. Give it default value or assign it in the constructor.
284-
identifier: property.uninitialized
285-
count: 1
286-
path: ../src/symfony/src/Security/Authentication/WebauthnBadge.php
287-
288-
-
289-
rawMessage: 'Webauthn\Bundle\Security\Authentication\WebauthnBadge::__construct() does not call parent constructor from Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge.'
290-
identifier: constructor.missingParentCall
291-
count: 1
292-
path: ../src/symfony/src/Security/Authentication/WebauthnBadge.php
293-
294192
-
295193
rawMessage: '''
296194
Access to deprecated property $name of class Webauthn\PublicKeyCredentialEntity:
@@ -369,36 +267,12 @@ parameters:
369267
count: 1
370268
path: ../src/symfony/src/Security/Http/Authenticator/WebauthnAuthenticator.php
371269

372-
-
373-
rawMessage: Cannot cast mixed to int.
374-
identifier: cast.int
375-
count: 1
376-
path: ../src/webauthn/src/AttestationStatement/AndroidKeyAttestationStatementSupport.php
377-
378-
-
379-
rawMessage: Class Webauthn\AttestationStatement\CompoundAttestationStatementSupport has an uninitialized property $attestationStatementSupportManager. Give it default value or assign it in the constructor.
380-
identifier: property.uninitialized
381-
count: 1
382-
path: ../src/webauthn/src/AttestationStatement/CompoundAttestationStatementSupport.php
383-
384270
-
385271
rawMessage: 'Parameter #2 $attStmt of static method Webauthn\AttestationStatement\AttestationStatement::create() expects array<string, mixed>, list<Webauthn\AttestationStatement\AttestationStatement> given.'
386272
identifier: argument.type
387273
count: 1
388274
path: ../src/webauthn/src/AttestationStatement/CompoundAttestationStatementSupport.php
389275

390-
-
391-
rawMessage: Cannot cast mixed to int.
392-
identifier: cast.int
393-
count: 2
394-
path: ../src/webauthn/src/AttestationStatement/PackedAttestationStatementSupport.php
395-
396-
-
397-
rawMessage: Cannot cast mixed to int.
398-
identifier: cast.int
399-
count: 2
400-
path: ../src/webauthn/src/AttestationStatement/TPMAttestationStatementSupport.php
401-
402276
-
403277
rawMessage: '''
404278
Instanceof references deprecated class Webauthn\PublicKeyCredentialSource:
@@ -672,18 +546,6 @@ parameters:
672546
count: 1
673547
path: ../src/webauthn/src/MetadataService/Psr18HttpClient.php
674548

675-
-
676-
rawMessage: 'Return type (array<array<string>>) of method Symfony\Contracts\HttpClient\ResponseInterface@anonymous/webauthn/src/MetadataService/Psr18HttpClient.php:84::getHeaders() should be covariant with return type (array<string, list<string>>) of method Symfony\Contracts\HttpClient\ResponseInterface::getHeaders()'
677-
identifier: method.childReturnType
678-
count: 1
679-
path: ../src/webauthn/src/MetadataService/Psr18HttpClient.php
680-
681-
-
682-
rawMessage: 'Parameter &$rootCertificates by-ref type of method Webauthn\MetadataService\Service\FidoAllianceCompliantMetadataService::getJwsPayload() expects array<string>, array<mixed, mixed> given.'
683-
identifier: parameterByRef.type
684-
count: 1
685-
path: ../src/webauthn/src/MetadataService/Service/FidoAllianceCompliantMetadataService.php
686-
687549
-
688550
rawMessage: '''
689551
Fetching deprecated class constant AUTHENTICATOR_TRANSPORT_CABLE of class Webauthn\PublicKeyCredentialDescriptor:

src/symfony/src/CredentialOptionsBuilder/PublicKeyCredentialCreationOptionsBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ interface PublicKeyCredentialCreationOptionsBuilder
1313
public function getFromRequest(
1414
Request $request,
1515
PublicKeyCredentialUserEntity $userEntity,
16-
/*bool $hideExistingExcludedCredentials = false*/
16+
bool $hideExistingExcludedCredentials = false,
1717
): PublicKeyCredentialCreationOptions;
1818
}

src/symfony/src/DataCollector/WebauthnCollector.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,14 @@ public function collect(Request $request, Response $response, ?Throwable $except
7373
];
7474
}
7575

76+
/**
77+
* @return array<string, mixed>|Data
78+
*/
7679
public function getData(): array|Data
7780
{
78-
return $this->data;
81+
/** @var array<string, mixed>|Data $data */
82+
$data = $this->data;
83+
return $data;
7984
}
8085

8186
public function getName(): string

src/symfony/src/DependencyInjection/Compiler/PasskeyEndpointsCompilerPass.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ public function process(ContainerBuilder $container): void
3838

3939
private function createPasskeyEndpointsResponse(ContainerBuilder $container): void
4040
{
41+
/** @var string|array<string, mixed>|null $enroll */
4142
$enroll = $container->getParameter('webauthn.passkey_endpoints.enroll');
43+
/** @var string|array<string, mixed>|null $manage */
4244
$manage = $container->getParameter('webauthn.passkey_endpoints.manage');
45+
/** @var string|array<string, mixed>|null $prfUsageDetails */
4346
$prfUsageDetails = $container->getParameter('webauthn.passkey_endpoints.prf_usage_details');
4447

4548
// Create Url definitions from string configuration

src/symfony/src/DependencyInjection/WebauthnExtension.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function prepend(ContainerBuilder $container): void
140140
if (! is_array($config)) {
141141
return;
142142
}
143-
/** @var array<string, class-string> $types */
143+
/** @var array{dbal?: array{types?: array<string, class-string>}} $config */
144144
$types = $config['dbal']['types'] ?? [];
145145
$types += [
146146
'attested_credential_data' => DbalType\AttestedCredentialDataType::class,
@@ -170,14 +170,21 @@ private function getDoctrineBundleConfiguration(ContainerBuilder $container): ?a
170170
return count($configs) === 0 ? null : current($configs);
171171
}
172172

173+
/**
174+
* @param array{enabled: bool, creation?: array<string, mixed>, request?: array<string, mixed>} $config
175+
*/
173176
private function loadControllersSupport(ContainerBuilder $container, array $config): void
174177
{
175178
if ($config['enabled'] === false) {
176179
return;
177180
}
178181

179-
$this->loadCreationControllersSupport($container, $config['creation'] ?? []);
180-
$this->loadRequestControllersSupport($container, $config['request'] ?? []);
182+
/** @var array<string, array{options_builder: string|null, profile: string, user_entity_guesser: string, options_storage: string|null, options_handler: string, failure_handler: string, success_handler: string, hide_existing_credentials: bool, options_method: string, options_path: string, result_method: string, result_path: string|null, host: string|null, secured_rp_ids: array<string>}> $creation */
183+
$creation = $config['creation'] ?? [];
184+
/** @var array<string, array{options_builder: string|null, profile: string, options_storage: string|null, options_handler: string, failure_handler: string, success_handler: string, options_method: string, options_path: string, result_method: string, result_path: string|null, host: string|null, secured_rp_ids: array<string>}> $request */
185+
$request = $config['request'] ?? [];
186+
$this->loadCreationControllersSupport($container, $creation);
187+
$this->loadRequestControllersSupport($container, $request);
181188
}
182189

183190
/**

src/symfony/src/Doctrine/Type/AttestedCredentialDataType.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44

55
namespace Webauthn\Bundle\Doctrine\Type;
66

7+
use function assert;
78
use Doctrine\DBAL\Platforms\AbstractPlatform;
89
use Doctrine\DBAL\Types\JsonType;
10+
use function is_string;
911
use Webauthn\AttestedCredentialData;
1012

1113
final class AttestedCredentialDataType extends JsonType
1214
{
1315
use SerializerTrait;
1416

15-
/**
16-
* @param AttestedCredentialData|string|null $value
17-
*/
18-
public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
17+
public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?string
1918
{
2019
if (! $value instanceof AttestedCredentialData) {
20+
assert($value === null || is_string($value));
2121
return $value;
2222
}
2323

src/symfony/src/Doctrine/Type/PublicKeyCredentialDescriptorType.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44

55
namespace Webauthn\Bundle\Doctrine\Type;
66

7+
use function assert;
78
use Doctrine\DBAL\Platforms\AbstractPlatform;
89
use Doctrine\DBAL\Types\JsonType;
10+
use function is_string;
911
use Webauthn\PublicKeyCredentialDescriptor;
1012

1113
final class PublicKeyCredentialDescriptorType extends JsonType
1214
{
1315
use SerializerTrait;
1416

15-
/**
16-
* @param PublicKeyCredentialDescriptor|string|null $value
17-
*/
18-
public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
17+
public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?string
1918
{
2019
if (! $value instanceof PublicKeyCredentialDescriptor) {
20+
assert($value === null || is_string($value));
2121
return $value;
2222
}
2323

src/symfony/src/Doctrine/Type/TrustPathDataType.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44

55
namespace Webauthn\Bundle\Doctrine\Type;
66

7+
use function assert;
78
use Doctrine\DBAL\Platforms\AbstractPlatform;
89
use Doctrine\DBAL\Types\JsonType;
10+
use function is_string;
911
use Webauthn\TrustPath\TrustPath;
1012

1113
final class TrustPathDataType extends JsonType
1214
{
1315
use SerializerTrait;
1416

15-
/**
16-
* @param TrustPath|string|null $value
17-
*/
18-
public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
17+
public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?string
1918
{
2019
if (! $value instanceof TrustPath) {
20+
assert($value === null || is_string($value));
2121
return $value;
2222
}
2323

0 commit comments

Comments
 (0)