Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preventing Guard auth method from exploding in 6.0 #1026

Merged
merged 1 commit into from
Dec 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/Maker/MakeAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private function generateAuthenticatorClass(array $securityData, string $authent
$authenticatorClass,
sprintf('authenticator/%sEmptyAuthenticator.tpl.php', $this->useSecurity52 ? 'Security52' : ''),
[
'provider_key_type_hint' => $this->providerKeyTypeHint(),
'provider_key_type_hint' => $this->getGuardProviderKeyTypeHint(),
'use_legacy_passport_interface' => $this->shouldUseLegacyPassportInterface(),
]
);
Expand All @@ -291,7 +291,7 @@ private function generateAuthenticatorClass(array $securityData, string $authent
'username_field_var' => Str::asLowerCamelCase($userNameField),
'user_needs_encoder' => $this->userClassHasEncoder($securityData, $userClass),
'user_is_entity' => $this->doctrineHelper->isClassAMappedEntity($userClass),
'provider_key_type_hint' => $this->providerKeyTypeHint(),
'provider_key_type_hint' => $this->getGuardProviderKeyTypeHint(),
'use_legacy_passport_interface' => $this->shouldUseLegacyPassportInterface(),
]
);
Expand Down Expand Up @@ -406,8 +406,16 @@ public function configureDependencies(DependencyBuilder $dependencies, InputInte
);
}

private function providerKeyTypeHint(): string
/**
* Calculates the type-hint used for the $provider argument (string or nothing) for Guard.
*/
private function getGuardProviderKeyTypeHint(): string
{
// doesn't matter: this only applies to non-Guard authenticators
if (!class_exists(AbstractFormLoginAuthenticator::class)) {
return '';
}

$reflectionMethod = new \ReflectionMethod(AbstractFormLoginAuthenticator::class, 'onAuthenticationSuccess');
$type = $reflectionMethod->getParameters()[2]->getType();

Expand Down