Skip to content

Commit 086055b

Browse files
committed
preventing Guard auth method from exploding in 6.0
1 parent 8e2590a commit 086055b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/Maker/MakeAuthenticator.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ private function generateAuthenticatorClass(array $securityData, string $authent
267267
$authenticatorClass,
268268
sprintf('authenticator/%sEmptyAuthenticator.tpl.php', $this->useSecurity52 ? 'Security52' : ''),
269269
[
270-
'provider_key_type_hint' => $this->providerKeyTypeHint(),
270+
'provider_key_type_hint' => $this->getGuardProviderKeyTypeHint(),
271271
'use_legacy_passport_interface' => $this->shouldUseLegacyPassportInterface(),
272272
]
273273
);
@@ -291,7 +291,7 @@ private function generateAuthenticatorClass(array $securityData, string $authent
291291
'username_field_var' => Str::asLowerCamelCase($userNameField),
292292
'user_needs_encoder' => $this->userClassHasEncoder($securityData, $userClass),
293293
'user_is_entity' => $this->doctrineHelper->isClassAMappedEntity($userClass),
294-
'provider_key_type_hint' => $this->providerKeyTypeHint(),
294+
'provider_key_type_hint' => $this->getGuardProviderKeyTypeHint(),
295295
'use_legacy_passport_interface' => $this->shouldUseLegacyPassportInterface(),
296296
]
297297
);
@@ -406,8 +406,16 @@ public function configureDependencies(DependencyBuilder $dependencies, InputInte
406406
);
407407
}
408408

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
410413
{
414+
// doesn't matter: this only applies to non-Guard authenticators
415+
if (!class_exists(AbstractFormLoginAuthenticator::class)) {
416+
return '';
417+
}
418+
411419
$reflectionMethod = new \ReflectionMethod(AbstractFormLoginAuthenticator::class, 'onAuthenticationSuccess');
412420
$type = $reflectionMethod->getParameters()[2]->getType();
413421

0 commit comments

Comments
 (0)