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