diff --git a/phpstan.neon b/phpstan.neon index 449e180257837c620ee200281ed52fe940a5d7de..e56bade66e2efbf69b74a594330d364d86ac2d24 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,4 +5,5 @@ parameters: symfony: container_xml_path: var/cache/dev/App_KernelDevDebugContainer.xml doctrine: - objectManagerLoader: tests/object-manager.php \ No newline at end of file + objectManagerLoader: tests/object-manager.php + checkGenericClassInNonGenericObjectType: false \ No newline at end of file diff --git a/src/Builder/UserBuilder.php b/src/Builder/UserBuilder.php index 86dd56662d0804a040cb779c002c16b80d852cfa..639effabb6c42cc710a71aa33c7baf270c5fc7f4 100644 --- a/src/Builder/UserBuilder.php +++ b/src/Builder/UserBuilder.php @@ -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)) { diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php index 4eedc131bd5cbf9240ab6e7c00f1309e3fa9ee55..e4f1245537cc8065dbf7a2dcb7dabd96ddd4b28d 100644 --- a/src/Controller/RegistrationController.php +++ b/src/Controller/RegistrationController.php @@ -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); diff --git a/src/Controller/ResetPasswordController.php b/src/Controller/ResetPasswordController.php index 1df4e65ea000e3b05024302d81a75830f2aca8e4..4eb6d1425d7baa4f3702eaedec1a9e0d28ce67b4 100644 --- a/src/Controller/ResetPasswordController.php +++ b/src/Controller/ResetPasswordController.php @@ -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, diff --git a/src/Curl/CurlHandle.php b/src/Curl/CurlHandle.php index f058c9c69290f055c196f790357287ee76e1d5a6..23f57e1052762ebcdf1fbd9655a85d49f3f30482 100644 --- a/src/Curl/CurlHandle.php +++ b/src/Curl/CurlHandle.php @@ -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); diff --git a/src/Entity/User.php b/src/Entity/User.php index 2322bc6ffb581da26c53e1bcfdf983f6f83f7964..1bbf9a3d02bbd347fa8df485b52c229ed05a85a2 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -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; diff --git a/src/Helper/ContractHelper.php b/src/Helper/ContractHelper.php index 0c3febc39aa881cb65db25b7053be614004d777b..2896df4cb1100b3c6bf5e2107a24efc1422329bb 100644 --- a/src/Helper/ContractHelper.php +++ b/src/Helper/ContractHelper.php @@ -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); diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php index 2104c06548a253332dc65d690000101ba0cb07d3..d8d123129eaeec7380c9fa4f3577053307dbf200 100644 --- a/src/Repository/UserRepository.php +++ b/src/Repository/UserRepository.php @@ -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') diff --git a/src/Security/UserChecker.php b/src/Security/UserChecker.php index 36201e37db30f49a3bb6f9ea204e20480286e2a6..7e6f77c8891a343fc28fcde7e2562284e6279453 100644 --- a/src/Security/UserChecker.php +++ b/src/Security/UserChecker.php @@ -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;