mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-27 12:18:54 +02:00
Applied rector suggestions
This commit is contained in:
parent
4106bcef5f
commit
20f32c7f12
170 changed files with 808 additions and 761 deletions
|
@ -74,15 +74,10 @@ abstract class BaseAdminController extends AbstractController
|
|||
protected string $attachment_class = '';
|
||||
protected ?string $parameter_class = '';
|
||||
|
||||
/**
|
||||
* @var EventDispatcher|EventDispatcherInterface
|
||||
*/
|
||||
protected EventDispatcher|EventDispatcherInterface $eventDispatcher;
|
||||
|
||||
public function __construct(protected TranslatorInterface $translator, protected UserPasswordHasherInterface $passwordEncoder,
|
||||
protected AttachmentSubmitHandler $attachmentSubmitHandler,
|
||||
protected EventCommentHelper $commentHelper, protected HistoryHelper $historyHelper, protected TimeTravel $timeTravel,
|
||||
protected DataTableFactory $dataTableFactory, EventDispatcherInterface $eventDispatcher, protected LabelExampleElementsGenerator $barcodeExampleGenerator,
|
||||
protected DataTableFactory $dataTableFactory, protected EventDispatcher|EventDispatcherInterface $eventDispatcher, protected LabelExampleElementsGenerator $barcodeExampleGenerator,
|
||||
protected LabelGenerator $labelGenerator, protected EntityManagerInterface $entityManager)
|
||||
{
|
||||
if ('' === $this->entity_class || '' === $this->form_class || '' === $this->twig_template || '' === $this->route_base) {
|
||||
|
@ -96,7 +91,6 @@ abstract class BaseAdminController extends AbstractController
|
|||
if ('' === $this->parameter_class || ($this->parameter_class && !is_a($this->parameter_class, AbstractParameter::class, true))) {
|
||||
throw new InvalidArgumentException('You have to override the $parameter_class value with a valid Parameter class in your subclass!');
|
||||
}
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
protected function revertElementIfNeeded(AbstractDBElement $entity, ?string $timestamp): ?DateTime
|
||||
|
@ -192,10 +186,8 @@ abstract class BaseAdminController extends AbstractController
|
|||
}
|
||||
|
||||
//Ensure that the master picture is still part of the attachments
|
||||
if ($entity instanceof AttachmentContainingDBElement) {
|
||||
if ($entity->getMasterPictureAttachment() !== null && !$entity->getAttachments()->contains($entity->getMasterPictureAttachment())) {
|
||||
$entity->setMasterPictureAttachment(null);
|
||||
}
|
||||
if ($entity instanceof AttachmentContainingDBElement && ($entity->getMasterPictureAttachment() !== null && !$entity->getAttachments()->contains($entity->getMasterPictureAttachment()))) {
|
||||
$entity->setMasterPictureAttachment(null);
|
||||
}
|
||||
|
||||
$this->commentHelper->setMessage($form['log_comment']->getData());
|
||||
|
@ -283,10 +275,8 @@ abstract class BaseAdminController extends AbstractController
|
|||
}
|
||||
|
||||
//Ensure that the master picture is still part of the attachments
|
||||
if ($new_entity instanceof AttachmentContainingDBElement) {
|
||||
if ($new_entity->getMasterPictureAttachment() !== null && !$new_entity->getAttachments()->contains($new_entity->getMasterPictureAttachment())) {
|
||||
$new_entity->setMasterPictureAttachment(null);
|
||||
}
|
||||
if ($new_entity instanceof AttachmentContainingDBElement && ($new_entity->getMasterPictureAttachment() !== null && !$new_entity->getAttachments()->contains($new_entity->getMasterPictureAttachment()))) {
|
||||
$new_entity->setMasterPictureAttachment(null);
|
||||
}
|
||||
|
||||
$this->commentHelper->setMessage($form['log_comment']->getData());
|
||||
|
|
|
@ -30,6 +30,9 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
/**
|
||||
* @see \App\Tests\Controller\KiCadApiControllerTest
|
||||
*/
|
||||
#[Route('/kicad-api/v1')]
|
||||
class KiCadApiController extends AbstractController
|
||||
{
|
||||
|
@ -62,7 +65,7 @@ class KiCadApiController extends AbstractController
|
|||
#[Route('/parts/category/{category}.json', name: 'kicad_api_category')]
|
||||
public function categoryParts(?Category $category): Response
|
||||
{
|
||||
if ($category) {
|
||||
if ($category !== null) {
|
||||
$this->denyAccessUnlessGranted('read', $category);
|
||||
} else {
|
||||
$this->denyAccessUnlessGranted('@categories.read');
|
||||
|
|
|
@ -51,7 +51,7 @@ class OAuthClientController extends AbstractController
|
|||
}
|
||||
|
||||
#[Route('/{name}/check', name: 'oauth_client_check')]
|
||||
public function check(string $name, Request $request): Response
|
||||
public function check(string $name): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('@system.manage_oauth_tokens');
|
||||
|
||||
|
|
|
@ -329,7 +329,7 @@ class PartController extends AbstractController
|
|||
$this->em->flush();
|
||||
if ($mode === 'new') {
|
||||
$this->addFlash('success', 'part.created_flash');
|
||||
} else if ($mode === 'edit') {
|
||||
} elseif ($mode === 'edit') {
|
||||
$this->addFlash('success', 'part.edited_flash');
|
||||
}
|
||||
|
||||
|
@ -358,11 +358,11 @@ class PartController extends AbstractController
|
|||
$template = '';
|
||||
if ($mode === 'new') {
|
||||
$template = 'parts/edit/new_part.html.twig';
|
||||
} else if ($mode === 'edit') {
|
||||
} elseif ($mode === 'edit') {
|
||||
$template = 'parts/edit/edit_part_info.html.twig';
|
||||
} else if ($mode === 'merge') {
|
||||
} elseif ($mode === 'merge') {
|
||||
$template = 'parts/edit/merge_parts.html.twig';
|
||||
} else if ($mode === 'update_from_ip') {
|
||||
} elseif ($mode === 'update_from_ip') {
|
||||
$template = 'parts/edit/update_from_ip.html.twig';
|
||||
}
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ class ProjectController extends AbstractController
|
|||
'project' => $project,
|
||||
'part' => $part
|
||||
]);
|
||||
if ($bom_entry) {
|
||||
if ($bom_entry !== null) {
|
||||
$preset_data->add($bom_entry);
|
||||
} else { //Otherwise create an empty one
|
||||
$entry = new ProjectBOMEntry();
|
||||
|
|
|
@ -54,6 +54,9 @@ use Symfony\Component\HttpFoundation\Response;
|
|||
use Symfony\Component\HttpKernel\Attribute\MapQueryParameter;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
/**
|
||||
* @see \App\Tests\Controller\ScanControllerTest
|
||||
*/
|
||||
#[Route(path: '/scan')]
|
||||
class ScanController extends AbstractController
|
||||
{
|
||||
|
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
|||
*/
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Component\Runtime\SymfonyRuntime;
|
||||
use App\Services\Attachments\AttachmentSubmitHandler;
|
||||
use App\Services\Attachments\AttachmentURLGenerator;
|
||||
use App\Services\Attachments\BuiltinAttachmentsFinder;
|
||||
|
@ -84,7 +85,7 @@ class ToolsController extends AbstractController
|
|||
'php_post_max_size' => ini_get('post_max_size'),
|
||||
'kernel_runtime_environment' => $this->getParameter('kernel.runtime_environment'),
|
||||
'kernel_runtime_mode' => $this->getParameter('kernel.runtime_mode'),
|
||||
'kernel_runtime' => $_SERVER['APP_RUNTIME'] ?? $_ENV['APP_RUNTIME'] ?? 'Symfony\\Component\\Runtime\\SymfonyRuntime',
|
||||
'kernel_runtime' => $_SERVER['APP_RUNTIME'] ?? $_ENV['APP_RUNTIME'] ?? SymfonyRuntime::class,
|
||||
|
||||
//DB section
|
||||
'db_type' => $DBInfoHelper->getDatabaseType() ?? 'Unknown',
|
||||
|
|
|
@ -59,11 +59,8 @@ use Symfony\Component\Validator\Constraints\Length;
|
|||
#[Route(path: '/user')]
|
||||
class UserSettingsController extends AbstractController
|
||||
{
|
||||
protected EventDispatcher|EventDispatcherInterface $eventDispatcher;
|
||||
|
||||
public function __construct(protected bool $demo_mode, EventDispatcherInterface $eventDispatcher)
|
||||
public function __construct(protected bool $demo_mode, protected EventDispatcher|EventDispatcherInterface $eventDispatcher)
|
||||
{
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
#[Route(path: '/2fa_backup_codes', name: 'show_backup_codes')]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue