Fixed some inspection issues

This commit is contained in:
Jan Böhmer 2022-12-18 19:45:04 +01:00
parent c6f1758a18
commit 8ae4e9fe05
39 changed files with 46 additions and 56 deletions

View file

@ -22,7 +22,7 @@ namespace App\DataTables\Filters\Constraints;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use \RuntimeException; use RuntimeException;
class NumberConstraint extends AbstractConstraint class NumberConstraint extends AbstractConstraint
{ {

View file

@ -378,7 +378,7 @@ final class PartsDataTable implements DataTableTypeInterface
->addGroupBy('suppliers') ->addGroupBy('suppliers')
->addGroupBy('attachments') ->addGroupBy('attachments')
->addGroupBy('partUnit') ->addGroupBy('partUnit')
->addGroupBy('parameters'); ->addGroupBy('parameters')
; ;
} }

View file

@ -185,7 +185,7 @@ abstract class Attachment extends AbstractNamedDBElement
//After the %PLACEHOLDER% comes a slash, so we can check if we have a placeholder via explode //After the %PLACEHOLDER% comes a slash, so we can check if we have a placeholder via explode
$tmp = explode('/', $this->path); $tmp = explode('/', $this->path);
return !in_array($tmp[0], array_merge(static::INTERNAL_PLACEHOLDER, static::BUILTIN_PLACEHOLDER)); return !in_array($tmp[0], array_merge(static::INTERNAL_PLACEHOLDER, static::BUILTIN_PLACEHOLDER), true);
} }
/** /**
@ -331,7 +331,7 @@ abstract class Attachment extends AbstractNamedDBElement
*/ */
public function getShowInTable(): bool public function getShowInTable(): bool
{ {
return (bool) $this->show_in_table; return $this->show_in_table;
} }
/** /**

View file

@ -259,7 +259,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
return round($this->amount); return round($this->amount);
} }
return (float) $this->amount; return $this->amount;
} }
/** /**

View file

@ -107,7 +107,7 @@ class Storelocation extends AbstractPartsContainingDBElement
*/ */
public function isFull(): bool public function isFull(): bool
{ {
return (bool) $this->is_full; return $this->is_full;
} }
/** /**

View file

@ -176,7 +176,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
*/ */
public function getObsolete(): bool public function getObsolete(): bool
{ {
return (bool) $this->obsolete; return $this->obsolete;
} }
/** /**

View file

@ -187,7 +187,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
if ($this->orderdetail && $this->orderdetail->getPart() && !$this->orderdetail->getPart()->useFloatAmount()) { if ($this->orderdetail && $this->orderdetail->getPart() && !$this->orderdetail->getPart()->useFloatAmount()) {
$tmp = round($this->price_related_quantity); $tmp = round($this->price_related_quantity);
return $tmp < 1 ? 1 : $tmp; return max($tmp, 1);
} }
return $this->price_related_quantity; return $this->price_related_quantity;

View file

@ -283,7 +283,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
*/ */
public function getUsername(): string public function getUsername(): string
{ {
return (string) $this->name; return $this->name;
} }
public function getUserIdentifier(): string public function getUserIdentifier(): string

View file

@ -50,8 +50,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
use function Sodium\add;
class PartBaseType extends AbstractType class PartBaseType extends AbstractType
{ {
protected Security $security; protected Security $security;

View file

@ -30,9 +30,6 @@ use App\Entity\LogSystem\ElementDeletedLogEntry;
use App\Entity\LogSystem\ElementEditedLogEntry; use App\Entity\LogSystem\ElementEditedLogEntry;
use App\Entity\UserSystem\User; use App\Entity\UserSystem\User;
use DateTime; use DateTime;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\ORMException;
use Doctrine\ORM\TransactionRequiredException;
use RuntimeException; use RuntimeException;
class LogEntryRepository extends DBElementRepository class LogEntryRepository extends DBElementRepository

View file

@ -166,7 +166,6 @@ class EntityURLGenerator
public function viewURL(Attachment $entity): ?string public function viewURL(Attachment $entity): ?string
{ {
if ($entity instanceof Attachment) {
if ($entity->isExternal()) { //For external attachments, return the link to external path if ($entity->isExternal()) { //For external attachments, return the link to external path
return $entity->getURL(); return $entity->getURL();
} }
@ -174,10 +173,6 @@ class EntityURLGenerator
return $this->attachmentURLGenerator->getViewURL($entity); return $this->attachmentURLGenerator->getViewURL($entity);
} }
//Otherwise throw an error
throw new EntityNotSupportedException('The given entity is not supported yet!');
}
public function downloadURL($entity): ?string public function downloadURL($entity): ?string
{ {
if ($entity instanceof Attachment) { if ($entity instanceof Attachment) {

View file

@ -26,7 +26,7 @@ use App\Entity\Parts\Part;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use function \mb_strlen; use function mb_strlen;
use function array_slice; use function array_slice;
/** /**

View file

@ -55,7 +55,7 @@ class UserCacheKeyGenerator
//If the user is null, then treat it as anonymous user. //If the user is null, then treat it as anonymous user.
//When the anonymous user is passed as user then use this path too. //When the anonymous user is passed as user then use this path too.
if (null === $user || !($user instanceof User) || User::ID_ANONYMOUS === $user->getID()) { if (!($user instanceof User) || User::ID_ANONYMOUS === $user->getID()) {
return 'user$_'.User::ID_ANONYMOUS; return 'user$_'.User::ID_ANONYMOUS;
} }

View file

@ -22,8 +22,8 @@ declare(strict_types=1);
namespace App\Tests\Controller; namespace App\Tests\Controller;
use App\Entity\UserSystem\User;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Proxies\__CG__\App\Entity\UserSystem\User;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/** /**
@ -44,7 +44,7 @@ class RedirectControllerTest extends WebTestCase
]); ]);
$this->client->disableReboot(); $this->client->disableReboot();
$this->client->catchExceptions(false); $this->client->catchExceptions(false);
$this->em = self::$container->get(EntityManagerInterface::class); $this->em = self::getContainer()->get(EntityManagerInterface::class);
$this->userRepo = $this->em->getRepository(User::class); $this->userRepo = $this->em->getRepository(User::class);
} }

View file

@ -40,7 +40,7 @@ class TreeViewNodeTest extends TestCase
{ {
$sub_nodes = []; $sub_nodes = [];
$sub_nodes[] = new TreeViewNode('Subnode 1'); $sub_nodes[] = new TreeViewNode('Subnode 1');
$sub_sub_nodes[] = []; $sub_sub_nodes = [];
$sub_sub_nodes[] = new TreeViewNode('Sub Subnode 1'); $sub_sub_nodes[] = new TreeViewNode('Sub Subnode 1');
$sub_sub_nodes[] = new TreeViewNode('Sub Subnode 2'); $sub_sub_nodes[] = new TreeViewNode('Sub Subnode 2');
$sub_nodes[] = new TreeViewNode('Subnode 2'); $sub_nodes[] = new TreeViewNode('Subnode 2');

View file

@ -35,7 +35,7 @@ class AttachmentURLGeneratorTest extends WebTestCase
{ {
//Get an service instance. //Get an service instance.
self::bootKernel(); self::bootKernel();
self::$service = self::$container->get(AttachmentURLGenerator::class); self::$service = self::getContainer()->get(AttachmentURLGenerator::class);
} }
public function dataProvider(): array public function dataProvider(): array

View file

@ -40,7 +40,7 @@ class BuiltinAttachmentsFinderTest extends WebTestCase
{ {
//Get an service instance. //Get an service instance.
self::bootKernel(); self::bootKernel();
self::$service = self::$container->get(BuiltinAttachmentsFinder::class); self::$service = self::getContainer()->get(BuiltinAttachmentsFinder::class);
} }
public function dataProvider(): array public function dataProvider(): array

View file

@ -32,7 +32,7 @@ class FileTypeFilterToolsTest extends WebTestCase
public static function setUpBeforeClass(): void public static function setUpBeforeClass(): void
{ {
self::bootKernel(); self::bootKernel();
self::$service = self::$container->get(FileTypeFilterTools::class); self::$service = self::getContainer()->get(FileTypeFilterTools::class);
} }
public function validateDataProvider(): array public function validateDataProvider(): array

View file

@ -40,7 +40,7 @@ class AmountFormatterTest extends WebTestCase
//Get an service instance. //Get an service instance.
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(AmountFormatter::class); $this->service = self::getContainer()->get(AmountFormatter::class);
} }
public function testFormatWithoutUnit(): void public function testFormatWithoutUnit(): void

View file

@ -43,7 +43,7 @@ class EntityImporterTest extends WebTestCase
//Get an service instance. //Get an service instance.
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(EntityImporter::class); $this->service = self::getContainer()->get(EntityImporter::class);
} }
public function testMassCreationResults(): void public function testMassCreationResults(): void

View file

@ -57,7 +57,7 @@ class BarcodeContentGeneratorTest extends KernelTestCase
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(BarcodeContentGenerator::class); $this->service = self::getContainer()->get(BarcodeContentGenerator::class);
} }
public function Barcode1DDataProvider(): array public function Barcode1DDataProvider(): array

View file

@ -54,7 +54,7 @@ class BarcodeNormalizerTest extends WebTestCase
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(BarcodeNormalizer::class); $this->service = self::getContainer()->get(BarcodeNormalizer::class);
} }
public function dataProvider(): array public function dataProvider(): array

View file

@ -55,7 +55,7 @@ class BarcodeRedirectorTest extends KernelTestCase
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(BarcodeRedirector::class); $this->service = self::getContainer()->get(BarcodeRedirector::class);
} }
public function urlDataProvider(): array public function urlDataProvider(): array

View file

@ -59,7 +59,7 @@ class LabelGeneratorTest extends WebTestCase
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(LabelGenerator::class); $this->service = self::getContainer()->get(LabelGenerator::class);
} }
public function supportsDataProvider(): array public function supportsDataProvider(): array

View file

@ -64,7 +64,7 @@ class LabelTextReplacerTest extends WebTestCase
//Get an service instance. //Get an service instance.
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(LabelTextReplacer::class); $this->service = self::getContainer()->get(LabelTextReplacer::class);
$this->target = new Part(); $this->target = new Part();
$this->target->setName('Part 1'); $this->target->setName('Part 1');

View file

@ -57,7 +57,7 @@ class AbstractElementProviderTest extends WebTestCase
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(AbstractDBElementProvider::class); $this->service = self::getContainer()->get(AbstractDBElementProvider::class);
$this->target = new class() extends AbstractDBElement { $this->target = new class() extends AbstractDBElement {
protected ?int $id = 123; protected ?int $id = 123;
}; };

View file

@ -57,7 +57,7 @@ class GlobalProvidersTest extends WebTestCase
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(GlobalProviders::class); $this->service = self::getContainer()->get(GlobalProviders::class);
$this->target = new Part(); $this->target = new Part();
} }

View file

@ -57,7 +57,7 @@ class NamedElementProviderTest extends WebTestCase
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(NamedElementProvider::class); $this->service = self::getContainer()->get(NamedElementProvider::class);
$this->target = new class() implements NamedElementInterface { $this->target = new class() implements NamedElementInterface {
public function getName(): string public function getName(): string
{ {

View file

@ -68,9 +68,9 @@ class PartProviderTest extends WebTestCase
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(PartProvider::class); $this->service = self::getContainer()->get(PartProvider::class);
$this->target = new Part(); $this->target = new Part();
$this->em = self::$container->get(EntityManagerInterface::class); $this->em = self::getContainer()->get(EntityManagerInterface::class);
$this->target->setCategory($this->em->find(Category::class, 6)); $this->target->setCategory($this->em->find(Category::class, 6));
$this->target->setFootprint($this->em->find(Footprint::class, 6)); $this->target->setFootprint($this->em->find(Footprint::class, 6));

View file

@ -60,7 +60,7 @@ class TimestampableElementProviderTest extends WebTestCase
{ {
self::bootKernel(); self::bootKernel();
\Locale::setDefault('en'); \Locale::setDefault('en');
$this->service = self::$container->get(TimestampableElementProvider::class); $this->service = self::getContainer()->get(TimestampableElementProvider::class);
$this->target = new class() implements TimeStampableInterface { $this->target = new class() implements TimeStampableInterface {
public function getLastModified(): ?DateTime public function getLastModified(): ?DateTime
{ {

View file

@ -57,7 +57,7 @@ class EventCommentHelperTest extends WebTestCase
//Get an service instance. //Get an service instance.
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(EventCommentHelper::class); $this->service = self::getContainer()->get(EventCommentHelper::class);
} }
public function testInitialState(): void public function testInitialState(): void

View file

@ -60,7 +60,7 @@ class EventLoggerTest extends WebTestCase
//Get an service instance. //Get an service instance.
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(EventLogger::class); $this->service = self::getContainer()->get(EventLogger::class);
} }
public function testShouldBeAdded(): void public function testShouldBeAdded(): void

View file

@ -29,7 +29,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class FAIconGeneratorTest extends WebTestCase class FAIconGeneratorTest extends WebTestCase
{ {
/** /**
* @var AmountFormatter * @var FAIconGenerator
*/ */
protected $service; protected $service;
@ -39,7 +39,7 @@ class FAIconGeneratorTest extends WebTestCase
//Get an service instance. //Get an service instance.
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(FAIconGenerator::class); $this->service = self::getContainer()->get(FAIconGenerator::class);
} }
public function fileExtensionDataProvider(): array public function fileExtensionDataProvider(): array

View file

@ -54,7 +54,7 @@ class RangeParserTest extends WebTestCase
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(RangeParser::class); $this->service = self::getContainer()->get(RangeParser::class);
} }
public function dataProvider(): array public function dataProvider(): array

View file

@ -54,7 +54,7 @@ class ParameterExtractorTest extends WebTestCase
parent::setUp(); parent::setUp();
//Get an service instance. //Get an service instance.
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(ParameterExtractor::class); $this->service = self::getContainer()->get(ParameterExtractor::class);
} }
public function emptyDataProvider(): array public function emptyDataProvider(): array

View file

@ -41,7 +41,7 @@ class PricedetailHelperTest extends WebTestCase
parent::setUp(); parent::setUp();
//Get an service instance. //Get an service instance.
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(PricedetailHelper::class); $this->service = self::getContainer()->get(PricedetailHelper::class);
} }
public function maxDiscountAmountDataProvider(): ?\Generator public function maxDiscountAmountDataProvider(): ?\Generator

View file

@ -41,8 +41,8 @@ class NodesListBuilderTest extends WebTestCase
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(NodesListBuilder::class); $this->service = self::getContainer()->get(NodesListBuilder::class);
$this->em = self::$container->get(EntityManagerInterface::class); $this->em = self::getContainer()->get(EntityManagerInterface::class);
} }
/** /**

View file

@ -46,8 +46,8 @@ class TreeViewGeneratorTest extends WebTestCase
//Get an service instance. //Get an service instance.
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(TreeViewGenerator::class); $this->service = self::getContainer()->get(TreeViewGenerator::class);
$this->em = self::$container->get(EntityManagerInterface::class); $this->em = self::getContainer()->get(EntityManagerInterface::class);
} }
public function testGetGenericTree(): void public function testGetGenericTree(): void

View file

@ -36,7 +36,7 @@ class BackupCodeManagerTest extends WebTestCase
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->service = self::$container->get(BackupCodeManager::class); $this->service = self::getContainer()->get(BackupCodeManager::class);
} }
public function testRegenerateBackupCodes(): void public function testRegenerateBackupCodes(): void