mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
Fixed PHPstan issues
This commit is contained in:
parent
6be55d1837
commit
f265b9d19d
5 changed files with 53 additions and 15 deletions
11
phpstan.neon
11
phpstan.neon
|
@ -19,6 +19,10 @@ parameters:
|
||||||
symfony:
|
symfony:
|
||||||
container_xml_path: '%rootDir%/../../../var/cache/dev/App_KernelDevDebugContainer.xml'
|
container_xml_path: '%rootDir%/../../../var/cache/dev/App_KernelDevDebugContainer.xml'
|
||||||
|
|
||||||
|
doctrine:
|
||||||
|
objectManagerLoader: tests/object-manager.php
|
||||||
|
allowNullablePropertyForRequiredField: true
|
||||||
|
|
||||||
checkUninitializedProperties: true
|
checkUninitializedProperties: true
|
||||||
|
|
||||||
checkFunctionNameCase: true
|
checkFunctionNameCase: true
|
||||||
|
@ -48,8 +52,11 @@ parameters:
|
||||||
ignoreErrors:
|
ignoreErrors:
|
||||||
# Ignore errors caused by complex mapping with AbstractStructuralDBElement
|
# Ignore errors caused by complex mapping with AbstractStructuralDBElement
|
||||||
- '#AbstractStructuralDBElement does not have a field named \$parent#'
|
- '#AbstractStructuralDBElement does not have a field named \$parent#'
|
||||||
- '#AbstractStructuralDBElement does not have a field named \$name#'
|
#- '#AbstractStructuralDBElement does not have a field named \$name#'
|
||||||
|
|
||||||
# Ignore errors related to the use of the ParametersTrait in Part entity
|
# Ignore errors related to the use of the ParametersTrait in Part entity
|
||||||
- '#expects .*PartParameter, .*AbstractParameter given.#'
|
- '#expects .*PartParameter, .*AbstractParameter given.#'
|
||||||
- '#Part::getParameters\(\) should return .*AbstractParameter#'
|
- '#Part::getParameters\(\) should return .*AbstractParameter#'
|
||||||
|
|
||||||
|
# Ignore doctrine type mapping mismatch
|
||||||
|
- '#Property .* type mapping mismatch: property can contain .* but database expects .*#'
|
|
@ -411,6 +411,9 @@ class UserSettingsController extends AbstractController
|
||||||
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
|
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
|
||||||
|
|
||||||
$token = new ApiToken();
|
$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());
|
$token->setUser($this->getUser());
|
||||||
|
|
||||||
$secret = null;
|
$secret = null;
|
||||||
|
|
|
@ -36,9 +36,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||||
class MeasurementUnitAttachment extends Attachment
|
class MeasurementUnitAttachment extends Attachment
|
||||||
{
|
{
|
||||||
final public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class;
|
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\ManyToOne(targetEntity: MeasurementUnit::class, inversedBy: 'attachments')]
|
||||||
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
#[ORM\JoinColumn(name: 'element_id', nullable: false, onDelete: 'CASCADE')]
|
||||||
protected ?AttachmentContainingDBElement $element = null;
|
protected ?AttachmentContainingDBElement $element = null;
|
||||||
|
|
|
@ -118,12 +118,8 @@ class ApiTokenAuthenticator implements AuthenticatorInterface
|
||||||
|
|
||||||
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): Response
|
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): Response
|
||||||
{
|
{
|
||||||
if (null !== $this->translator) {
|
$errorMessage = $this->translator->trans($exception->getMessageKey(), $exception->getMessageData(),
|
||||||
$errorMessage = $this->translator->trans($exception->getMessageKey(), $exception->getMessageData(),
|
'security');
|
||||||
'security');
|
|
||||||
} else {
|
|
||||||
$errorMessage = strtr($exception->getMessageKey(), $exception->getMessageData());
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Response(
|
return new Response(
|
||||||
null,
|
null,
|
||||||
|
@ -152,8 +148,9 @@ class ApiTokenAuthenticator implements AuthenticatorInterface
|
||||||
|
|
||||||
return sprintf('Bearer %s', implode(',', $values));
|
return sprintf('Bearer %s', implode(',', $values));
|
||||||
}
|
}
|
||||||
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
|
|
||||||
{
|
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
|
||||||
return null;
|
{
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
32
tests/object-manager.php
Normal file
32
tests/object-manager.php
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 - 2023 Jan Böhmer (https://github.com/jbtronics)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published
|
||||||
|
* by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use App\Kernel;
|
||||||
|
use Symfony\Component\Dotenv\Dotenv;
|
||||||
|
|
||||||
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
|
(new Dotenv())->bootEnv(__DIR__ . '/../.env');
|
||||||
|
|
||||||
|
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
|
||||||
|
$kernel->boot();
|
||||||
|
return $kernel->getContainer()->get('doctrine')->getManager();
|
Loading…
Add table
Add a link
Reference in a new issue