Skip to content

Commit

Permalink
phpstan bug fix
Browse files Browse the repository at this point in the history
Signed-off-by: MarioRadu <[email protected]>
  • Loading branch information
MarioRadu committed Nov 21, 2024
1 parent 29c328d commit 44887ea
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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

6 changes: 3 additions & 3 deletions src/App/src/Middleware/RememberMeMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
) {
}
Expand Down
6 changes: 3 additions & 3 deletions src/User/src/Entity/UserRememberMe.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/User/src/Repository/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions src/User/src/Service/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions src/User/src/Service/UserServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ 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;

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;

Expand Down

0 comments on commit 44887ea

Please sign in to comment.