Skip to content

Commit 08b370e

Browse files
committed
bug #992 Renaming variable $userPasswordHasherInterface -> $userPasswordHasher (weaverryan)
This PR was squashed before being merged into the 1.0-dev branch. Discussion ---------- Renaming variable $userPasswordHasherInterface -> $userPasswordHasher Fixes (by removing `Interface`) an unnecessarily long and strange argument name in the controller. Before: <img width="848" alt="Screen Shot 2021-10-12 at 2 27 26 PM" src="https://user-images.githubusercontent.com/121003/137009551-2b8180f9-4902-4922-84a3-4d629b0f2b39.png"> Already tested in a real app to be extra safe :) Commits ------- 39abf21 Renaming variable $userPasswordHasherInterface -> $userPasswordHasher
2 parents 6c7a575 + 39abf21 commit 08b370e

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/Maker/MakeRegistrationForm.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,8 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
330330
'authenticator_full_class_name' => $this->autoLoginAuthenticator,
331331
'firewall_name' => $this->firewallName,
332332
'redirect_route_name' => $this->redirectRouteName,
333-
'password_class_details' => ($passwordClassDetails = $generator->createClassNameDetails($passwordHasher, '\\')),
334-
'password_variable_name' => sprintf('$%s', lcfirst($passwordClassDetails->getShortName())), // @legacy see passwordHasher conditional above
333+
'password_hasher_class_details' => ($passwordClassDetails = $generator->createClassNameDetails($passwordHasher, '\\')),
334+
'password_hasher_variable_name' => str_replace('Interface', '', sprintf('$%s', lcfirst($passwordClassDetails->getShortName()))), // @legacy see passwordHasher conditional above
335335
'use_password_hasher' => UserPasswordHasherInterface::class === $passwordHasher, // @legacy see passwordHasher conditional above
336336
],
337337
$userRepoVars

src/Maker/MakeResetPassword.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
248248
'from_email_name' => $this->fromEmailName,
249249
'email_getter' => $this->emailGetterMethodName,
250250
'email_field' => $this->emailPropertyName,
251-
'password_class_details' => ($passwordClassDetails = $generator->createClassNameDetails($passwordHasher, '\\')),
252-
'password_variable_name' => sprintf('$%s', lcfirst($passwordClassDetails->getShortName())), // @legacy see passwordHasher conditional above
251+
'password_hasher_class_details' => ($passwordClassDetails = $generator->createClassNameDetails($passwordHasher, '\\')),
252+
'password_hasher_variable_name' => str_replace('Interface', '', sprintf('$%s', lcfirst($passwordClassDetails->getShortName()))), // @legacy see passwordHasher conditional above
253253
'use_password_hasher' => UserPasswordHasherInterface::class === $passwordHasher, // @legacy see passwordHasher conditional above
254254
]
255255
);

src/Resources/skeleton/registration/RegistrationController.tpl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function __construct(<?= $email_verifier_class_details->getShortName() ?>
1616

1717
<?php endif; ?>
1818
<?= $generator->generateRouteForControllerMethod($route_path, $route_name) ?>
19-
public function register(Request $request, <?= $password_class_details->getShortName() ?> <?= $password_variable_name ?><?= $authenticator_full_class_name ? sprintf(', GuardAuthenticatorHandler $guardHandler, %s $authenticator', $authenticator_class_name) : '' ?>): Response
19+
public function register(Request $request, <?= $password_hasher_class_details->getShortName() ?> <?= $password_hasher_variable_name ?><?= $authenticator_full_class_name ? sprintf(', GuardAuthenticatorHandler $guardHandler, %s $authenticator', $authenticator_class_name) : '' ?>): Response
2020
{
2121
$user = new <?= $user_class_name ?>();
2222
$form = $this->createForm(<?= $form_class_name ?>::class, $user);
@@ -25,7 +25,7 @@ public function register(Request $request, <?= $password_class_details->getShort
2525
if ($form->isSubmitted() && $form->isValid()) {
2626
// encode the plain password
2727
$user->set<?= ucfirst($password_field) ?>(
28-
<?= $password_variable_name ?>-><?= $use_password_hasher ? 'hashPassword' : 'encodePassword' ?>(
28+
<?= $password_hasher_variable_name ?>-><?= $use_password_hasher ? 'hashPassword' : 'encodePassword' ?>(
2929
$user,
3030
$form->get('plainPassword')->getData()
3131
)

src/Resources/skeleton/resetPassword/ResetPasswordController.tpl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function checkEmail(): Response
8282
* @Route("/reset/{token}", name="app_reset_password")
8383
*/
8484
<?php } ?>
85-
public function reset(Request $request, <?= $password_class_details->getShortName() ?> <?= $password_variable_name ?>, string $token = null): Response
85+
public function reset(Request $request, <?= $password_hasher_class_details->getShortName() ?> <?= $password_hasher_variable_name ?>, string $token = null): Response
8686
{
8787
if ($token) {
8888
// We store the token in session and remove it from the URL, to avoid the URL being
@@ -117,7 +117,7 @@ public function reset(Request $request, <?= $password_class_details->getShortNam
117117
$this->resetPasswordHelper->removeResetRequest($token);
118118

119119
// Encode(hash) the plain password, and set it.
120-
$encodedPassword = <?= $password_variable_name ?>-><?= $use_password_hasher ? 'hashPassword' : 'encodePassword' ?>(
120+
$encodedPassword = <?= $password_hasher_variable_name ?>-><?= $use_password_hasher ? 'hashPassword' : 'encodePassword' ?>(
121121
$user,
122122
$form->get('plainPassword')->getData()
123123
);

0 commit comments

Comments
 (0)