Skip to content

Commit f876bff

Browse files
committed
Improve type declarations in the project
1 parent bbdacd5 commit f876bff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+247
-72
lines changed

src/Command/ActivateUserCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use FOS\UserBundle\Util\UserManipulator;
1515
use Symfony\Component\Console\Attribute\AsCommand;
1616
use Symfony\Component\Console\Command\Command;
17+
use Symfony\Component\Console\Helper\QuestionHelper;
1718
use Symfony\Component\Console\Input\InputArgument;
1819
use Symfony\Component\Console\Input\InputInterface;
1920
use Symfony\Component\Console\Output\OutputInterface;
@@ -80,7 +81,10 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
8081

8182
return $username;
8283
});
83-
$answer = $this->getHelper('question')->ask($input, $output, $question);
84+
85+
$helper = $this->getHelper('question');
86+
\assert($helper instanceof QuestionHelper);
87+
$answer = $helper->ask($input, $output, $question);
8488

8589
$input->setArgument('username', $answer);
8690
}

src/Command/ChangePasswordCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use FOS\UserBundle\Util\UserManipulator;
1515
use Symfony\Component\Console\Attribute\AsCommand;
1616
use Symfony\Component\Console\Command\Command;
17+
use Symfony\Component\Console\Helper\QuestionHelper;
1718
use Symfony\Component\Console\Input\InputArgument;
1819
use Symfony\Component\Console\Input\InputInterface;
1920
use Symfony\Component\Console\Output\OutputInterface;
@@ -105,8 +106,11 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
105106
$questions['password'] = $question;
106107
}
107108

109+
$helper = $this->getHelper('question');
110+
\assert($helper instanceof QuestionHelper);
111+
108112
foreach ($questions as $name => $question) {
109-
$answer = $this->getHelper('question')->ask($input, $output, $question);
113+
$answer = $helper->ask($input, $output, $question);
110114
$input->setArgument($name, $answer);
111115
}
112116
}

src/Command/CreateUserCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use FOS\UserBundle\Util\UserManipulator;
1515
use Symfony\Component\Console\Attribute\AsCommand;
1616
use Symfony\Component\Console\Command\Command;
17+
use Symfony\Component\Console\Helper\QuestionHelper;
1718
use Symfony\Component\Console\Input\InputArgument;
1819
use Symfony\Component\Console\Input\InputInterface;
1920
use Symfony\Component\Console\Input\InputOption;
@@ -136,8 +137,11 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
136137
$questions['password'] = $question;
137138
}
138139

140+
$helper = $this->getHelper('question');
141+
\assert($helper instanceof QuestionHelper);
142+
139143
foreach ($questions as $name => $question) {
140-
$answer = $this->getHelper('question')->ask($input, $output, $question);
144+
$answer = $helper->ask($input, $output, $question);
141145
$input->setArgument($name, $answer);
142146
}
143147
}

src/Command/DeactivateUserCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use FOS\UserBundle\Util\UserManipulator;
1515
use Symfony\Component\Console\Attribute\AsCommand;
1616
use Symfony\Component\Console\Command\Command;
17+
use Symfony\Component\Console\Helper\QuestionHelper;
1718
use Symfony\Component\Console\Input\InputArgument;
1819
use Symfony\Component\Console\Input\InputInterface;
1920
use Symfony\Component\Console\Output\OutputInterface;
@@ -80,7 +81,10 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
8081

8182
return $username;
8283
});
83-
$answer = $this->getHelper('question')->ask($input, $output, $question);
84+
85+
$helper = $this->getHelper('question');
86+
\assert($helper instanceof QuestionHelper);
87+
$answer = $helper->ask($input, $output, $question);
8488

8589
$input->setArgument('username', $answer);
8690
}

src/Command/RoleCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use FOS\UserBundle\Util\UserManipulator;
1515
use Symfony\Component\Console\Command\Command;
16+
use Symfony\Component\Console\Helper\QuestionHelper;
1617
use Symfony\Component\Console\Input\InputArgument;
1718
use Symfony\Component\Console\Input\InputInterface;
1819
use Symfony\Component\Console\Input\InputOption;
@@ -102,8 +103,11 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
102103
$questions['role'] = $question;
103104
}
104105

106+
$helper = $this->getHelper('question');
107+
\assert($helper instanceof QuestionHelper);
108+
105109
foreach ($questions as $name => $question) {
106-
$answer = $this->getHelper('question')->ask($input, $output, $question);
110+
$answer = $helper->ask($input, $output, $question);
107111
$input->setArgument($name, $answer);
108112
}
109113
}

src/Controller/RegistrationController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ private function getTargetUrlFromSession(SessionInterface $session): ?string
174174
{
175175
$token = $this->tokenStorage->getToken();
176176

177+
if (null === $token) {
178+
return null;
179+
}
180+
177181
if (method_exists($token, 'getFirewallName')) {
178182
$firewallName = $token->getFirewallName();
179183
} elseif (method_exists($token, 'getProviderKey')) {

src/Controller/SecurityController.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,17 @@ public function loginAction(): Response
5151
]);
5252
}
5353

54+
/**
55+
* @return never
56+
*/
5457
public function checkAction()
5558
{
5659
throw new \RuntimeException('You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.');
5760
}
5861

62+
/**
63+
* @return never
64+
*/
5965
public function logoutAction()
6066
{
6167
throw new \RuntimeException('You must activate the logout in your security firewall configuration.');
@@ -64,6 +70,8 @@ public function logoutAction()
6470
/**
6571
* Renders the login template with the given parameters. Overwrite this function in
6672
* an extended controller to provide additional data for the login template.
73+
*
74+
* @param array<string, mixed> $data
6775
*/
6876
protected function renderLogin(array $data): Response
6977
{

src/DependencyInjection/Compiler/InjectRememberMeServicesPass.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class InjectRememberMeServicesPass implements CompilerPassInterface
2929
public function process(ContainerBuilder $container): void
3030
{
3131
$firewallName = $container->getParameter('fos_user.firewall_name');
32+
\assert(\is_string($firewallName));
3233
$loginManager = $container->getDefinition('fos_user.security.login_manager');
3334

3435
if ($container->has('security.authenticator.remember_me_handler.'.$firewallName)) {

src/DependencyInjection/Compiler/InjectUserCheckerPass.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class InjectUserCheckerPass implements CompilerPassInterface
2929
public function process(ContainerBuilder $container): void
3030
{
3131
$firewallName = $container->getParameter('fos_user.firewall_name');
32+
\assert(\is_string($firewallName));
3233
$loginManager = $container->findDefinition('fos_user.security.login_manager');
3334

3435
if ($container->has('security.user_checker.'.$firewallName)) {

src/DependencyInjection/Compiler/ValidationPass.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function process(ContainerBuilder $container): void
3232
}
3333

3434
$storage = $container->getParameter('fos_user.storage');
35+
\assert(\is_string($storage));
3536

3637
if ('custom' === $storage) {
3738
return;

0 commit comments

Comments
 (0)