1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MadWizard\WebAuthn\Builder; |
4
|
|
|
|
5
|
|
|
use Closure; |
6
|
|
|
use GuzzleHttp\Client; |
7
|
|
|
use MadWizard\WebAuthn\Attestation\AttestationType; |
8
|
|
|
use MadWizard\WebAuthn\Attestation\Registry\AttestationFormatRegistry; |
9
|
|
|
use MadWizard\WebAuthn\Attestation\Registry\AttestationFormatRegistryInterface; |
10
|
|
|
use MadWizard\WebAuthn\Attestation\TrustAnchor\TrustPathValidator; |
11
|
|
|
use MadWizard\WebAuthn\Attestation\TrustAnchor\TrustPathValidatorInterface; |
12
|
|
|
use MadWizard\WebAuthn\Attestation\Verifier\AndroidKeyAttestationVerifier; |
13
|
|
|
use MadWizard\WebAuthn\Attestation\Verifier\AndroidSafetyNetAttestationVerifier; |
14
|
|
|
use MadWizard\WebAuthn\Attestation\Verifier\FidoU2fAttestationVerifier; |
15
|
|
|
use MadWizard\WebAuthn\Attestation\Verifier\NoneAttestationVerifier; |
16
|
|
|
use MadWizard\WebAuthn\Attestation\Verifier\PackedAttestationVerifier; |
17
|
|
|
use MadWizard\WebAuthn\Attestation\Verifier\TpmAttestationVerifier; |
18
|
|
|
use MadWizard\WebAuthn\Cache\CacheProviderInterface; |
19
|
|
|
use MadWizard\WebAuthn\Cache\FileCacheProvider; |
20
|
|
|
use MadWizard\WebAuthn\Config\RelyingParty; |
21
|
|
|
use MadWizard\WebAuthn\Config\RelyingPartyInterface; |
22
|
|
|
use MadWizard\WebAuthn\Credential\CredentialStoreInterface; |
23
|
|
|
use MadWizard\WebAuthn\Exception\ConfigurationException; |
24
|
|
|
use MadWizard\WebAuthn\Exception\UnsupportedException; |
25
|
|
|
use MadWizard\WebAuthn\Extension\AppId\AppIdExtension; |
26
|
|
|
use MadWizard\WebAuthn\Extension\ExtensionInterface; |
27
|
|
|
use MadWizard\WebAuthn\Extension\ExtensionRegistry; |
28
|
|
|
use MadWizard\WebAuthn\Extension\ExtensionRegistryInterface; |
29
|
|
|
use MadWizard\WebAuthn\Metadata\MetadataResolver; |
30
|
|
|
use MadWizard\WebAuthn\Metadata\MetadataResolverInterface; |
31
|
|
|
use MadWizard\WebAuthn\Metadata\NullMetadataResolver; |
32
|
|
|
use MadWizard\WebAuthn\Metadata\Provider\FileProvider; |
33
|
|
|
use MadWizard\WebAuthn\Metadata\Provider\MetadataServiceProvider; |
34
|
|
|
use MadWizard\WebAuthn\Metadata\Source\MetadataServiceSource; |
35
|
|
|
use MadWizard\WebAuthn\Metadata\Source\MetadataSourceInterface; |
36
|
|
|
use MadWizard\WebAuthn\Metadata\Source\StatementDirectorySource; |
37
|
|
|
use MadWizard\WebAuthn\Pki\ChainValidator; |
38
|
|
|
use MadWizard\WebAuthn\Pki\ChainValidatorInterface; |
39
|
|
|
use MadWizard\WebAuthn\Policy\Policy; |
40
|
|
|
use MadWizard\WebAuthn\Policy\PolicyInterface; |
41
|
|
|
use MadWizard\WebAuthn\Policy\Trust\TrustDecisionManager; |
42
|
|
|
use MadWizard\WebAuthn\Policy\Trust\TrustDecisionManagerInterface; |
43
|
|
|
use MadWizard\WebAuthn\Policy\Trust\Voter\AllowEmptyMetadataVoter; |
44
|
|
|
use MadWizard\WebAuthn\Policy\Trust\Voter\SupportedAttestationTypeVoter; |
45
|
|
|
use MadWizard\WebAuthn\Policy\Trust\Voter\TrustAttestationTypeVoter; |
46
|
|
|
use MadWizard\WebAuthn\Policy\Trust\Voter\TrustChainVoter; |
47
|
|
|
use MadWizard\WebAuthn\Policy\Trust\Voter\UndesiredStatusReportVoter; |
48
|
|
|
use MadWizard\WebAuthn\Remote\CachingClientFactory; |
49
|
|
|
use MadWizard\WebAuthn\Remote\Downloader; |
50
|
|
|
use MadWizard\WebAuthn\Remote\DownloaderInterface; |
51
|
|
|
use MadWizard\WebAuthn\Server\ServerInterface; |
52
|
|
|
use MadWizard\WebAuthn\Server\WebAuthnServer; |
53
|
|
|
use Psr\Log\LoggerAwareInterface; |
54
|
|
|
use Psr\Log\LoggerInterface; |
55
|
|
|
use Psr\Log\NullLogger; |
56
|
|
|
|
57
|
|
|
final class ServerBuilder |
58
|
|
|
{ |
59
|
|
|
/** |
60
|
|
|
* @var RelyingParty|null |
61
|
|
|
*/ |
62
|
|
|
private $rp; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @var CredentialStoreInterface|null |
66
|
|
|
*/ |
67
|
|
|
private $store; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @var string|null; |
71
|
|
|
*/ |
72
|
|
|
private $cacheDir; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @var callable|PolicyCallbackInterface|null |
76
|
|
|
*/ |
77
|
|
|
private $policyCallback; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @var MetadataSourceInterface[] |
81
|
|
|
*/ |
82
|
|
|
private $metadataSources = []; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @var LoggerInterface|null |
86
|
|
|
*/ |
87
|
|
|
private $logger; |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @var bool |
91
|
|
|
*/ |
92
|
|
|
private $allowNoneAttestation = true; |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @var bool |
96
|
|
|
*/ |
97
|
|
|
private $allowSelfAttestation = true; |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @var bool |
101
|
|
|
*/ |
102
|
|
|
private $trustWithoutMetadata = true; |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @var bool |
106
|
|
|
*/ |
107
|
|
|
private $useMetadata = true; |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @var bool |
111
|
|
|
*/ |
112
|
|
|
private $strictSupportedFormats = false; |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @var string[] |
116
|
|
|
*/ |
117
|
|
|
private $enabledExtensions = []; |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @var ExtensionInterface[] |
121
|
|
|
*/ |
122
|
|
|
private $customExtensions = []; |
123
|
|
|
|
124
|
|
|
private const SUPPORTED_EXTENSIONS = [ |
125
|
|
|
'appid' => AppIdExtension::class, |
126
|
|
|
]; |
127
|
|
|
|
128
|
18 |
|
public function __construct() |
129
|
|
|
{ |
130
|
18 |
|
} |
131
|
|
|
|
132
|
18 |
|
public function setRelyingParty(RelyingParty $rp): self |
133
|
|
|
{ |
134
|
18 |
|
$this->rp = $rp; |
135
|
18 |
|
return $this; |
136
|
|
|
} |
137
|
|
|
|
138
|
18 |
|
public function setCredentialStore(CredentialStoreInterface $store): self |
139
|
|
|
{ |
140
|
18 |
|
$this->store = $store; |
141
|
18 |
|
return $this; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
public function setCacheDirectory(string $directory): self |
145
|
|
|
{ |
146
|
|
|
$this->cacheDir = $directory; |
147
|
|
|
return $this; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
public function useSystemTempCache(string $subDirectory = 'webauthn-server-cache'): self |
151
|
|
|
{ |
152
|
|
|
$this->cacheDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $subDirectory; |
153
|
|
|
return $this; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @param callable|PolicyCallbackInterface $policyCallback |
158
|
|
|
* |
159
|
|
|
* @return $this |
160
|
|
|
*/ |
161
|
|
|
public function configurePolicy(callable $policyCallback): self |
162
|
|
|
{ |
163
|
|
|
$this->policyCallback = $policyCallback; |
164
|
|
|
return $this; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @return $this |
169
|
|
|
*/ |
170
|
|
|
public function allowNoneAttestation(bool $allow): self |
171
|
|
|
{ |
172
|
|
|
$this->allowNoneAttestation = $allow; |
173
|
|
|
return $this; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @return $this |
178
|
|
|
*/ |
179
|
|
|
public function strictSupportedFormats(bool $strict): self |
180
|
|
|
{ |
181
|
|
|
$this->strictSupportedFormats = $strict; |
182
|
|
|
return $this; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @return $this |
187
|
|
|
*/ |
188
|
|
|
public function useMetadata(bool $use): self |
189
|
|
|
{ |
190
|
|
|
$this->useMetadata = $use; |
191
|
|
|
return $this; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @return $this |
196
|
|
|
*/ |
197
|
|
|
public function allowSelfAttestation(bool $allow): self |
198
|
|
|
{ |
199
|
|
|
$this->allowSelfAttestation = $allow; |
200
|
|
|
return $this; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* @return $this |
205
|
|
|
*/ |
206
|
|
|
public function trustWithoutMetadata(bool $trust): self |
207
|
|
|
{ |
208
|
|
|
$this->trustWithoutMetadata = $trust; |
209
|
|
|
return $this; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* @return $this |
214
|
|
|
*/ |
215
|
|
|
public function enableExtensions(string ...$extensions): self |
216
|
|
|
{ |
217
|
|
|
foreach ($extensions as $ext) { |
218
|
|
|
if (!isset(self::SUPPORTED_EXTENSIONS[$ext])) { |
219
|
|
|
throw new ConfigurationException(sprintf('Extension %s is not supported.', $ext)); |
220
|
|
|
} |
221
|
|
|
} |
222
|
|
|
$this->enabledExtensions = array_merge($this->enabledExtensions, $extensions); |
223
|
|
|
return $this; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* @return $this |
228
|
|
|
*/ |
229
|
|
|
public function addCustomExtension(ExtensionInterface $extension): self |
230
|
|
|
{ |
231
|
|
|
$this->customExtensions[] = $extension; |
232
|
|
|
return $this; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @return $this |
237
|
|
|
*/ |
238
|
|
|
public function setLogger(LoggerInterface $logger): self |
239
|
|
|
{ |
240
|
|
|
$this->logger = $logger; |
241
|
|
|
return $this; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
private function assignLogger(LoggerAwareInterface $service): void |
245
|
|
|
{ |
246
|
|
|
if ($this->logger !== null) { |
247
|
|
|
$service->setLogger($this->logger); |
248
|
|
|
} |
249
|
|
|
} |
250
|
|
|
|
251
|
18 |
|
public function build(): ServerInterface |
252
|
|
|
{ |
253
|
18 |
|
$c = $this->setupContainer(); |
254
|
|
|
|
255
|
18 |
|
return $c[ServerInterface::class]; |
256
|
|
|
} |
257
|
|
|
|
258
|
18 |
|
private function setupContainer(): ServiceContainer |
259
|
|
|
{ |
260
|
18 |
|
$c = new ServiceContainer(); |
261
|
|
|
|
262
|
18 |
|
$this->setupConfiguredServices($c); |
263
|
18 |
|
$this->setupFormats($c); |
264
|
18 |
|
$this->setupTrustDecisionManager($c); |
265
|
18 |
|
$this->setupExtensions($c); |
266
|
|
|
|
267
|
|
|
$c[TrustPathValidatorInterface::class] = static function (ServiceContainer $c): TrustPathValidatorInterface { |
268
|
18 |
|
return new TrustPathValidator($c[ChainValidatorInterface::class]); |
269
|
|
|
}; |
270
|
|
|
|
271
|
|
|
$c[ChainValidatorInterface::class] = static function (ServiceContainer $c): ChainValidatorInterface { |
|
|
|
|
272
|
|
|
// TODO |
273
|
|
|
//return new ChainValidator($c[CertificateStatusResolverInterface::class]); |
274
|
18 |
|
return new ChainValidator(null); |
275
|
|
|
}; |
276
|
|
|
|
277
|
|
|
// TODO |
278
|
|
|
// $c[CertificateStatusResolverInterface::class] = static function (ServiceContainer $c) { |
279
|
|
|
// return new CertificateStatusResolver($c[DownloaderInterface::class], $c[CacheProviderInterface::class]); |
280
|
|
|
// }; |
281
|
|
|
|
282
|
18 |
|
$c[PolicyInterface::class] = Closure::fromCallable([$this, 'createPolicy']); |
283
|
18 |
|
$c[MetadataResolverInterface::class] = Closure::fromCallable([$this, 'createMetadataResolver']); |
284
|
18 |
|
$c[ServerInterface::class] = Closure::fromCallable([$this, 'createServer']); |
285
|
|
|
|
286
|
18 |
|
return $c; |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
private function setupDownloader(ServiceContainer $c) |
290
|
|
|
{ |
291
|
|
|
$this->setupCache($c); |
292
|
|
|
if (isset($c[DownloaderInterface::class])) { |
293
|
|
|
return; |
294
|
|
|
} |
295
|
|
|
$c[DownloaderInterface::class] = static function (ServiceContainer $c): DownloaderInterface { |
296
|
|
|
return new Downloader($c[Client::class]); |
297
|
|
|
}; |
298
|
|
|
$c[Client::class] = static function (ServiceContainer $c): Client { |
299
|
|
|
$factory = new CachingClientFactory($c[CacheProviderInterface::class]); |
300
|
|
|
return $factory->createClient(); |
301
|
|
|
}; |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
private function setupCache(ServiceContainer $c) |
305
|
|
|
{ |
306
|
|
|
if (isset($c[CacheProviderInterface::class])) { |
307
|
|
|
return; |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
$cacheDir = $this->cacheDir; |
311
|
|
|
if ($cacheDir === null) { |
312
|
|
|
throw new ConfigurationException('No cache directory configured. Use useCacheDirectory or useSystemTempCache.'); |
313
|
|
|
} |
314
|
|
|
$c[CacheProviderInterface::class] = static function (ServiceContainer $c) use ($cacheDir): CacheProviderInterface { |
|
|
|
|
315
|
|
|
return new FileCacheProvider($cacheDir); |
316
|
|
|
}; |
317
|
|
|
} |
318
|
|
|
|
319
|
18 |
|
private function setupConfiguredServices(ServiceContainer $c): void |
320
|
|
|
{ |
321
|
18 |
|
if ($this->rp === null) { |
322
|
|
|
throw new ConfigurationException('Relying party not configured. Use setRelyingParty.'); |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
$c[RelyingPartyInterface::class] = function (): RelyingPartyInterface { return $this->rp; }; |
|
|
|
|
326
|
|
|
|
327
|
18 |
|
if ($this->store === null) { |
328
|
|
|
throw new ConfigurationException('Credential store not configured. Use setCredentialStore.'); |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
$c[CredentialStoreInterface::class] = function (): CredentialStoreInterface { return $this->store; }; |
|
|
|
|
332
|
|
|
$c[LoggerInterface::class] = function (): LoggerInterface { return $this->logger ?? new NullLogger(); }; |
333
|
18 |
|
} |
334
|
|
|
|
335
|
18 |
|
private function createPolicy(ServiceContainer $c): PolicyInterface |
|
|
|
|
336
|
|
|
{ |
337
|
18 |
|
$policy = new Policy(); |
338
|
|
|
|
339
|
18 |
|
if ($this->policyCallback !== null) { |
340
|
|
|
($this->policyCallback)($policy); |
341
|
|
|
} |
342
|
|
|
|
343
|
18 |
|
return $policy; |
344
|
|
|
} |
345
|
|
|
|
346
|
18 |
|
private function createServer(ServiceContainer $c): ServerInterface |
347
|
|
|
{ |
348
|
18 |
|
return new WebAuthnServer( |
349
|
18 |
|
$c[RelyingPartyInterface::class], |
350
|
18 |
|
$c[PolicyInterface::class], |
351
|
18 |
|
$c[CredentialStoreInterface::class], |
352
|
18 |
|
$c[AttestationFormatRegistryInterface::class], |
353
|
18 |
|
$c[MetadataResolverInterface::class], |
354
|
18 |
|
$c[TrustDecisionManagerInterface::class], |
355
|
18 |
|
$c[ExtensionRegistryInterface::class]); |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
public function addMetadataSource(MetadataSourceInterface $metadataSource): self |
359
|
|
|
{ |
360
|
|
|
$this->metadataSources[] = $metadataSource; |
361
|
|
|
return $this; |
362
|
|
|
} |
363
|
|
|
|
364
|
18 |
|
private function createMetadataResolver(ServiceContainer $c): MetadataResolverInterface |
365
|
|
|
{ |
366
|
18 |
|
if (count($this->metadataSources) === 0) { |
367
|
18 |
|
return new NullMetadataResolver(); |
368
|
|
|
} |
369
|
|
|
return new MetadataResolver($this->createMetadataProviders($c)); |
370
|
|
|
} |
371
|
|
|
|
372
|
18 |
|
private function setupTrustDecisionManager(ServiceContainer $c) |
373
|
|
|
{ |
374
|
|
|
$c[TrustDecisionManagerInterface::class] = function (ServiceContainer $c): TrustDecisionManagerInterface { |
375
|
18 |
|
$tdm = new TrustDecisionManager(); |
376
|
|
|
|
377
|
18 |
|
if ($this->allowNoneAttestation) { |
378
|
18 |
|
$tdm->addVoter(new TrustAttestationTypeVoter(AttestationType::NONE)); |
379
|
|
|
} |
380
|
18 |
|
if ($this->allowSelfAttestation) { |
381
|
18 |
|
$tdm->addVoter(new TrustAttestationTypeVoter(AttestationType::SELF)); |
382
|
|
|
} |
383
|
18 |
|
if ($this->trustWithoutMetadata) { |
384
|
18 |
|
$tdm->addVoter(new AllowEmptyMetadataVoter()); |
385
|
|
|
} |
386
|
18 |
|
if ($this->useMetadata) { |
387
|
18 |
|
$tdm->addVoter(new SupportedAttestationTypeVoter()); |
388
|
18 |
|
$tdm->addVoter(new UndesiredStatusReportVoter()); |
389
|
18 |
|
$tdm->addVoter(new TrustChainVoter($c[TrustPathValidatorInterface::class])); |
390
|
|
|
} |
391
|
18 |
|
return $tdm; |
392
|
|
|
}; |
393
|
18 |
|
} |
394
|
|
|
|
395
|
|
|
private function createMetadataProviders(ServiceContainer $c): array |
396
|
|
|
{ |
397
|
|
|
$providers = []; |
398
|
|
|
foreach ($this->metadataSources as $source) { |
399
|
|
|
if ($source instanceof StatementDirectorySource) { |
400
|
|
|
$provider = new FileProvider($source); |
401
|
|
|
} elseif ($source instanceof MetadataServiceSource) { |
402
|
|
|
$this->setupDownloader($c); |
403
|
|
|
$provider = new MetadataServiceProvider($source, $c[DownloaderInterface::class], $c[CacheProviderInterface::class], $c[ChainValidatorInterface::class]); |
404
|
|
|
} else { |
405
|
|
|
throw new UnsupportedException(sprintf('No provider available for metadata source of type %s.', get_class($source))); |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
if ($provider instanceof LoggerAwareInterface) { |
409
|
|
|
$this->assignLogger($provider); |
410
|
|
|
} |
411
|
|
|
$providers[] = $provider; |
412
|
|
|
} |
413
|
|
|
return $providers; |
414
|
|
|
} |
415
|
|
|
|
416
|
18 |
|
private function setupFormats(ServiceContainer $c) |
417
|
|
|
{ |
418
|
|
|
$c[PackedAttestationVerifier::class] = static function (): PackedAttestationVerifier { |
419
|
18 |
|
return new PackedAttestationVerifier(); |
420
|
|
|
}; |
421
|
|
|
$c[FidoU2fAttestationVerifier::class] = static function (): FidoU2fAttestationVerifier { |
422
|
18 |
|
return new FidoU2fAttestationVerifier(); |
423
|
|
|
}; |
424
|
|
|
$c[NoneAttestationVerifier::class] = static function (): NoneAttestationVerifier { |
425
|
18 |
|
return new NoneAttestationVerifier(); |
426
|
|
|
}; |
427
|
|
|
$c[TpmAttestationVerifier::class] = static function (): TpmAttestationVerifier { |
428
|
18 |
|
return new TpmAttestationVerifier(); |
429
|
|
|
}; |
430
|
|
|
$c[AndroidSafetyNetAttestationVerifier::class] = static function (): AndroidSafetyNetAttestationVerifier { |
431
|
18 |
|
return new AndroidSafetyNetAttestationVerifier(); |
432
|
|
|
}; |
433
|
|
|
$c[AndroidKeyAttestationVerifier::class] = static function (): AndroidKeyAttestationVerifier { |
434
|
18 |
|
return new AndroidKeyAttestationVerifier(); |
435
|
|
|
}; |
436
|
|
|
|
437
|
|
|
$c[AttestationFormatRegistryInterface::class] = function (ServiceContainer $c): AttestationFormatRegistryInterface { |
438
|
18 |
|
$registry = new AttestationFormatRegistry(); |
439
|
|
|
|
440
|
18 |
|
$registry->strictSupportedFormats($this->strictSupportedFormats); |
441
|
|
|
|
442
|
18 |
|
$registry->addFormat($c[PackedAttestationVerifier::class]->getSupportedFormat()); |
443
|
18 |
|
$registry->addFormat($c[FidoU2fAttestationVerifier::class]->getSupportedFormat()); |
444
|
18 |
|
$registry->addFormat($c[NoneAttestationVerifier::class]->getSupportedFormat()); |
445
|
18 |
|
$registry->addFormat($c[TpmAttestationVerifier::class]->getSupportedFormat()); |
446
|
18 |
|
$registry->addFormat($c[AndroidSafetyNetAttestationVerifier::class]->getSupportedFormat()); |
447
|
18 |
|
$registry->addFormat($c[AndroidKeyAttestationVerifier::class]->getSupportedFormat()); |
448
|
|
|
|
449
|
18 |
|
return $registry; |
450
|
|
|
}; |
451
|
18 |
|
} |
452
|
|
|
|
453
|
18 |
|
private function setupExtensions(ServiceContainer $c): void |
454
|
|
|
{ |
455
|
|
|
$c[AppIdExtension::class] = static function (ServiceContainer $c): AppIdExtension { |
|
|
|
|
456
|
|
|
return new AppIdExtension(); |
457
|
|
|
}; |
458
|
|
|
$c[ExtensionRegistryInterface::class] = function (ServiceContainer $c): ExtensionRegistryInterface { |
459
|
18 |
|
$registry = new ExtensionRegistry(); |
460
|
18 |
|
foreach (array_unique($this->enabledExtensions) as $ext) { |
461
|
|
|
$registry->addExtension($c[self::SUPPORTED_EXTENSIONS[$ext]]); |
462
|
|
|
} |
463
|
18 |
|
foreach ($this->customExtensions as $ext) { |
464
|
|
|
$registry->addExtension($ext); |
465
|
|
|
} |
466
|
18 |
|
return $registry; |
467
|
|
|
}; |
468
|
18 |
|
} |
469
|
|
|
} |
470
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.