From 44887eaa82f549b8a36b3ec4ce2fced7af0e2048 Mon Sep 17 00:00:00 2001 From: MarioRadu Date: Thu, 21 Nov 2024 09:49:51 +0200 Subject: [PATCH] phpstan bug fix Signed-off-by: MarioRadu --- phpstan.neon | 3 +++ src/App/src/Middleware/RememberMeMiddleware.php | 6 +++--- src/User/src/Entity/UserRememberMe.php | 6 +++--- src/User/src/Repository/UserRepository.php | 2 +- src/User/src/Service/UserService.php | 4 ++-- src/User/src/Service/UserServiceInterface.php | 4 ++-- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index e5e91083..96ced513 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -15,4 +15,7 @@ parameters: - message: '#Call to an undefined method Laminas\\InputFilter\\InputFilterInterface::getInputs\(\)#' path: test + - + message: '#Call to an undefined method Laminas\\Authentication\\AuthenticationServiceInterface::getStorage\(\)#' + path: src/App/src/Middleware/RememberMeMiddleware.php diff --git a/src/App/src/Middleware/RememberMeMiddleware.php b/src/App/src/Middleware/RememberMeMiddleware.php index 067db592..e8148e03 100644 --- a/src/App/src/Middleware/RememberMeMiddleware.php +++ b/src/App/src/Middleware/RememberMeMiddleware.php @@ -9,7 +9,7 @@ use Dot\DependencyInjection\Attribute\Inject; use Frontend\User\Entity\UserIdentity; use Frontend\User\Service\UserServiceInterface; -use Laminas\Authentication\AuthenticationService; +use Laminas\Authentication\AuthenticationServiceInterface; use Laminas\Authentication\Exception\ExceptionInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; @@ -20,12 +20,12 @@ class RememberMeMiddleware implements MiddlewareInterface { #[Inject( UserServiceInterface::class, - AuthenticationService::class, + AuthenticationServiceInterface::class, "config.rememberMe", )] public function __construct( protected UserServiceInterface $userService, - protected AuthenticationService $authenticationService, + protected AuthenticationServiceInterface $authenticationService, protected array $rememberConfig ) { } diff --git a/src/User/src/Entity/UserRememberMe.php b/src/User/src/Entity/UserRememberMe.php index b987f9b9..51c019aa 100644 --- a/src/User/src/Entity/UserRememberMe.php +++ b/src/User/src/Entity/UserRememberMe.php @@ -18,7 +18,7 @@ class UserRememberMe extends AbstractEntity #[ORM\ManyToOne(targetEntity: User::class)] #[ORM\JoinColumn(name: 'userUuid', referencedColumnName: 'uuid', nullable: false)] - protected User|UserInterface $user; + protected User $user; #[ORM\Column(name: 'rememberMeToken', type: 'string', length: 100, unique: true, nullable: false)] protected string $rememberMeToken = ''; @@ -29,12 +29,12 @@ class UserRememberMe extends AbstractEntity #[ORM\Column(name: 'expireDate', type: 'datetime_immutable')] protected DateTimeImmutable $expireDate; - public function getUser(): User|UserInterface + public function getUser(): User { return $this->user; } - public function setUser(User|UserInterface $user): self + public function setUser(User $user): self { $this->user = $user; diff --git a/src/User/src/Repository/UserRepository.php b/src/User/src/Repository/UserRepository.php index a2b3ae12..e1482fb1 100644 --- a/src/User/src/Repository/UserRepository.php +++ b/src/User/src/Repository/UserRepository.php @@ -104,7 +104,7 @@ public function getRememberUser(string $token): ?UserRememberMe /** * @throws NonUniqueResultException */ - public function findRememberMeUser(User|UserInterface $user, string $userAgent): ?UserRememberMe + public function findRememberMeUser(User $user, string $userAgent): ?UserRememberMe { $qb = $this->getEntityManager()->createQueryBuilder(); $qb->select('user_remember_me') diff --git a/src/User/src/Service/UserService.php b/src/User/src/Service/UserService.php index b32d79cb..93c85720 100644 --- a/src/User/src/Service/UserService.php +++ b/src/User/src/Service/UserService.php @@ -275,7 +275,7 @@ public function sendActivationMail(User $user): bool return $this->mailService->send()->isValid(); } - public function findOneBy(array $params = []): ?UserInterface + public function findOneBy(array $params = []): ?User { if (empty($params)) { return null; @@ -344,7 +344,7 @@ public function getRepository(): UserRepository /** * @throws Exception */ - public function addRememberMeToken(UserInterface|User $user, string $userAgent, array $cookies = []): void + public function addRememberMeToken(User $user, string $userAgent, array $cookies = []): void { $this->deleteExpiredRememberMeTokens(); diff --git a/src/User/src/Service/UserServiceInterface.php b/src/User/src/Service/UserServiceInterface.php index ae181dea..4eaf646d 100644 --- a/src/User/src/Service/UserServiceInterface.php +++ b/src/User/src/Service/UserServiceInterface.php @@ -18,7 +18,7 @@ public function createUser(array $data): UserInterface; */ public function sendActivationMail(User $user): bool; - public function findOneBy(array $params = []): ?UserInterface; + public function findOneBy(array $params = []): ?User; public function activateUser(User $user): User; @@ -26,7 +26,7 @@ public function findByUuid(string $uuid): ?User; public function getRepository(): UserRepository; - public function addRememberMeToken(UserInterface|User $user, string $userAgent, array $cookies = []): void; + public function addRememberMeToken(User $user, string $userAgent, array $cookies = []): void; public function deleteRememberMeToken(array $cookies = []): void;