Skip to content
Snippets Groups Projects
Commit 9be17b0e authored by Camille Simiand's avatar Camille Simiand
Browse files

Fix phpstan level 6 errors

parent 4a532a45
No related branches found
No related tags found
1 merge request!27tuleap-108-add-stricter-code-quality-tools-configuration
This commit is part of merge request !27. Comments created here will be created in the context of that merge request.
......@@ -6,3 +6,4 @@ parameters:
container_xml_path: var/cache/dev/App_KernelDevDebugContainer.xml
doctrine:
objectManagerLoader: tests/object-manager.php
checkGenericClassInNonGenericObjectType: false
\ No newline at end of file
......@@ -18,7 +18,7 @@ class UserBuilder
private bool $hasRequiredRoles = false;
private bool $hasRequiredIsVerified = false;
public function __construct($password_hasher)
public function __construct(UserPasswordHasherInterface $password_hasher)
{
$this->user = new User();
$this->password_hasher = $password_hasher;
......@@ -59,6 +59,9 @@ class UserBuilder
return $this;
}
/**
* @param array<string> $roles
*/
public function withRoles(array $roles): UserBuilder
{
if (! in_array(['ROLE_USER'], $roles)) {
......
......@@ -122,7 +122,7 @@ class RegistrationController extends AbstractController
/**
* @Route("/register_mail_sent", name="app_register_mail_sent")
*/
public function mailSentMessage(UserRepository $userRepository)
public function mailSentMessage(UserRepository $userRepository): Response
{
$userid = $this->requestStack->getSession()->get('userid');
$user = $userRepository->find($userid);
......
......@@ -26,8 +26,8 @@ class ResetPasswordController extends AbstractController
{
use ResetPasswordControllerTrait;
private $resetPasswordHelper;
private $entityManager;
private ResetPasswordHelperInterface $resetPasswordHelper;
private EntityManagerInterface $entityManager;
public function __construct(
ResetPasswordHelperInterface $resetPasswordHelper,
......
......@@ -20,6 +20,7 @@ class CurlHandle
$this->curl_handler = $curl_init;
}
/** @phpstan-ignore-next-line */
public function setOptions(array $options_array): void
{
curl_setopt_array($this->curl_handler, $options_array);
......
......@@ -63,7 +63,8 @@ class User implements UserInterface, LegacyPasswordAuthenticatedUserInterface
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/** @phpstan-ignore-next-line */
private array $roles = [];
/**
* @var string The hashed password
......@@ -130,6 +131,9 @@ class User implements UserInterface, LegacyPasswordAuthenticatedUserInterface
return array_unique($roles);
}
/**
* @param array<string> $roles
*/
public function setRoles(array $roles): self
{
$this->roles = $roles;
......@@ -166,7 +170,7 @@ class User implements UserInterface, LegacyPasswordAuthenticatedUserInterface
/**
* @see UserInterface
*/
public function eraseCredentials()
public function eraseCredentials(): void
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
......
......@@ -7,7 +7,7 @@ class ContractHelper
/**
* @throws \Exception if the predicate is not fulfilled an exception is thrown.
*/
public static function requires(bool $predicate, string $errorMessage)
public static function requires(bool $predicate, string $errorMessage): void
{
if (! $predicate) {
throw new \Exception($errorMessage);
......
......@@ -38,7 +38,7 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
$this->_em->flush();
}
public function findOneByEmail($value): ?User
public function findOneByEmail(string $value): ?User
{
return $this->createQueryBuilder('u')
->andWhere('u.email = :val')
......
......@@ -18,11 +18,11 @@ class UserChecker implements UserCheckerInterface
$this->translator = $translator;
}
public function checkPreAuth(UserInterface $user)
public function checkPreAuth(UserInterface $user): void
{
}
public function checkPostAuth(UserInterface $user)
public function checkPostAuth(UserInterface $user): void
{
if (!$user instanceof User) {
return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment