Fixed PHPstan issues

This commit is contained in:
Jan Böhmer 2023-08-28 22:39:29 +02:00
parent 6be55d1837
commit f265b9d19d
5 changed files with 53 additions and 15 deletions

View file

@ -411,6 +411,9 @@ class UserSettingsController extends AbstractController
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
$token = new ApiToken();
if (!$this->getUser() instanceof User) {
throw new RuntimeException('This controller only works only for Part-DB User objects!');
}
$token->setUser($this->getUser());
$secret = null;

View file

@ -36,9 +36,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
class MeasurementUnitAttachment extends Attachment
{
final public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class;
/**
* @var Manufacturer|null the element this attachment is associated with
*/
#[ORM\ManyToOne(targetEntity: MeasurementUnit::class, inversedBy: 'attachments')]
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
protected ?AttachmentContainingDBElement $element = null;

View file

@ -118,12 +118,8 @@ class ApiTokenAuthenticator implements AuthenticatorInterface
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): Response
{
if (null !== $this->translator) {
$errorMessage = $this->translator->trans($exception->getMessageKey(), $exception->getMessageData(),
'security');
} else {
$errorMessage = strtr($exception->getMessageKey(), $exception->getMessageData());
}
$errorMessage = $this->translator->trans($exception->getMessageKey(), $exception->getMessageData(),
'security');
return new Response(
null,
@ -152,8 +148,9 @@ class ApiTokenAuthenticator implements AuthenticatorInterface
return sprintf('Bearer %s', implode(',', $values));
}
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
{
return null;
}
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
{
return null;
}
}