@@ -267,7 +267,7 @@ private function generateAuthenticatorClass(array $securityData, string $authent
267
267
$ authenticatorClass ,
268
268
sprintf ('authenticator/%sEmptyAuthenticator.tpl.php ' , $ this ->useSecurity52 ? 'Security52 ' : '' ),
269
269
[
270
- 'provider_key_type_hint ' => $ this ->providerKeyTypeHint (),
270
+ 'provider_key_type_hint ' => $ this ->getGuardProviderKeyTypeHint (),
271
271
'use_legacy_passport_interface ' => $ this ->shouldUseLegacyPassportInterface (),
272
272
]
273
273
);
@@ -291,7 +291,7 @@ private function generateAuthenticatorClass(array $securityData, string $authent
291
291
'username_field_var ' => Str::asLowerCamelCase ($ userNameField ),
292
292
'user_needs_encoder ' => $ this ->userClassHasEncoder ($ securityData , $ userClass ),
293
293
'user_is_entity ' => $ this ->doctrineHelper ->isClassAMappedEntity ($ userClass ),
294
- 'provider_key_type_hint ' => $ this ->providerKeyTypeHint (),
294
+ 'provider_key_type_hint ' => $ this ->getGuardProviderKeyTypeHint (),
295
295
'use_legacy_passport_interface ' => $ this ->shouldUseLegacyPassportInterface (),
296
296
]
297
297
);
@@ -406,8 +406,16 @@ public function configureDependencies(DependencyBuilder $dependencies, InputInte
406
406
);
407
407
}
408
408
409
- private function providerKeyTypeHint (): string
409
+ /**
410
+ * Calculates the type-hint used for the $provider argument (string or nothing) for Guard.
411
+ */
412
+ private function getGuardProviderKeyTypeHint (): string
410
413
{
414
+ // doesn't matter: this only applies to non-Guard authenticators
415
+ if (!class_exists (AbstractFormLoginAuthenticator::class)) {
416
+ return '' ;
417
+ }
418
+
411
419
$ reflectionMethod = new \ReflectionMethod (AbstractFormLoginAuthenticator::class, 'onAuthenticationSuccess ' );
412
420
$ type = $ reflectionMethod ->getParameters ()[2 ]->getType ();
413
421
0 commit comments