diff --git a/src/ApiPlatform/Filter/EntityFilterHelper.php b/src/ApiPlatform/Filter/EntityFilterHelper.php
index ddb55ae7..42cc567f 100644
--- a/src/ApiPlatform/Filter/EntityFilterHelper.php
+++ b/src/ApiPlatform/Filter/EntityFilterHelper.php
@@ -81,12 +81,12 @@ class EntityFilterHelper
public function getDescription(array $properties): array
{
- if (!$properties) {
+ if ($properties === []) {
return [];
}
$description = [];
- foreach ($properties as $property => $strategy) {
+ foreach (array_keys($properties) as $property) {
$description[(string)$property] = [
'property' => $property,
'type' => Type::BUILTIN_TYPE_STRING,
diff --git a/src/ApiPlatform/Filter/LikeFilter.php b/src/ApiPlatform/Filter/LikeFilter.php
index 90ac8e59..f88c89b1 100644
--- a/src/ApiPlatform/Filter/LikeFilter.php
+++ b/src/ApiPlatform/Filter/LikeFilter.php
@@ -61,7 +61,7 @@ final class LikeFilter extends AbstractFilter
}
$description = [];
- foreach ($this->properties as $property => $strategy) {
+ foreach (array_keys($this->properties) as $property) {
$description[(string)$property] = [
'property' => $property,
'type' => Type::BUILTIN_TYPE_STRING,
diff --git a/src/Controller/AdminPages/BaseAdminController.php b/src/Controller/AdminPages/BaseAdminController.php
index 8f3bb902..d953b9bc 100644
--- a/src/Controller/AdminPages/BaseAdminController.php
+++ b/src/Controller/AdminPages/BaseAdminController.php
@@ -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());
diff --git a/src/Controller/KiCadApiController.php b/src/Controller/KiCadApiController.php
index a45e71dd..c28e87a6 100644
--- a/src/Controller/KiCadApiController.php
+++ b/src/Controller/KiCadApiController.php
@@ -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');
diff --git a/src/Controller/OAuthClientController.php b/src/Controller/OAuthClientController.php
index 388c7e16..9606a4e4 100644
--- a/src/Controller/OAuthClientController.php
+++ b/src/Controller/OAuthClientController.php
@@ -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');
diff --git a/src/Controller/PartController.php b/src/Controller/PartController.php
index 20b07fd9..d6acb36b 100644
--- a/src/Controller/PartController.php
+++ b/src/Controller/PartController.php
@@ -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';
}
diff --git a/src/Controller/ProjectController.php b/src/Controller/ProjectController.php
index 9afdb645..761e498c 100644
--- a/src/Controller/ProjectController.php
+++ b/src/Controller/ProjectController.php
@@ -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();
diff --git a/src/Controller/ScanController.php b/src/Controller/ScanController.php
index 93fbb822..77183c89 100644
--- a/src/Controller/ScanController.php
+++ b/src/Controller/ScanController.php
@@ -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
{
diff --git a/src/Controller/ToolsController.php b/src/Controller/ToolsController.php
index 984e50eb..8f49d6f7 100644
--- a/src/Controller/ToolsController.php
+++ b/src/Controller/ToolsController.php
@@ -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',
diff --git a/src/Controller/UserSettingsController.php b/src/Controller/UserSettingsController.php
index 364cea58..4587d0a1 100644
--- a/src/Controller/UserSettingsController.php
+++ b/src/Controller/UserSettingsController.php
@@ -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')]
diff --git a/src/DataTables/Adapters/TwoStepORMAdapter.php b/src/DataTables/Adapters/TwoStepORMAdapter.php
index e225ce2f..2086c907 100644
--- a/src/DataTables/Adapters/TwoStepORMAdapter.php
+++ b/src/DataTables/Adapters/TwoStepORMAdapter.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace App\DataTables\Adapters;
+use Doctrine\ORM\Query\Expr\From;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Doctrine\ORM\Tools\Pagination\Paginator;
@@ -51,12 +52,12 @@ class TwoStepORMAdapter extends ORMAdapter
private bool $use_simple_total = false;
- private \Closure|null $query_modifier;
+ private \Closure|null $query_modifier = null;
public function __construct(ManagerRegistry $registry = null)
{
parent::__construct($registry);
- $this->detailQueryCallable = static function (QueryBuilder $qb, array $ids) {
+ $this->detailQueryCallable = static function (QueryBuilder $qb, array $ids): never {
throw new \RuntimeException('You need to set the detail_query option to use the TwoStepORMAdapter');
};
}
@@ -66,9 +67,7 @@ class TwoStepORMAdapter extends ORMAdapter
parent::configureOptions($resolver);
$resolver->setRequired('filter_query');
- $resolver->setDefault('query', function (Options $options) {
- return $options['filter_query'];
- });
+ $resolver->setDefault('query', fn(Options $options) => $options['filter_query']);
$resolver->setRequired('detail_query');
$resolver->setAllowedTypes('detail_query', \Closure::class);
@@ -108,7 +107,7 @@ class TwoStepORMAdapter extends ORMAdapter
}
}
- /** @var Query\Expr\From $fromClause */
+ /** @var From $fromClause */
$fromClause = $builder->getDQLPart('from')[0];
$identifier = "{$fromClause->getAlias()}.{$this->metadata->getSingleIdentifierFieldName()}";
@@ -201,7 +200,7 @@ class TwoStepORMAdapter extends ORMAdapter
/** The paginator count queries can be rather slow, so when query for total count (100ms or longer),
* just return the entity count.
*/
- /** @var Query\Expr\From $from_expr */
+ /** @var From $from_expr */
$from_expr = $queryBuilder->getDQLPart('from')[0];
return $this->manager->getRepository($from_expr->getFrom())->count([]);
diff --git a/src/DataTables/AttachmentDataTable.php b/src/DataTables/AttachmentDataTable.php
index a53d61c9..da1cef0f 100644
--- a/src/DataTables/AttachmentDataTable.php
+++ b/src/DataTables/AttachmentDataTable.php
@@ -92,7 +92,7 @@ final class AttachmentDataTable implements DataTableTypeInterface
if ($context->isExternal()) {
return sprintf(
'%s',
- htmlspecialchars($context->getURL()),
+ htmlspecialchars((string) $context->getURL()),
htmlspecialchars($value)
);
}
diff --git a/src/DataTables/Column/EnumColumn.php b/src/DataTables/Column/EnumColumn.php
index e41b79e4..5a5d998d 100644
--- a/src/DataTables/Column/EnumColumn.php
+++ b/src/DataTables/Column/EnumColumn.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\DataTables\Column;
use Omines\DataTablesBundle\Column\AbstractColumn;
diff --git a/src/DataTables/Helpers/ColumnSortHelper.php b/src/DataTables/Helpers/ColumnSortHelper.php
index c61ad6ce..05bd8182 100644
--- a/src/DataTables/Helpers/ColumnSortHelper.php
+++ b/src/DataTables/Helpers/ColumnSortHelper.php
@@ -109,7 +109,7 @@ class ColumnSortHelper
}
//and the remaining non-visible columns
- foreach ($this->columns as $col_id => $col_data) {
+ foreach (array_keys($this->columns) as $col_id) {
if (in_array($col_id, $processed_columns, true)) {
// column already processed
continue;
diff --git a/src/DataTables/LogDataTable.php b/src/DataTables/LogDataTable.php
index b14c1b1f..f6604279 100644
--- a/src/DataTables/LogDataTable.php
+++ b/src/DataTables/LogDataTable.php
@@ -162,7 +162,7 @@ class LogDataTable implements DataTableTypeInterface
if (!$user instanceof User) {
if ($context->isCLIEntry()) {
return sprintf('%s [%s]',
- htmlentities($context->getCLIUsername()),
+ htmlentities((string) $context->getCLIUsername()),
$this->translator->trans('log.cli_user')
);
}
diff --git a/src/DataTables/PartsDataTable.php b/src/DataTables/PartsDataTable.php
index 7f1df5e5..28c564b1 100644
--- a/src/DataTables/PartsDataTable.php
+++ b/src/DataTables/PartsDataTable.php
@@ -156,7 +156,7 @@ final class PartsDataTable implements DataTableTypeInterface
'orderField' => 'NATSORT(_partUnit.name)',
'render' => function($value, Part $context): string {
$partUnit = $context->getPartUnit();
- if (!$partUnit) {
+ if ($partUnit === null) {
return '';
}
@@ -184,7 +184,7 @@ final class PartsDataTable implements DataTableTypeInterface
'label' => $this->translator->trans('part.table.manufacturingStatus'),
'class' => ManufacturingStatus::class,
'render' => function (?ManufacturingStatus $status, Part $context): string {
- if (!$status) {
+ if ($status === null) {
return '';
}
diff --git a/src/DataTables/ProjectBomEntriesDataTable.php b/src/DataTables/ProjectBomEntriesDataTable.php
index c59ca3bd..84a89320 100644
--- a/src/DataTables/ProjectBomEntriesDataTable.php
+++ b/src/DataTables/ProjectBomEntriesDataTable.php
@@ -85,7 +85,7 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
'orderField' => 'NATSORT(part.name)',
'render' => function ($value, ProjectBOMEntry $context) {
if(!$context->getPart() instanceof Part) {
- return htmlspecialchars($context->getName());
+ return htmlspecialchars((string) $context->getName());
}
if($context->getPart() instanceof Part) {
$tmp = $this->partDataTableHelper->renderName($context->getPart());
@@ -154,7 +154,7 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
'label' => 'project.bom.instockAmount',
'visible' => false,
'render' => function ($value, ProjectBOMEntry $context) {
- if ($context->getPart()) {
+ if ($context->getPart() !== null) {
return $this->partDataTableHelper->renderAmount($context->getPart());
}
@@ -165,7 +165,7 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
'label' => 'part.table.storeLocations',
'visible' => false,
'render' => function ($value, ProjectBOMEntry $context) {
- if ($context->getPart()) {
+ if ($context->getPart() !== null) {
return $this->partDataTableHelper->renderStorageLocations($context->getPart());
}
diff --git a/src/Doctrine/Functions/Field2.php b/src/Doctrine/Functions/Field2.php
index 3b57fa27..57f55653 100644
--- a/src/Doctrine/Functions/Field2.php
+++ b/src/Doctrine/Functions/Field2.php
@@ -23,6 +23,8 @@ declare(strict_types=1);
namespace App\Doctrine\Functions;
+use Doctrine\ORM\Query\Parser;
+use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\TokenType;
@@ -36,7 +38,7 @@ class Field2 extends FunctionNode
private $values = [];
- public function parse(\Doctrine\ORM\Query\Parser $parser): void
+ public function parse(Parser $parser): void
{
$parser->match(TokenType::T_IDENTIFIER);
$parser->match(TokenType::T_OPEN_PARENTHESIS);
@@ -58,15 +60,16 @@ class Field2 extends FunctionNode
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
}
- public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker): string
+ public function getSql(SqlWalker $sqlWalker): string
{
$query = 'FIELD2(';
$query .= $this->field->dispatch($sqlWalker);
$query .= ', ';
+ $counter = count($this->values);
- for ($i = 0; $i < count($this->values); $i++) {
+ for ($i = 0; $i < $counter; $i++) {
if ($i > 0) {
$query .= ', ';
}
@@ -74,8 +77,6 @@ class Field2 extends FunctionNode
$query .= $this->values[$i]->dispatch($sqlWalker);
}
- $query .= ')';
-
- return $query;
+ return $query . ')';
}
}
\ No newline at end of file
diff --git a/src/Doctrine/Functions/Natsort.php b/src/Doctrine/Functions/Natsort.php
index cf6fded9..fc60058f 100644
--- a/src/Doctrine/Functions/Natsort.php
+++ b/src/Doctrine/Functions/Natsort.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace App\Doctrine\Functions;
+use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver;
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
@@ -59,9 +60,9 @@ class Natsort extends FunctionNode
* The result is cached in memory.
* @param Connection $connection
* @return bool
- * @throws \Doctrine\DBAL\Exception
+ * @throws Exception
*/
- private static function mariaDBSupportsNaturalSort(Connection $connection): bool
+ private function mariaDBSupportsNaturalSort(Connection $connection): bool
{
if (self::$supportsNaturalSort !== null) {
return self::$supportsNaturalSort;
@@ -95,7 +96,7 @@ class Natsort extends FunctionNode
return $this->field->dispatch($sqlWalker) . ' COLLATE numeric';
}
- if ($platform instanceof MariaDBPlatform && self::mariaDBSupportsNaturalSort($sqlWalker->getConnection())) {
+ if ($platform instanceof MariaDBPlatform && $this->mariaDBSupportsNaturalSort($sqlWalker->getConnection())) {
return 'NATURAL_SORT_KEY(' . $this->field->dispatch($sqlWalker) . ')';
}
diff --git a/src/Doctrine/Helpers/FieldHelper.php b/src/Doctrine/Helpers/FieldHelper.php
index d49df4e3..11300db3 100644
--- a/src/Doctrine/Helpers/FieldHelper.php
+++ b/src/Doctrine/Helpers/FieldHelper.php
@@ -109,7 +109,7 @@ final class FieldHelper
//If we are on MySQL, we can just use the FIELD function
if ($db_platform instanceof AbstractMySQLPlatform) {
$qb->orderBy("FIELD2($field_expr, :field_arr)", $order);
- } else if ($db_platform instanceof PostgreSQLPlatform) {
+ } elseif ($db_platform instanceof PostgreSQLPlatform) {
//Use the postgres native array_position function
self::addPostgresOrderBy($qb, $field_expr, $key, $values, $order);
} else {
diff --git a/src/Doctrine/Middleware/SQLiteRegexExtensionMiddlewareDriver.php b/src/Doctrine/Middleware/SQLiteRegexExtensionMiddlewareDriver.php
index c991d7b7..80a81612 100644
--- a/src/Doctrine/Middleware/SQLiteRegexExtensionMiddlewareDriver.php
+++ b/src/Doctrine/Middleware/SQLiteRegexExtensionMiddlewareDriver.php
@@ -98,10 +98,9 @@ class SQLiteRegexExtensionMiddlewareDriver extends AbstractDriverMiddleware
* This function returns the index (position) of the first argument in the subsequent arguments.
* If the first argument is not found or is NULL, 0 is returned.
* @param string|int|null $value
- * @param mixed ...$array
* @return int
*/
- final public static function field(string|int|null $value, ...$array): int
+ final public static function field(string|int|null $value, mixed ...$array): int
{
if ($value === null) {
return 0;
diff --git a/src/Entity/Attachments/Attachment.php b/src/Entity/Attachments/Attachment.php
index a53a8d41..aa849fa4 100644
--- a/src/Entity/Attachments/Attachment.php
+++ b/src/Entity/Attachments/Attachment.php
@@ -385,7 +385,7 @@ abstract class Attachment extends AbstractNamedDBElement
return null;
}
- return parse_url($this->getURL(), PHP_URL_HOST);
+ return parse_url((string) $this->getURL(), PHP_URL_HOST);
}
/**
@@ -477,7 +477,7 @@ abstract class Attachment extends AbstractNamedDBElement
*/
public function setElement(AttachmentContainingDBElement $element): self
{
- if (!is_a($element, static::ALLOWED_ELEMENT_CLASS)) {
+ if (!$element instanceof AttachmentContainingDBElement) {
throw new InvalidArgumentException(sprintf('The element associated with a %s must be a %s!', static::class, static::ALLOWED_ELEMENT_CLASS));
}
diff --git a/src/Entity/Attachments/AttachmentType.php b/src/Entity/Attachments/AttachmentType.php
index 214f0af1..e0c530f1 100644
--- a/src/Entity/Attachments/AttachmentType.php
+++ b/src/Entity/Attachments/AttachmentType.php
@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Entity\Attachments;
+use Doctrine\Common\Collections\Criteria;
use ApiPlatform\Doctrine\Common\Filter\DateFilterInterface;
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
@@ -85,8 +86,11 @@ use Symfony\Component\Validator\Constraints as Assert;
#[ApiFilter(OrderFilter::class, properties: ['name', 'id', 'addedDate', 'lastModified'])]
class AttachmentType extends AbstractStructuralDBElement
{
+ /**
+ * @var Collection
+ */
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: AttachmentType::class, cascade: ['persist'])]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
protected Collection $children;
#[ORM\ManyToOne(targetEntity: AttachmentType::class, inversedBy: 'children')]
@@ -110,7 +114,7 @@ class AttachmentType extends AbstractStructuralDBElement
*/
#[Assert\Valid]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: AttachmentTypeAttachment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
#[Groups(['attachment_type:read', 'attachment_type:write'])]
protected Collection $attachments;
@@ -123,7 +127,7 @@ class AttachmentType extends AbstractStructuralDBElement
*/
#[Assert\Valid]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: AttachmentTypeParameter::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
+ #[ORM\OrderBy(['group' => Criteria::ASC, 'name' => 'ASC'])]
#[Groups(['attachment_type:read', 'attachment_type:write'])]
protected Collection $parameters;
diff --git a/src/Entity/LabelSystem/BarcodeType.php b/src/Entity/LabelSystem/BarcodeType.php
index 0794b606..daf7d401 100644
--- a/src/Entity/LabelSystem/BarcodeType.php
+++ b/src/Entity/LabelSystem/BarcodeType.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Entity\LabelSystem;
enum BarcodeType: string
diff --git a/src/Entity/LabelSystem/LabelPictureType.php b/src/Entity/LabelSystem/LabelPictureType.php
index c9183ca6..c1f90fe2 100644
--- a/src/Entity/LabelSystem/LabelPictureType.php
+++ b/src/Entity/LabelSystem/LabelPictureType.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Entity\LabelSystem;
enum LabelPictureType: string
@@ -34,4 +36,4 @@ enum LabelPictureType: string
* Show the main attachment of the element on the label
*/
case MAIN_ATTACHMENT = 'main_attachment';
-}
\ No newline at end of file
+}
diff --git a/src/Entity/LabelSystem/LabelProcessMode.php b/src/Entity/LabelSystem/LabelProcessMode.php
index 76bf175f..d5967b49 100644
--- a/src/Entity/LabelSystem/LabelProcessMode.php
+++ b/src/Entity/LabelSystem/LabelProcessMode.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Entity\LabelSystem;
enum LabelProcessMode: string
@@ -26,4 +28,4 @@ enum LabelProcessMode: string
case PLACEHOLDER = 'html';
/** Interpret the given lines as twig template */
case TWIG = 'twig';
-}
\ No newline at end of file
+}
diff --git a/src/Entity/LabelSystem/LabelProfile.php b/src/Entity/LabelSystem/LabelProfile.php
index 0a5150e7..a59d9292 100644
--- a/src/Entity/LabelSystem/LabelProfile.php
+++ b/src/Entity/LabelSystem/LabelProfile.php
@@ -41,6 +41,7 @@ declare(strict_types=1);
namespace App\Entity\LabelSystem;
+use Doctrine\Common\Collections\Criteria;
use App\Entity\Attachments\Attachment;
use App\Repository\LabelProfileRepository;
use App\EntityListeners\TreeCacheInvalidationListener;
@@ -66,7 +67,7 @@ class LabelProfile extends AttachmentContainingDBElement
* @var Collection
*/
#[ORM\OneToMany(mappedBy: 'element', targetEntity: LabelAttachment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
protected Collection $attachments;
#[ORM\ManyToOne(targetEntity: LabelAttachment::class)]
diff --git a/src/Entity/LabelSystem/LabelSupportedElement.php b/src/Entity/LabelSystem/LabelSupportedElement.php
index 5007de7f..2f9afa85 100644
--- a/src/Entity/LabelSystem/LabelSupportedElement.php
+++ b/src/Entity/LabelSystem/LabelSupportedElement.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Entity\LabelSystem;
use App\Entity\Parts\Part;
@@ -42,4 +44,4 @@ enum LabelSupportedElement: string
self::STORELOCATION => StorageLocation::class,
};
}
-}
\ No newline at end of file
+}
diff --git a/src/Entity/LogSystem/AbstractLogEntry.php b/src/Entity/LogSystem/AbstractLogEntry.php
index cbccbbf0..6b6eb7f3 100644
--- a/src/Entity/LogSystem/AbstractLogEntry.php
+++ b/src/Entity/LogSystem/AbstractLogEntry.php
@@ -55,7 +55,8 @@ abstract class AbstractLogEntry extends AbstractDBElement
#[ORM\Column(type: Types::STRING)]
protected string $username = '';
- /** @var \DateTime The datetime the event associated with this log entry has occured
+ /**
+ * @var \DateTimeInterface The datetime the event associated with this log entry has occured
*/
#[ORM\Column(name: 'datetime', type: Types::DATETIME_MUTABLE)]
protected \DateTime $timestamp;
diff --git a/src/Entity/LogSystem/LogLevel.php b/src/Entity/LogSystem/LogLevel.php
index fd0c678b..435c5468 100644
--- a/src/Entity/LogSystem/LogLevel.php
+++ b/src/Entity/LogSystem/LogLevel.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Entity\LogSystem;
use Psr\Log\LogLevel as PSRLogLevel;
diff --git a/src/Entity/LogSystem/LogTargetType.php b/src/Entity/LogSystem/LogTargetType.php
index 6e413079..1c6e4f8c 100644
--- a/src/Entity/LogSystem/LogTargetType.php
+++ b/src/Entity/LogSystem/LogTargetType.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Entity\LogSystem;
use App\Entity\Attachments\Attachment;
@@ -120,7 +122,7 @@ enum LogTargetType: int
}
}
- $elementClass = is_object($element) ? get_class($element) : $element;
+ $elementClass = is_object($element) ? $element::class : $element;
//If no matching type was found, throw an exception
throw new \InvalidArgumentException("The given class $elementClass is not a valid log target type.");
}
diff --git a/src/Entity/LogSystem/LogWithEventUndoTrait.php b/src/Entity/LogSystem/LogWithEventUndoTrait.php
index 16568241..ed8629dc 100644
--- a/src/Entity/LogSystem/LogWithEventUndoTrait.php
+++ b/src/Entity/LogSystem/LogWithEventUndoTrait.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Entity\LogSystem;
use App\Entity\Contracts\LogWithEventUndoInterface;
@@ -48,4 +50,4 @@ trait LogWithEventUndoTrait
$mode_int = $this->extra['um'] ?? 1;
return EventUndoMode::fromExtraInt($mode_int);
}
-}
\ No newline at end of file
+}
diff --git a/src/Entity/LogSystem/PartStockChangeType.php b/src/Entity/LogSystem/PartStockChangeType.php
index 92c5073f..f69fe95f 100644
--- a/src/Entity/LogSystem/PartStockChangeType.php
+++ b/src/Entity/LogSystem/PartStockChangeType.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Entity\LogSystem;
enum PartStockChangeType: string
@@ -53,4 +55,4 @@ enum PartStockChangeType: string
default => throw new \InvalidArgumentException("Invalid short type: $value"),
};
}
-}
\ No newline at end of file
+}
diff --git a/src/Entity/LogSystem/PartStockChangedLogEntry.php b/src/Entity/LogSystem/PartStockChangedLogEntry.php
index dd7b5234..1bac9e9f 100644
--- a/src/Entity/LogSystem/PartStockChangedLogEntry.php
+++ b/src/Entity/LogSystem/PartStockChangedLogEntry.php
@@ -52,8 +52,6 @@ class PartStockChangedLogEntry extends AbstractLogEntry
$this->level = LogLevel::INFO;
$this->setTargetElement($lot);
-
- $this->typeString = 'part_stock_changed';
$this->extra = array_merge($this->extra, [
't' => $type->toExtraShortType(),
'o' => $old_stock,
diff --git a/src/Entity/OAuthToken.php b/src/Entity/OAuthToken.php
index 2ecf9342..54e86b74 100644
--- a/src/Entity/OAuthToken.php
+++ b/src/Entity/OAuthToken.php
@@ -38,7 +38,7 @@ use League\OAuth2\Client\Token\AccessTokenInterface;
class OAuthToken extends AbstractNamedDBElement implements AccessTokenInterface
{
/** @var string|null The short-term usable OAuth2 token */
- #[ORM\Column(type: 'text', nullable: true)]
+ #[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $token = null;
/** @var \DateTimeImmutable|null The date when the token expires */
@@ -46,7 +46,7 @@ class OAuthToken extends AbstractNamedDBElement implements AccessTokenInterface
private ?\DateTimeImmutable $expires_at = null;
/** @var string|null The refresh token for the OAuth2 auth */
- #[ORM\Column(type: 'text', nullable: true)]
+ #[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $refresh_token = null;
/**
diff --git a/src/Entity/Parts/Category.php b/src/Entity/Parts/Category.php
index ecd609ce..30a4cb5f 100644
--- a/src/Entity/Parts/Category.php
+++ b/src/Entity/Parts/Category.php
@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Entity\Parts;
+use Doctrine\Common\Collections\Criteria;
use ApiPlatform\Doctrine\Common\Filter\DateFilterInterface;
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
@@ -91,7 +92,7 @@ use Symfony\Component\Validator\Constraints as Assert;
class Category extends AbstractPartsContainingDBElement
{
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
protected Collection $children;
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
@@ -165,7 +166,7 @@ class Category extends AbstractPartsContainingDBElement
#[Assert\Valid]
#[Groups(['full', 'category:read', 'category:write'])]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: CategoryAttachment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
protected Collection $attachments;
#[ORM\ManyToOne(targetEntity: CategoryAttachment::class)]
@@ -178,7 +179,7 @@ class Category extends AbstractPartsContainingDBElement
#[Assert\Valid]
#[Groups(['full', 'category:read', 'category:write'])]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: CategoryParameter::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
+ #[ORM\OrderBy(['group' => Criteria::ASC, 'name' => 'ASC'])]
protected Collection $parameters;
#[Groups(['category:read'])]
diff --git a/src/Entity/Parts/Footprint.php b/src/Entity/Parts/Footprint.php
index 02c93694..238ffb35 100644
--- a/src/Entity/Parts/Footprint.php
+++ b/src/Entity/Parts/Footprint.php
@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Entity\Parts;
+use Doctrine\Common\Collections\Criteria;
use ApiPlatform\Doctrine\Common\Filter\DateFilterInterface;
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
@@ -96,7 +97,7 @@ class Footprint extends AbstractPartsContainingDBElement
protected ?AbstractStructuralDBElement $parent = null;
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
protected Collection $children;
#[Groups(['footprint:read', 'footprint:write'])]
@@ -107,7 +108,7 @@ class Footprint extends AbstractPartsContainingDBElement
*/
#[Assert\Valid]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: FootprintAttachment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
#[Groups(['footprint:read', 'footprint:write'])]
protected Collection $attachments;
@@ -128,7 +129,7 @@ class Footprint extends AbstractPartsContainingDBElement
*/
#[Assert\Valid]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: FootprintParameter::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
+ #[ORM\OrderBy(['group' => Criteria::ASC, 'name' => 'ASC'])]
#[Groups(['footprint:read', 'footprint:write'])]
protected Collection $parameters;
diff --git a/src/Entity/Parts/InfoProviderReference.php b/src/Entity/Parts/InfoProviderReference.php
index 305c1d9b..550f82f5 100644
--- a/src/Entity/Parts/InfoProviderReference.php
+++ b/src/Entity/Parts/InfoProviderReference.php
@@ -31,25 +31,26 @@ use Symfony\Component\Serializer\Annotation\Groups;
/**
* This class represents a reference to a info provider inside a part.
+ * @see \App\Tests\Entity\Parts\InfoProviderReferenceTest
*/
#[Embeddable]
class InfoProviderReference
{
/** @var string|null The key referencing the provider used to get this part, or null if it was not provided by a data provider */
- #[Column(type: 'string', nullable: true)]
+ #[Column(type: Types::STRING, nullable: true)]
#[Groups(['provider_reference:read'])]
private ?string $provider_key = null;
/** @var string|null The id of this part inside the provider system or null if the part was not provided by a data provider */
- #[Column(type: 'string', nullable: true)]
+ #[Column(type: Types::STRING, nullable: true)]
#[Groups(['provider_reference:read'])]
private ?string $provider_id = null;
/**
* @var string|null The url of this part inside the provider system or null if this info is not existing
*/
- #[Column(type: 'string', nullable: true)]
+ #[Column(type: Types::STRING, nullable: true)]
#[Groups(['provider_reference:read'])]
private ?string $provider_url = null;
diff --git a/src/Entity/Parts/Manufacturer.php b/src/Entity/Parts/Manufacturer.php
index 94f83e68..0edf8232 100644
--- a/src/Entity/Parts/Manufacturer.php
+++ b/src/Entity/Parts/Manufacturer.php
@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Entity\Parts;
+use Doctrine\Common\Collections\Criteria;
use ApiPlatform\Doctrine\Common\Filter\DateFilterInterface;
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
@@ -95,7 +96,7 @@ class Manufacturer extends AbstractCompany
protected ?AbstractStructuralDBElement $parent = null;
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
protected Collection $children;
/**
@@ -103,7 +104,7 @@ class Manufacturer extends AbstractCompany
*/
#[Assert\Valid]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: ManufacturerAttachment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
#[Groups(['manufacturer:read', 'manufacturer:write'])]
#[ApiProperty(readableLink: false, writableLink: true)]
protected Collection $attachments;
@@ -118,7 +119,7 @@ class Manufacturer extends AbstractCompany
*/
#[Assert\Valid]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: ManufacturerParameter::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
+ #[ORM\OrderBy(['group' => Criteria::ASC, 'name' => 'ASC'])]
#[Groups(['manufacturer:read', 'manufacturer:write'])]
#[ApiProperty(readableLink: false, writableLink: true)]
protected Collection $parameters;
diff --git a/src/Entity/Parts/MeasurementUnit.php b/src/Entity/Parts/MeasurementUnit.php
index 870ad374..9e5abd2a 100644
--- a/src/Entity/Parts/MeasurementUnit.php
+++ b/src/Entity/Parts/MeasurementUnit.php
@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Entity\Parts;
+use Doctrine\Common\Collections\Criteria;
use ApiPlatform\Doctrine\Common\Filter\DateFilterInterface;
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
@@ -123,7 +124,7 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
protected bool $use_si_prefix = false;
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class, cascade: ['persist'])]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
protected Collection $children;
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
@@ -137,7 +138,7 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
*/
#[Assert\Valid]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: MeasurementUnitAttachment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
#[Groups(['measurement_unit:read', 'measurement_unit:write'])]
protected Collection $attachments;
@@ -150,7 +151,7 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
*/
#[Assert\Valid]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: MeasurementUnitParameter::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
+ #[ORM\OrderBy(['group' => Criteria::ASC, 'name' => 'ASC'])]
#[Groups(['measurement_unit:read', 'measurement_unit:write'])]
protected Collection $parameters;
diff --git a/src/Entity/Parts/Part.php b/src/Entity/Parts/Part.php
index 090eda8b..a563ad6e 100644
--- a/src/Entity/Parts/Part.php
+++ b/src/Entity/Parts/Part.php
@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Entity\Parts;
+use Doctrine\Common\Collections\Criteria;
use ApiPlatform\Doctrine\Common\Filter\DateFilterInterface;
use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
@@ -119,7 +120,7 @@ class Part extends AttachmentContainingDBElement
#[Assert\Valid]
#[Groups(['full', 'part:read', 'part:write'])]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: PartParameter::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
+ #[ORM\OrderBy(['group' => Criteria::ASC, 'name' => 'ASC'])]
#[UniqueObjectCollection(fields: ['name', 'group', 'element'])]
protected Collection $parameters;
@@ -140,7 +141,7 @@ class Part extends AttachmentContainingDBElement
#[Assert\Valid]
#[Groups(['full', 'part:read', 'part:write'])]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: PartAttachment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
protected Collection $attachments;
/**
diff --git a/src/Entity/Parts/PartAssociation.php b/src/Entity/Parts/PartAssociation.php
index 843a63ee..32017488 100644
--- a/src/Entity/Parts/PartAssociation.php
+++ b/src/Entity/Parts/PartAssociation.php
@@ -49,6 +49,7 @@ use Symfony\Component\Validator\Constraints\Length;
/**
* This entity describes a part association, which is a semantic connection between two parts.
* For example, a part association can be used to describe that a part is a replacement for another part.
+ * @see \App\Tests\Entity\Parts\PartAssociationTest
*/
#[ORM\Entity(repositoryClass: DBElementRepository::class)]
#[ORM\HasLifecycleCallbacks]
diff --git a/src/Entity/Parts/PartLot.php b/src/Entity/Parts/PartLot.php
index 25b40d5a..fdd39ba7 100644
--- a/src/Entity/Parts/PartLot.php
+++ b/src/Entity/Parts/PartLot.php
@@ -105,7 +105,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
protected string $comment = '';
/**
- * @var \DateTime|null Set a time until when the lot must be used.
+ * @var \DateTimeInterface|null Set a time until when the lot must be used.
* Set to null, if the lot can be used indefinitely.
*/
#[Groups(['extended', 'full', 'import', 'part_lot:read', 'part_lot:write'])]
diff --git a/src/Entity/Parts/PartTraits/InstockTrait.php b/src/Entity/Parts/PartTraits/InstockTrait.php
index 5f73243d..08b070f3 100644
--- a/src/Entity/Parts/PartTraits/InstockTrait.php
+++ b/src/Entity/Parts/PartTraits/InstockTrait.php
@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Entity\Parts\PartTraits;
+use Doctrine\Common\Collections\Criteria;
use Doctrine\DBAL\Types\Types;
use App\Entity\Parts\MeasurementUnit;
use App\Entity\Parts\PartLot;
@@ -42,7 +43,7 @@ trait InstockTrait
#[Assert\Valid]
#[Groups(['extended', 'full', 'import', 'part:read', 'part:write'])]
#[ORM\OneToMany(mappedBy: 'part', targetEntity: PartLot::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['amount' => 'DESC'])]
+ #[ORM\OrderBy(['amount' => Criteria::DESC])]
protected Collection $partLots;
/**
diff --git a/src/Entity/Parts/PartTraits/OrderTrait.php b/src/Entity/Parts/PartTraits/OrderTrait.php
index 0a914e24..2c142016 100644
--- a/src/Entity/Parts/PartTraits/OrderTrait.php
+++ b/src/Entity/Parts/PartTraits/OrderTrait.php
@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Entity\Parts\PartTraits;
+use Doctrine\Common\Collections\Criteria;
use Doctrine\DBAL\Types\Types;
use App\Entity\PriceInformations\Orderdetail;
use Symfony\Component\Serializer\Annotation\Groups;
@@ -41,7 +42,7 @@ trait OrderTrait
#[Assert\Valid]
#[Groups(['extended', 'full', 'import', 'part:read', 'part:write'])]
#[ORM\OneToMany(mappedBy: 'part', targetEntity: Orderdetail::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['supplierpartnr' => 'ASC'])]
+ #[ORM\OrderBy(['supplierpartnr' => Criteria::ASC])]
protected Collection $orderdetails;
/**
diff --git a/src/Entity/Parts/StorageLocation.php b/src/Entity/Parts/StorageLocation.php
index c88decac..782b11cb 100644
--- a/src/Entity/Parts/StorageLocation.php
+++ b/src/Entity/Parts/StorageLocation.php
@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Entity\Parts;
+use Doctrine\Common\Collections\Criteria;
use ApiPlatform\Doctrine\Common\Filter\DateFilterInterface;
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
@@ -90,7 +91,7 @@ use Symfony\Component\Validator\Constraints as Assert;
class StorageLocation extends AbstractPartsContainingDBElement
{
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
protected Collection $children;
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
@@ -114,7 +115,7 @@ class StorageLocation extends AbstractPartsContainingDBElement
*/
#[Assert\Valid]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: StorageLocationParameter::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
+ #[ORM\OrderBy(['group' => Criteria::ASC, 'name' => 'ASC'])]
#[Groups(['location:read', 'location:write'])]
protected Collection $parameters;
diff --git a/src/Entity/Parts/Supplier.php b/src/Entity/Parts/Supplier.php
index 12373593..6b01a92c 100644
--- a/src/Entity/Parts/Supplier.php
+++ b/src/Entity/Parts/Supplier.php
@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Entity\Parts;
+use Doctrine\Common\Collections\Criteria;
use ApiPlatform\Doctrine\Common\Filter\DateFilterInterface;
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
@@ -92,7 +93,7 @@ use Symfony\Component\Validator\Constraints as Assert;
class Supplier extends AbstractCompany
{
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
protected Collection $children;
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
@@ -129,7 +130,7 @@ class Supplier extends AbstractCompany
*/
#[Assert\Valid]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: SupplierAttachment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
#[Groups(['supplier:read', 'supplier:write'])]
#[ApiProperty(readableLink: false, writableLink: true)]
protected Collection $attachments;
@@ -144,7 +145,7 @@ class Supplier extends AbstractCompany
*/
#[Assert\Valid]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: SupplierParameter::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
+ #[ORM\OrderBy(['group' => Criteria::ASC, 'name' => 'ASC'])]
#[Groups(['supplier:read', 'supplier:write'])]
#[ApiProperty(readableLink: false, writableLink: true)]
protected Collection $parameters;
diff --git a/src/Entity/PriceInformations/Currency.php b/src/Entity/PriceInformations/Currency.php
index 4e9a9acc..cd7c2bc9 100644
--- a/src/Entity/PriceInformations/Currency.php
+++ b/src/Entity/PriceInformations/Currency.php
@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Entity\PriceInformations;
+use Doctrine\Common\Collections\Criteria;
use ApiPlatform\Doctrine\Common\Filter\DateFilterInterface;
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
@@ -118,7 +119,7 @@ class Currency extends AbstractStructuralDBElement
protected string $iso_code = "";
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class, cascade: ['persist'])]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
protected Collection $children;
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
@@ -132,7 +133,7 @@ class Currency extends AbstractStructuralDBElement
*/
#[Assert\Valid]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: CurrencyAttachment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
#[Groups(['currency:read', 'currency:write'])]
protected Collection $attachments;
@@ -145,7 +146,7 @@ class Currency extends AbstractStructuralDBElement
*/
#[Assert\Valid]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: CurrencyParameter::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
+ #[ORM\OrderBy(['group' => Criteria::ASC, 'name' => 'ASC'])]
#[Groups(['currency:read', 'currency:write'])]
protected Collection $parameters;
diff --git a/src/Entity/PriceInformations/Orderdetail.php b/src/Entity/PriceInformations/Orderdetail.php
index 811df111..1275ebc2 100644
--- a/src/Entity/PriceInformations/Orderdetail.php
+++ b/src/Entity/PriceInformations/Orderdetail.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace App\Entity\PriceInformations;
+use Doctrine\Common\Collections\Criteria;
use ApiPlatform\Doctrine\Common\Filter\DateFilterInterface;
use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
@@ -96,10 +97,13 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
{
use TimestampTrait;
+ /**
+ * @var Collection
+ */
#[Assert\Valid]
#[Groups(['extended', 'full', 'import', 'orderdetail:read', 'orderdetail:write'])]
#[ORM\OneToMany(mappedBy: 'orderdetail', targetEntity: Pricedetail::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['min_discount_quantity' => 'ASC'])]
+ #[ORM\OrderBy(['min_discount_quantity' => Criteria::ASC])]
protected Collection $pricedetails;
/**
diff --git a/src/Entity/ProjectSystem/Project.php b/src/Entity/ProjectSystem/Project.php
index e537984f..5703388b 100644
--- a/src/Entity/ProjectSystem/Project.php
+++ b/src/Entity/ProjectSystem/Project.php
@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Entity\ProjectSystem;
+use Doctrine\Common\Collections\Criteria;
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiProperty;
@@ -88,7 +89,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
class Project extends AbstractStructuralDBElement
{
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
protected Collection $children;
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
@@ -100,6 +101,9 @@ class Project extends AbstractStructuralDBElement
#[Groups(['project:read', 'project:write'])]
protected string $comment = '';
+ /**
+ * @var Collection
+ */
#[Assert\Valid]
#[Groups(['extended', 'full'])]
#[ORM\OneToMany(mappedBy: 'project', targetEntity: ProjectBOMEntry::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
@@ -137,7 +141,7 @@ class Project extends AbstractStructuralDBElement
* @var Collection
*/
#[ORM\OneToMany(mappedBy: 'element', targetEntity: ProjectAttachment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
#[Groups(['project:read', 'project:write'])]
protected Collection $attachments;
@@ -149,7 +153,7 @@ class Project extends AbstractStructuralDBElement
/** @var Collection
*/
#[ORM\OneToMany(mappedBy: 'element', targetEntity: ProjectParameter::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
+ #[ORM\OrderBy(['group' => Criteria::ASC, 'name' => 'ASC'])]
#[Groups(['project:read', 'project:write'])]
protected Collection $parameters;
diff --git a/src/Entity/UserSystem/Group.php b/src/Entity/UserSystem/Group.php
index 32056cc9..6da9d35f 100644
--- a/src/Entity/UserSystem/Group.php
+++ b/src/Entity/UserSystem/Group.php
@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Entity\UserSystem;
+use Doctrine\Common\Collections\Criteria;
use App\Entity\Attachments\Attachment;
use App\Validator\Constraints\NoLockout;
use Doctrine\DBAL\Types\Types;
@@ -49,7 +50,7 @@ use Symfony\Component\Validator\Constraints as Assert;
class Group extends AbstractStructuralDBElement implements HasPermissionsInterface
{
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
protected Collection $children;
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
@@ -74,7 +75,7 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa
*/
#[Assert\Valid]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: GroupAttachment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
protected Collection $attachments;
#[ORM\ManyToOne(targetEntity: GroupAttachment::class)]
@@ -91,7 +92,7 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa
*/
#[Assert\Valid]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: GroupParameter::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
+ #[ORM\OrderBy(['group' => Criteria::ASC, 'name' => 'ASC'])]
protected Collection $parameters;
public function __construct()
diff --git a/src/Entity/UserSystem/User.php b/src/Entity/UserSystem/User.php
index 7d8c181a..7b81afe5 100644
--- a/src/Entity/UserSystem/User.php
+++ b/src/Entity/UserSystem/User.php
@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\Entity\UserSystem;
+use Doctrine\Common\Collections\Criteria;
use ApiPlatform\Doctrine\Common\Filter\DateFilterInterface;
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
@@ -267,7 +268,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
* @var Collection
*/
#[ORM\OneToMany(mappedBy: 'element', targetEntity: UserAttachment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[ORM\OrderBy(['name' => 'ASC'])]
+ #[ORM\OrderBy(['name' => Criteria::ASC])]
#[Groups(['user:read', 'user:write'])]
protected Collection $attachments;
@@ -317,7 +318,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
protected ?PermissionData $permissions = null;
/**
- * @var \DateTime|null the time until the password reset token is valid
+ * @var \DateTimeInterface|null the time until the password reset token is valid
*/
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
protected ?\DateTime $pw_reset_expires = null;
diff --git a/src/Form/AttachmentFormType.php b/src/Form/AttachmentFormType.php
index 109c6602..957d692b 100644
--- a/src/Form/AttachmentFormType.php
+++ b/src/Form/AttachmentFormType.php
@@ -142,7 +142,7 @@ class AttachmentFormType extends AbstractType
if (!$file instanceof UploadedFile) {
//When no file was uploaded, but a URL was entered, try to determine the attachment name from the URL
- if (empty($attachment->getName()) && !empty($attachment->getURL())) {
+ if ((trim($attachment->getName()) === '') && ($attachment->getURL() !== null && $attachment->getURL() !== '')) {
$name = basename(parse_url($attachment->getURL(), PHP_URL_PATH));
$attachment->setName($name);
}
diff --git a/src/Form/PasswordTypeExtension.php b/src/Form/PasswordTypeExtension.php
index a911bf90..64711c53 100644
--- a/src/Form/PasswordTypeExtension.php
+++ b/src/Form/PasswordTypeExtension.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Form;
use Symfony\Component\Form\AbstractTypeExtension;
@@ -51,4 +53,4 @@ class PasswordTypeExtension extends AbstractTypeExtension
$view->vars['password_estimator'] = $options['password_estimator'];
}
-}
\ No newline at end of file
+}
diff --git a/src/Form/Permissions/PermissionsType.php b/src/Form/Permissions/PermissionsType.php
index c0fbb4e8..86fdbc2c 100644
--- a/src/Form/Permissions/PermissionsType.php
+++ b/src/Form/Permissions/PermissionsType.php
@@ -45,9 +45,7 @@ class PermissionsType extends AbstractType
$resolver->setDefaults([
'show_legend' => true,
'show_presets' => false,
- 'show_dependency_notice' => static function (Options $options) {
- return !$options['disabled'];
- },
+ 'show_dependency_notice' => static fn(Options $options) => !$options['disabled'],
'constraints' => static function (Options $options) {
if (!$options['disabled']) {
return [new NoLockout()];
diff --git a/src/Form/ProjectSystem/ProjectAddPartsType.php b/src/Form/ProjectSystem/ProjectAddPartsType.php
index ea51764a..61f72c41 100644
--- a/src/Form/ProjectSystem/ProjectAddPartsType.php
+++ b/src/Form/ProjectSystem/ProjectAddPartsType.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Form\ProjectSystem;
use App\Entity\ProjectSystem\Project;
@@ -83,4 +85,4 @@ class ProjectAddPartsType extends AbstractType
$resolver->setAllowedTypes('project', ['null', Project::class]);
}
-}
\ No newline at end of file
+}
diff --git a/src/Form/Type/Helper/StructuralEntityChoiceHelper.php b/src/Form/Type/Helper/StructuralEntityChoiceHelper.php
index 0c596f83..e8e19ad6 100644
--- a/src/Form/Type/Helper/StructuralEntityChoiceHelper.php
+++ b/src/Form/Type/Helper/StructuralEntityChoiceHelper.php
@@ -100,7 +100,7 @@ class StructuralEntityChoiceHelper
public function generateChoiceAttrCurrency(Currency $choice, Options|array $options): array
{
$tmp = $this->generateChoiceAttr($choice, $options);
- $symbol = empty($choice->getIsoCode()) ? null : Currencies::getSymbol($choice->getIsoCode());
+ $symbol = $choice->getIsoCode() === '' ? null : Currencies::getSymbol($choice->getIsoCode());
$tmp['data-short'] = $options['short'] ? $symbol : $choice->getName();
//Show entities that are not added to DB yet separately from other entities
diff --git a/src/Form/Type/Helper/StructuralEntityChoiceLoader.php b/src/Form/Type/Helper/StructuralEntityChoiceLoader.php
index a527a44f..b79fad1b 100644
--- a/src/Form/Type/Helper/StructuralEntityChoiceLoader.php
+++ b/src/Form/Type/Helper/StructuralEntityChoiceLoader.php
@@ -52,11 +52,7 @@ class StructuralEntityChoiceLoader extends AbstractChoiceLoader
protected function loadChoices(): iterable
{
//If the starting_element is set and not persisted yet, add it to the list
- if ($this->starting_element !== null && $this->starting_element->getID() === null) {
- $tmp = [$this->starting_element];
- } else {
- $tmp = [];
- }
+ $tmp = $this->starting_element !== null && $this->starting_element->getID() === null ? [$this->starting_element] : [];
if ($this->additional_element) {
$tmp = $this->createNewEntitiesFromValue($this->additional_element);
@@ -163,7 +159,7 @@ class StructuralEntityChoiceLoader extends AbstractChoiceLoader
// the same as the value that is generated for the same entity after it is persisted.
// Otherwise, errors occurs that the element could not be found.
foreach ($values as &$data) {
- $data = trim($data);
+ $data = trim((string) $data);
$data = preg_replace('/\s*->\s*/', '->', $data);
}
unset ($data);
diff --git a/src/Form/Type/StructuralEntityType.php b/src/Form/Type/StructuralEntityType.php
index 41ad1c97..1018eeeb 100644
--- a/src/Form/Type/StructuralEntityType.php
+++ b/src/Form/Type/StructuralEntityType.php
@@ -108,12 +108,8 @@ class StructuralEntityType extends AbstractType
$resolver->setDefault('dto_value', null);
$resolver->setAllowedTypes('dto_value', ['null', 'string']);
//If no help text is explicitly set, we use the dto value as help text and show it as html
- $resolver->setDefault('help', function (Options $options) {
- return $this->dtoText($options['dto_value']);
- });
- $resolver->setDefault('help_html', function (Options $options) {
- return $options['dto_value'] !== null;
- });
+ $resolver->setDefault('help', fn(Options $options) => $this->dtoText($options['dto_value']));
+ $resolver->setDefault('help_html', fn(Options $options) => $options['dto_value'] !== null);
$resolver->setDefault('attr', function (Options $options) {
$tmp = [
diff --git a/src/Helpers/FilenameSanatizer.php b/src/Helpers/FilenameSanatizer.php
index 3dca5995..0ca07dfc 100644
--- a/src/Helpers/FilenameSanatizer.php
+++ b/src/Helpers/FilenameSanatizer.php
@@ -47,9 +47,9 @@ class FilenameSanatizer
'-', $filename);
// avoids ".", ".." or ".hiddenFiles"
- $filename = ltrim($filename, '.-');
+ $filename = ltrim((string) $filename, '.-');
//Limit filename length to 255 bytes
$ext = pathinfo($filename, PATHINFO_EXTENSION);
- return mb_strcut(pathinfo($filename, PATHINFO_FILENAME), 0, 255 - ($ext ? strlen($ext) + 1 : 0), mb_detect_encoding($filename)) . ($ext ? '.' . $ext : '');
+ return mb_strcut(pathinfo($filename, PATHINFO_FILENAME), 0, 255 - ($ext !== '' && $ext !== '0' ? strlen($ext) + 1 : 0), mb_detect_encoding($filename)) . ($ext !== '' && $ext !== '0' ? '.' . $ext : '');
}
}
\ No newline at end of file
diff --git a/src/Helpers/Projects/ProjectBuildRequest.php b/src/Helpers/Projects/ProjectBuildRequest.php
index c2c2ad90..430d37b5 100644
--- a/src/Helpers/Projects/ProjectBuildRequest.php
+++ b/src/Helpers/Projects/ProjectBuildRequest.php
@@ -174,11 +174,7 @@ final class ProjectBuildRequest
*/
public function getLotWithdrawAmount(PartLot|int $lot): float
{
- if ($lot instanceof PartLot) {
- $lot_id = $lot->getID();
- } else { // Then it must be an int
- $lot_id = $lot;
- }
+ $lot_id = $lot instanceof PartLot ? $lot->getID() : $lot;
if (! array_key_exists($lot_id, $this->withdraw_amounts)) {
throw new \InvalidArgumentException('The given lot is not in the withdraw amounts array!');
diff --git a/src/Helpers/TrinaryLogicHelper.php b/src/Helpers/TrinaryLogicHelper.php
index 54ab9bf8..f4b460de 100644
--- a/src/Helpers/TrinaryLogicHelper.php
+++ b/src/Helpers/TrinaryLogicHelper.php
@@ -26,6 +26,7 @@ namespace App\Helpers;
/**
* Helper functions for logic operations with trinary logic.
* True and false are represented as classical boolean values, undefined is represented as null.
+ * @see \App\Tests\Helpers\TrinaryLogicHelperTest
*/
class TrinaryLogicHelper
{
diff --git a/src/Migration/WithPermPresetsTrait.php b/src/Migration/WithPermPresetsTrait.php
index debbade8..5182f3b6 100644
--- a/src/Migration/WithPermPresetsTrait.php
+++ b/src/Migration/WithPermPresetsTrait.php
@@ -64,7 +64,7 @@ trait WithPermPresetsTrait
public function setContainer(ContainerInterface $container = null): void
{
- if ($container) {
+ if ($container !== null) {
$this->container = $container;
$this->permission_presets_helper = $container->get(PermissionPresetsHelper::class);
}
diff --git a/src/Repository/AttachmentContainingDBElementRepository.php b/src/Repository/AttachmentContainingDBElementRepository.php
index 7c81c38a..40869662 100644
--- a/src/Repository/AttachmentContainingDBElementRepository.php
+++ b/src/Repository/AttachmentContainingDBElementRepository.php
@@ -30,6 +30,7 @@ use Doctrine\ORM\Mapping\ClassMetadata;
/**
* @template TEntityClass of AttachmentContainingDBElement
* @extends NamedDBElementRepository
+ * @see \App\Tests\Repository\AttachmentContainingDBElementRepositoryTest
*/
class AttachmentContainingDBElementRepository extends NamedDBElementRepository
{
diff --git a/src/Repository/DBElementRepository.php b/src/Repository/DBElementRepository.php
index 90bd5927..2437e848 100644
--- a/src/Repository/DBElementRepository.php
+++ b/src/Repository/DBElementRepository.php
@@ -49,6 +49,7 @@ use ReflectionClass;
/**
* @template TEntityClass of AbstractDBElement
* @extends EntityRepository
+ * @see \App\Tests\Repository\DBElementRepositoryTest
*/
class DBElementRepository extends EntityRepository
{
@@ -143,9 +144,7 @@ class DBElementRepository extends EntityRepository
*/
protected function sortResultArrayByIDArray(array &$result_array, array $ids): void
{
- usort($result_array, static function (AbstractDBElement $a, AbstractDBElement $b) use ($ids) {
- return array_search($a->getID(), $ids, true) <=> array_search($b->getID(), $ids, true);
- });
+ usort($result_array, static fn(AbstractDBElement $a, AbstractDBElement $b) => array_search($a->getID(), $ids, true) <=> array_search($b->getID(), $ids, true));
}
protected function setField(AbstractDBElement $element, string $field, int $new_value): void
diff --git a/src/Repository/NamedDBElementRepository.php b/src/Repository/NamedDBElementRepository.php
index e62c64e7..8c78cb5e 100644
--- a/src/Repository/NamedDBElementRepository.php
+++ b/src/Repository/NamedDBElementRepository.php
@@ -29,6 +29,7 @@ use App\Helpers\Trees\TreeViewNode;
/**
* @template TEntityClass of AbstractNamedDBElement
* @extends DBElementRepository
+ * @see \App\Tests\Repository\NamedDBElementRepositoryTest
*/
class NamedDBElementRepository extends DBElementRepository
{
diff --git a/src/Repository/StructuralDBElementRepository.php b/src/Repository/StructuralDBElementRepository.php
index c7548cc9..47c85db3 100644
--- a/src/Repository/StructuralDBElementRepository.php
+++ b/src/Repository/StructuralDBElementRepository.php
@@ -52,7 +52,7 @@ class StructuralDBElementRepository extends AttachmentContainingDBElementReposit
$qb->select('e')
->orderBy('NATSORT(e.name)', $nameOrdering);
- if ($parent) {
+ if ($parent !== null) {
$qb->where('e.parent = :parent')
->setParameter('parent', $parent);
} else {
@@ -260,7 +260,7 @@ class StructuralDBElementRepository extends AttachmentContainingDBElementReposit
//Try to find if we already have an element cached for this name
$entity = $this->getNewEntityFromCache($name, null);
- if ($entity) {
+ if ($entity !== null) {
return $entity;
}
diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php
index 9f24520d..bbaa2b39 100644
--- a/src/Repository/UserRepository.php
+++ b/src/Repository/UserRepository.php
@@ -36,6 +36,7 @@ use Symfony\Component\Security\Core\User\UserInterface;
* @method User[] findAll()
* @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
* @extends NamedDBElementRepository
+ * @see \App\Tests\Repository\UserRepositoryTest
*/
final class UserRepository extends NamedDBElementRepository implements PasswordUpgraderInterface
{
diff --git a/src/Security/TwoFactor/WebauthnKeyLastUseTwoFactorProvider.php b/src/Security/TwoFactor/WebauthnKeyLastUseTwoFactorProvider.php
index 5d67e36f..9bfa691d 100644
--- a/src/Security/TwoFactor/WebauthnKeyLastUseTwoFactorProvider.php
+++ b/src/Security/TwoFactor/WebauthnKeyLastUseTwoFactorProvider.php
@@ -44,12 +44,12 @@ class WebauthnKeyLastUseTwoFactorProvider implements TwoFactorProviderInterface
public function __construct(
#[AutowireDecorated]
- private TwoFactorProviderInterface $decorated,
- private EntityManagerInterface $entityManager,
+ private readonly TwoFactorProviderInterface $decorated,
+ private readonly EntityManagerInterface $entityManager,
#[Autowire(service: 'jbtronics_webauthn_tfa.user_public_key_source_repo')]
- private UserPublicKeyCredentialSourceRepository $publicKeyCredentialSourceRepository,
+ private readonly UserPublicKeyCredentialSourceRepository $publicKeyCredentialSourceRepository,
#[Autowire(service: 'jbtronics_webauthn_tfa.webauthn_provider')]
- private WebauthnProvider $webauthnProvider,
+ private readonly WebauthnProvider $webauthnProvider,
)
{
}
diff --git a/src/Serializer/APIPlatform/DetermineTypeFromElementIRIDenormalizer.php b/src/Serializer/APIPlatform/DetermineTypeFromElementIRIDenormalizer.php
index 863fbee6..8283dbbe 100644
--- a/src/Serializer/APIPlatform/DetermineTypeFromElementIRIDenormalizer.php
+++ b/src/Serializer/APIPlatform/DetermineTypeFromElementIRIDenormalizer.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace App\Serializer\APIPlatform;
+use ApiPlatform\Metadata\Exception\ResourceClassNotFoundException;
use ApiPlatform\Api\IriConverterInterface;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\Metadata\Post;
@@ -59,7 +60,7 @@ class DetermineTypeFromElementIRIDenormalizer implements DenormalizerInterface,
* @param array $input
* @param Operation $operation
* @return array
- * @throws \ApiPlatform\Metadata\Exception\ResourceClassNotFoundException
+ * @throws ResourceClassNotFoundException
*/
private function addTypeDiscriminatorIfNecessary(array $input, Operation $operation): array
{
diff --git a/src/Serializer/PartNormalizer.php b/src/Serializer/PartNormalizer.php
index a4890104..650b0214 100644
--- a/src/Serializer/PartNormalizer.php
+++ b/src/Serializer/PartNormalizer.php
@@ -161,7 +161,7 @@ class PartNormalizer implements NormalizerInterface, DenormalizerInterface, Norm
if (isset($data['supplier']) && $data['supplier'] !== "") {
$supplier = $this->locationDenormalizer->denormalize($data['supplier'], Supplier::class, $format, $context);
- if ($supplier) {
+ if ($supplier !== null) {
$orderdetail = new Orderdetail();
$orderdetail->setSupplier($supplier);
diff --git a/src/Services/Attachments/AttachmentPathResolver.php b/src/Services/Attachments/AttachmentPathResolver.php
index e6015b3a..e3e7a3ca 100644
--- a/src/Services/Attachments/AttachmentPathResolver.php
+++ b/src/Services/Attachments/AttachmentPathResolver.php
@@ -139,12 +139,12 @@ class AttachmentPathResolver
}
//If we have now have a placeholder left, the string is invalid:
- if (preg_match('#%\w+%#', $placeholder_path)) {
+ if (preg_match('#%\w+%#', (string) $placeholder_path)) {
return null;
}
//Path is invalid if path is directory traversal
- if (str_contains($placeholder_path, '..')) {
+ if (str_contains((string) $placeholder_path, '..')) {
return null;
}
@@ -183,7 +183,7 @@ class AttachmentPathResolver
}
//If the new string does not begin with a placeholder, it is invalid
- if (!preg_match('#^%\w+%#', $real_path)) {
+ if (!preg_match('#^%\w+%#', (string) $real_path)) {
return null;
}
diff --git a/src/Services/Attachments/AttachmentSubmitHandler.php b/src/Services/Attachments/AttachmentSubmitHandler.php
index d5fe9370..d9b2a380 100644
--- a/src/Services/Attachments/AttachmentSubmitHandler.php
+++ b/src/Services/Attachments/AttachmentSubmitHandler.php
@@ -300,7 +300,7 @@ class AttachmentSubmitHandler
return $attachment;
}
- $filename = basename($old_path);
+ $filename = basename((string) $old_path);
//If the basename is not one of the new unique on, we have to save the old filename
if (!preg_match('#\w+-\w{13}\.#', $filename)) {
//Save filename to attachment field
@@ -378,7 +378,7 @@ class AttachmentSubmitHandler
//If we don't know filename yet, try to determine it out of url
if ('' === $filename) {
- $filename = basename(parse_url($url, PHP_URL_PATH));
+ $filename = basename(parse_url((string) $url, PHP_URL_PATH));
}
//Set original file
diff --git a/src/Services/Cache/ElementCacheTagGenerator.php b/src/Services/Cache/ElementCacheTagGenerator.php
index 382c9317..88fca09f 100644
--- a/src/Services/Cache/ElementCacheTagGenerator.php
+++ b/src/Services/Cache/ElementCacheTagGenerator.php
@@ -46,11 +46,10 @@ class ElementCacheTagGenerator
{
//Ensure that the given element is a class name
if (is_object($element)) {
- $element = get_class($element);
- } else { //And that the class exists
- if (!class_exists($element)) {
- throw new \InvalidArgumentException("The given class '$element' does not exist!");
- }
+ $element = $element::class;
+ } elseif (!class_exists($element)) {
+ //And that the class exists
+ throw new \InvalidArgumentException("The given class '$element' does not exist!");
}
//Check if the tag is already cached
diff --git a/src/Services/EDA/KiCadHelper.php b/src/Services/EDA/KiCadHelper.php
index 05630d16..13de01e8 100644
--- a/src/Services/EDA/KiCadHelper.php
+++ b/src/Services/EDA/KiCadHelper.php
@@ -134,7 +134,7 @@ class KiCadHelper
if ($this->category_depth >= 0) {
//Ensure that the category is set
- if (!$category) {
+ if ($category === null) {
throw new NotFoundHttpException('Category must be set, if category_depth is greater than 1!');
}
@@ -196,25 +196,25 @@ class KiCadHelper
//Add basic fields
$result["fields"]["description"] = $this->createField($part->getDescription());
- if ($part->getCategory()) {
+ if ($part->getCategory() !== null) {
$result["fields"]["Category"] = $this->createField($part->getCategory()->getFullPath('/'));
}
- if ($part->getManufacturer()) {
+ if ($part->getManufacturer() !== null) {
$result["fields"]["Manufacturer"] = $this->createField($part->getManufacturer()->getName());
}
if ($part->getManufacturerProductNumber() !== "") {
$result['fields']["MPN"] = $this->createField($part->getManufacturerProductNumber());
}
- if ($part->getManufacturingStatus()) {
+ if ($part->getManufacturingStatus() !== null) {
$result["fields"]["Manufacturing Status"] = $this->createField(
//Always use the english translation
$this->translator->trans($part->getManufacturingStatus()->toTranslationKey(), locale: 'en')
);
}
- if ($part->getFootprint()) {
+ if ($part->getFootprint() !== null) {
$result["fields"]["Part-DB Footprint"] = $this->createField($part->getFootprint()->getName());
}
- if ($part->getPartUnit()) {
+ if ($part->getPartUnit() !== null) {
$unit = $part->getPartUnit()->getName();
if ($part->getPartUnit()->getUnit() !== "") {
$unit .= ' ('.$part->getPartUnit()->getUnit().')';
@@ -225,7 +225,7 @@ class KiCadHelper
$result["fields"]["Mass"] = $this->createField($part->getMass() . ' g');
}
$result["fields"]["Part-DB ID"] = $this->createField($part->getId());
- if (!empty($part->getIpn())) {
+ if ($part->getIpn() !== null && $part->getIpn() !== '' && $part->getIpn() !== '0') {
$result["fields"]["Part-DB IPN"] = $this->createField($part->getIpn());
}
@@ -308,14 +308,9 @@ class KiCadHelper
)) {
return true;
}
-
//And on the footprint
- if ($part->getFootprint() && $part->getFootprint()->getEdaInfo()->getKicadFootprint() !== null) {
- return true;
- }
-
//Otherwise the part should be not visible
- return false;
+ return $part->getFootprint() && $part->getFootprint()->getEdaInfo()->getKicadFootprint() !== null;
}
/**
diff --git a/src/Services/EntityMergers/EntityMerger.php b/src/Services/EntityMergers/EntityMerger.php
index 0f1355ea..c0be84ee 100644
--- a/src/Services/EntityMergers/EntityMerger.php
+++ b/src/Services/EntityMergers/EntityMerger.php
@@ -69,7 +69,7 @@ class EntityMerger
{
$merger = $this->findMergerForObject($target, $other, $context);
if ($merger === null) {
- throw new \RuntimeException('No merger found for merging '.get_class($other).' into '.get_class($target));
+ throw new \RuntimeException('No merger found for merging '.$other::class.' into '.$target::class);
}
return $merger->merge($target, $other, $context);
}
diff --git a/src/Services/EntityMergers/Mergers/EntityMergerHelperTrait.php b/src/Services/EntityMergers/Mergers/EntityMergerHelperTrait.php
index dcd0984a..a5c9a5fa 100644
--- a/src/Services/EntityMergers/Mergers/EntityMergerHelperTrait.php
+++ b/src/Services/EntityMergers/Mergers/EntityMergerHelperTrait.php
@@ -85,9 +85,7 @@ trait EntityMergerHelperTrait
protected function useOtherValueIfNotNull(object $target, object $other, string $field): object
{
return $this->useCallback(
- function ($target_value, $other_value) {
- return $target_value ?? $other_value;
- },
+ fn($target_value, $other_value) => $target_value ?? $other_value,
$target,
$other,
$field
@@ -106,9 +104,7 @@ trait EntityMergerHelperTrait
protected function useOtherValueIfNotEmtpy(object $target, object $other, string $field): object
{
return $this->useCallback(
- function ($target_value, $other_value) {
- return empty($target_value) ? $other_value : $target_value;
- },
+ fn($target_value, $other_value) => empty($target_value) ? $other_value : $target_value,
$target,
$other,
$field
@@ -126,9 +122,7 @@ trait EntityMergerHelperTrait
protected function useLargerValue(object $target, object $other, string $field): object
{
return $this->useCallback(
- function ($target_value, $other_value) {
- return max($target_value, $other_value);
- },
+ fn($target_value, $other_value) => max($target_value, $other_value),
$target,
$other,
$field
@@ -146,9 +140,7 @@ trait EntityMergerHelperTrait
protected function useSmallerValue(object $target, object $other, string $field): object
{
return $this->useCallback(
- function ($target_value, $other_value) {
- return min($target_value, $other_value);
- },
+ fn($target_value, $other_value) => min($target_value, $other_value),
$target,
$other,
$field
@@ -166,9 +158,7 @@ trait EntityMergerHelperTrait
protected function useTrueValue(object $target, object $other, string $field): object
{
return $this->useCallback(
- function (bool $target_value, bool $other_value): bool {
- return $target_value || $other_value;
- },
+ fn(bool $target_value, bool $other_value): bool => $target_value || $other_value,
$target,
$other,
$field
@@ -232,10 +222,8 @@ trait EntityMergerHelperTrait
continue 2;
}
}
- } else {
- if ($target_collection->contains($item)) {
- continue;
- }
+ } elseif ($target_collection->contains($item)) {
+ continue;
}
$clones[] = clone $item;
@@ -257,11 +245,9 @@ trait EntityMergerHelperTrait
*/
protected function mergeAttachments(AttachmentContainingDBElement $target, AttachmentContainingDBElement $other): object
{
- return $this->mergeCollections($target, $other, 'attachments', function (Attachment $t, Attachment $o): bool {
- return $t->getName() === $o->getName()
- && $t->getAttachmentType() === $o->getAttachmentType()
- && $t->getPath() === $o->getPath();
- });
+ return $this->mergeCollections($target, $other, 'attachments', fn(Attachment $t, Attachment $o): bool => $t->getName() === $o->getName()
+ && $t->getAttachmentType() === $o->getAttachmentType()
+ && $t->getPath() === $o->getPath());
}
/**
@@ -272,16 +258,14 @@ trait EntityMergerHelperTrait
*/
protected function mergeParameters(AbstractStructuralDBElement|Part $target, AbstractStructuralDBElement|Part $other): object
{
- return $this->mergeCollections($target, $other, 'parameters', function (AbstractParameter $t, AbstractParameter $o): bool {
- return $t->getName() === $o->getName()
- && $t->getSymbol() === $o->getSymbol()
- && $t->getUnit() === $o->getUnit()
- && $t->getValueMax() === $o->getValueMax()
- && $t->getValueMin() === $o->getValueMin()
- && $t->getValueTypical() === $o->getValueTypical()
- && $t->getValueText() === $o->getValueText()
- && $t->getGroup() === $o->getGroup();
- });
+ return $this->mergeCollections($target, $other, 'parameters', fn(AbstractParameter $t, AbstractParameter $o): bool => $t->getName() === $o->getName()
+ && $t->getSymbol() === $o->getSymbol()
+ && $t->getUnit() === $o->getUnit()
+ && $t->getValueMax() === $o->getValueMax()
+ && $t->getValueMin() === $o->getValueMin()
+ && $t->getValueTypical() === $o->getValueTypical()
+ && $t->getValueText() === $o->getValueText()
+ && $t->getGroup() === $o->getGroup());
}
/**
diff --git a/src/Services/EntityMergers/Mergers/PartMerger.php b/src/Services/EntityMergers/Mergers/PartMerger.php
index 29d4fe5c..4ce779e8 100644
--- a/src/Services/EntityMergers/Mergers/PartMerger.php
+++ b/src/Services/EntityMergers/Mergers/PartMerger.php
@@ -33,6 +33,7 @@ use App\Entity\PriceInformations\Orderdetail;
* This class merges two parts together.
*
* @implements EntityMergerInterface
+ * @see \App\Tests\Services\EntityMergers\Mergers\PartMergerTest
*/
class PartMerger implements EntityMergerInterface
{
@@ -99,7 +100,7 @@ class PartMerger implements EntityMergerInterface
return $target;
}
- private static function comparePartAssociations(PartAssociation $t, PartAssociation $o): bool {
+ private function comparePartAssociations(PartAssociation $t, PartAssociation $o): bool {
//We compare the translation keys, as it contains info about the type and other type info
return $t->getOther() === $o->getOther()
&& $t->getTypeTranslationKey() === $o->getTypeTranslationKey();
@@ -117,7 +118,7 @@ class PartMerger implements EntityMergerInterface
$this->mergeParameters($target, $other);
//Merge the associations
- $this->mergeCollections($target, $other, 'associated_parts_as_owner', self::comparePartAssociations(...));
+ $this->mergeCollections($target, $other, 'associated_parts_as_owner', $this->comparePartAssociations(...));
//We have to recreate the associations towards the other part, as they are not created by the merger
foreach ($other->getAssociatedPartsAsOther() as $association) {
@@ -131,7 +132,7 @@ class PartMerger implements EntityMergerInterface
}
//Ensure that the association is not already present
foreach ($owner->getAssociatedPartsAsOwner() as $existing_association) {
- if (self::comparePartAssociations($existing_association, $clone)) {
+ if ($this->comparePartAssociations($existing_association, $clone)) {
continue 2;
}
}
diff --git a/src/Services/EntityURLGenerator.php b/src/Services/EntityURLGenerator.php
index 16aadb0e..5718daec 100644
--- a/src/Services/EntityURLGenerator.php
+++ b/src/Services/EntityURLGenerator.php
@@ -360,11 +360,7 @@ class EntityURLGenerator
*/
protected function mapToController(array $map, string|AbstractDBElement $entity): string
{
- if (is_string($entity)) { //If a class name was already passed, then use it directly
- $class = $entity;
- } else { //Otherwise get the class name from the entity
- $class = $entity::class;
- }
+ $class = is_string($entity) ? $entity : $entity::class;
//Check if we have an direct mapping for the given class
if (!array_key_exists($class, $map)) {
diff --git a/src/Services/ImportExportSystem/PartKeeprImporter/PKOptionalImporter.php b/src/Services/ImportExportSystem/PartKeeprImporter/PKOptionalImporter.php
index b8e8272e..fafde29a 100644
--- a/src/Services/ImportExportSystem/PartKeeprImporter/PKOptionalImporter.php
+++ b/src/Services/ImportExportSystem/PartKeeprImporter/PKOptionalImporter.php
@@ -116,7 +116,7 @@ class PKOptionalImporter
//All imported users get assigned to the "PartKeepr Users" group
$group_users = $this->em->find(Group::class, 3);
$group = $this->em->getRepository(Group::class)->findOneBy(['name' => 'PartKeepr Users', 'parent' => $group_users]);
- if (!$group) {
+ if ($group === null) {
$group = new Group();
$group->setName('PartKeepr Users');
$group->setParent($group_users);
diff --git a/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php b/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php
index 767f36b4..9dd67233 100644
--- a/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php
+++ b/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php
@@ -218,7 +218,7 @@ class PKPartImporter
'iso_code' => $currency_iso_code,
]);
- if (!$currency) {
+ if ($currency === null) {
$currency = new Currency();
$currency->setIsoCode($currency_iso_code);
$currency->setName(Currencies::getName($currency_iso_code));
@@ -265,7 +265,7 @@ class PKPartImporter
]);
//When no orderdetail exists, create one
- if (!$orderdetail) {
+ if ($orderdetail === null) {
$orderdetail = new Orderdetail();
$orderdetail->setSupplier($supplier);
$orderdetail->setSupplierpartnr($spn);
diff --git a/src/Services/InfoProviderSystem/DTOs/FileDTO.php b/src/Services/InfoProviderSystem/DTOs/FileDTO.php
index 295cf78a..0d1db76a 100644
--- a/src/Services/InfoProviderSystem/DTOs/FileDTO.php
+++ b/src/Services/InfoProviderSystem/DTOs/FileDTO.php
@@ -26,6 +26,7 @@ namespace App\Services\InfoProviderSystem\DTOs;
/**
* This DTO represents a file that can be downloaded from a URL.
* This could be a datasheet, a 3D model, a picture or similar.
+ * @see \App\Tests\Services\InfoProviderSystem\DTOs\FileDTOTest
*/
class FileDTO
{
diff --git a/src/Services/InfoProviderSystem/DTOs/ParameterDTO.php b/src/Services/InfoProviderSystem/DTOs/ParameterDTO.php
index d9a0596c..3332700b 100644
--- a/src/Services/InfoProviderSystem/DTOs/ParameterDTO.php
+++ b/src/Services/InfoProviderSystem/DTOs/ParameterDTO.php
@@ -26,6 +26,7 @@ namespace App\Services\InfoProviderSystem\DTOs;
/**
* This DTO represents a parameter of a part (similar to the AbstractParameter entity).
* This could be a voltage, a current, a temperature or similar.
+ * @see \App\Tests\Services\InfoProviderSystem\DTOs\ParameterDTOTest
*/
class ParameterDTO
{
@@ -76,7 +77,7 @@ class ParameterDTO
$parts = preg_split('/\s*(\.{3}|~)\s*/', $value);
if (count($parts) === 2) {
//Try to extract number and unit from value (allow leading +)
- if (empty($unit)) {
+ if ($unit === null || trim($unit) === '') {
[$number, $unit] = self::splitIntoValueAndUnit(ltrim($parts[0], " +")) ?? [$parts[0], null];
} else {
$number = $parts[0];
diff --git a/src/Services/InfoProviderSystem/DTOs/PurchaseInfoDTO.php b/src/Services/InfoProviderSystem/DTOs/PurchaseInfoDTO.php
index 6073cc5f..bcd8be43 100644
--- a/src/Services/InfoProviderSystem/DTOs/PurchaseInfoDTO.php
+++ b/src/Services/InfoProviderSystem/DTOs/PurchaseInfoDTO.php
@@ -25,6 +25,7 @@ namespace App\Services\InfoProviderSystem\DTOs;
/**
* This DTO represents a purchase information for a part (supplier name, order number and prices).
+ * @see \App\Tests\Services\InfoProviderSystem\DTOs\PurchaseInfoDTOTest
*/
class PurchaseInfoDTO
{
diff --git a/src/Services/InfoProviderSystem/DTOs/SearchResultDTO.php b/src/Services/InfoProviderSystem/DTOs/SearchResultDTO.php
index c12b54f8..28943702 100644
--- a/src/Services/InfoProviderSystem/DTOs/SearchResultDTO.php
+++ b/src/Services/InfoProviderSystem/DTOs/SearchResultDTO.php
@@ -27,6 +27,7 @@ use App\Entity\Parts\ManufacturingStatus;
/**
* This DTO represents a search result for a part.
+ * @see \App\Tests\Services\InfoProviderSystem\DTOs\SearchResultDTOTest
*/
class SearchResultDTO
{
diff --git a/src/Services/InfoProviderSystem/DTOtoEntityConverter.php b/src/Services/InfoProviderSystem/DTOtoEntityConverter.php
index a0d1baf0..2c2b4076 100644
--- a/src/Services/InfoProviderSystem/DTOtoEntityConverter.php
+++ b/src/Services/InfoProviderSystem/DTOtoEntityConverter.php
@@ -45,6 +45,7 @@ use Doctrine\ORM\EntityManagerInterface;
/**
* This class converts DTOs to entities which can be persisted in the DB
+ * @see \App\Tests\Services\InfoProviderSystem\DTOtoEntityConverterTest
*/
final class DTOtoEntityConverter
{
@@ -127,7 +128,7 @@ final class DTOtoEntityConverter
$entity->setAttachmentType($type);
//If no name is given, try to extract the name from the URL
- if (empty($dto->name)) {
+ if ($dto->name === null || $dto->name === '' || $dto->name === '0') {
$entity->setName($this->getAttachmentNameFromURL($dto->url));
} else {
$entity->setName($dto->name);
diff --git a/src/Services/InfoProviderSystem/ProviderRegistry.php b/src/Services/InfoProviderSystem/ProviderRegistry.php
index acfbdc1e..f6c398d2 100644
--- a/src/Services/InfoProviderSystem/ProviderRegistry.php
+++ b/src/Services/InfoProviderSystem/ProviderRegistry.php
@@ -27,6 +27,7 @@ use App\Services\InfoProviderSystem\Providers\InfoProviderInterface;
/**
* This class keeps track of all registered info providers and allows to find them by their key
+ * @see \App\Tests\Services\InfoProviderSystem\ProviderRegistryTest
*/
final class ProviderRegistry
{
diff --git a/src/Services/InfoProviderSystem/Providers/DigikeyProvider.php b/src/Services/InfoProviderSystem/Providers/DigikeyProvider.php
index 1ffbd836..e707290a 100644
--- a/src/Services/InfoProviderSystem/Providers/DigikeyProvider.php
+++ b/src/Services/InfoProviderSystem/Providers/DigikeyProvider.php
@@ -93,7 +93,7 @@ class DigikeyProvider implements InfoProviderInterface
public function isActive(): bool
{
//The client ID has to be set and a token has to be available (user clicked connect)
- return !empty($this->clientId) && $this->authTokenManager->hasToken(self::OAUTH_APP_NAME);
+ return $this->clientId !== '' && $this->authTokenManager->hasToken(self::OAUTH_APP_NAME);
}
public function searchByKeyword(string $keyword): array
@@ -210,7 +210,7 @@ class DigikeyProvider implements InfoProviderInterface
$footprint_name = $parameter['Value'];
}
- if (in_array(trim($parameter['Value']), array('', '-'), true)) {
+ if (in_array(trim((string) $parameter['Value']), ['', '-'], true)) {
continue;
}
diff --git a/src/Services/InfoProviderSystem/Providers/Element14Provider.php b/src/Services/InfoProviderSystem/Providers/Element14Provider.php
index 085c9e50..ad70f9d9 100644
--- a/src/Services/InfoProviderSystem/Providers/Element14Provider.php
+++ b/src/Services/InfoProviderSystem/Providers/Element14Provider.php
@@ -65,7 +65,7 @@ class Element14Provider implements InfoProviderInterface
public function isActive(): bool
{
- return !empty($this->api_key);
+ return $this->api_key !== '';
}
/**
diff --git a/src/Services/InfoProviderSystem/Providers/LCSCProvider.php b/src/Services/InfoProviderSystem/Providers/LCSCProvider.php
index b065bed4..cdd85d07 100755
--- a/src/Services/InfoProviderSystem/Providers/LCSCProvider.php
+++ b/src/Services/InfoProviderSystem/Providers/LCSCProvider.php
@@ -96,7 +96,7 @@ class LCSCProvider implements InfoProviderInterface
*/
private function getRealDatasheetUrl(?string $url): string
{
- if (!empty($url) && preg_match("/^https:\/\/(datasheet\.lcsc\.com|www\.lcsc\.com\/datasheet)\/.*(C\d+)\.pdf$/", $url, $matches) > 0) {
+ if ($url !== null && trim($url) !== '' && preg_match("/^https:\/\/(datasheet\.lcsc\.com|www\.lcsc\.com\/datasheet)\/.*(C\d+)\.pdf$/", $url, $matches) > 0) {
$response = $this->lcscClient->request('GET', $url, [
'headers' => [
'Referer' => 'https://www.lcsc.com/product-detail/_' . $matches[2] . '.html'
@@ -139,7 +139,7 @@ class LCSCProvider implements InfoProviderInterface
// LCSC does not display LCSC codes in the search, instead taking you directly to the
// detailed product listing. It does so utilizing a product tip field.
// If product tip exists and there are no products in the product list try a detail query
- if (count($products) === 0 && !($tipProductCode === null)) {
+ if (count($products) === 0 && $tipProductCode !== null) {
$result[] = $this->queryDetail($tipProductCode);
}
@@ -174,11 +174,11 @@ class LCSCProvider implements InfoProviderInterface
{
// Get product images in advance
$product_images = $this->getProductImages($product['productImages'] ?? null);
- $product['productImageUrl'] = $product['productImageUrl'] ?? null;
+ $product['productImageUrl'] ??= null;
// If the product does not have a product image but otherwise has attached images, use the first one.
if (count($product_images) > 0) {
- $product['productImageUrl'] = $product['productImageUrl'] ?? $product_images[0]->url;
+ $product['productImageUrl'] ??= $product_images[0]->url;
}
// LCSC puts HTML in footprints and descriptions sometimes randomly
@@ -321,7 +321,7 @@ class LCSCProvider implements InfoProviderInterface
foreach ($attributes as $attribute) {
//Skip this attribute if it's empty
- if (in_array(trim($attribute['paramValueEn']), array('', '-'), true)) {
+ if (in_array(trim((string) $attribute['paramValueEn']), ['', '-'], true)) {
continue;
}
diff --git a/src/Services/InfoProviderSystem/Providers/MouserProvider.php b/src/Services/InfoProviderSystem/Providers/MouserProvider.php
index 1e58285c..e5f937da 100644
--- a/src/Services/InfoProviderSystem/Providers/MouserProvider.php
+++ b/src/Services/InfoProviderSystem/Providers/MouserProvider.php
@@ -74,7 +74,7 @@ class MouserProvider implements InfoProviderInterface
public function isActive(): bool
{
- return !empty($this->api_key);
+ return $this->api_key !== '';
}
public function searchByKeyword(string $keyword): array
@@ -247,7 +247,7 @@ class MouserProvider implements InfoProviderInterface
private function parseDataSheets(?string $sheetUrl, ?string $sheetName): ?array
{
- if (empty($sheetUrl)) {
+ if ($sheetUrl === null || $sheetUrl === '' || $sheetUrl === '0') {
return null;
}
$result = [];
diff --git a/src/Services/InfoProviderSystem/Providers/OctopartProvider.php b/src/Services/InfoProviderSystem/Providers/OctopartProvider.php
index f261e225..e28162ba 100644
--- a/src/Services/InfoProviderSystem/Providers/OctopartProvider.php
+++ b/src/Services/InfoProviderSystem/Providers/OctopartProvider.php
@@ -183,7 +183,7 @@ class OctopartProvider implements InfoProviderInterface
{
//The client ID has to be set and a token has to be available (user clicked connect)
//return /*!empty($this->clientId) && */ $this->authTokenManager->hasToken(self::OAUTH_APP_NAME);
- return !empty($this->clientId) && !empty($this->secret);
+ return $this->clientId !== '' && $this->secret !== '';
}
private function mapLifeCycleStatus(?string $value): ?ManufacturingStatus
@@ -243,11 +243,14 @@ class OctopartProvider implements InfoProviderInterface
//If we encounter the mass spec, we save it for later
if ($spec['attribute']['shortname'] === "weight") {
$mass = (float) $spec['siValue'];
- } else if ($spec['attribute']['shortname'] === "case_package") { //Package
+ } elseif ($spec['attribute']['shortname'] === "case_package") {
+ //Package
$package = $spec['value'];
- } else if ($spec['attribute']['shortname'] === "numberofpins") { //Pin Count
+ } elseif ($spec['attribute']['shortname'] === "numberofpins") {
+ //Pin Count
$pinCount = $spec['value'];
- } else if ($spec['attribute']['shortname'] === "lifecyclestatus") { //LifeCycleStatus
+ } elseif ($spec['attribute']['shortname'] === "lifecyclestatus") {
+ //LifeCycleStatus
$mStatus = $this->mapLifeCycleStatus($spec['value']);
}
@@ -295,7 +298,7 @@ class OctopartProvider implements InfoProviderInterface
$category = null;
if (!empty($part['category']['name'])) {
$category = implode(' -> ', array_map(static fn($c) => $c['name'], $part['category']['ancestors'] ?? []));
- if (!empty($category)) {
+ if ($category !== '' && $category !== '0') {
$category .= ' -> ';
}
$category .= $part['category']['name'];
diff --git a/src/Services/InfoProviderSystem/Providers/TMEClient.php b/src/Services/InfoProviderSystem/Providers/TMEClient.php
index df2c7202..0e32e9a6 100644
--- a/src/Services/InfoProviderSystem/Providers/TMEClient.php
+++ b/src/Services/InfoProviderSystem/Providers/TMEClient.php
@@ -47,7 +47,7 @@ class TMEClient
public function isUsable(): bool
{
- return !($this->token === '' || $this->secret === '');
+ return $this->token !== '' && $this->secret !== '';
}
diff --git a/src/Services/InfoProviderSystem/Providers/TMEProvider.php b/src/Services/InfoProviderSystem/Providers/TMEProvider.php
index 892294f3..61944b7d 100644
--- a/src/Services/InfoProviderSystem/Providers/TMEProvider.php
+++ b/src/Services/InfoProviderSystem/Providers/TMEProvider.php
@@ -80,7 +80,7 @@ class TMEProvider implements InfoProviderInterface
$result[] = new SearchResultDTO(
provider_key: $this->getProviderKey(),
provider_id: $product['Symbol'],
- name: !empty($product['OriginalSymbol']) ? $product['OriginalSymbol'] : $product['Symbol'],
+ name: empty($product['OriginalSymbol']) ? $product['Symbol'] : $product['OriginalSymbol'],
description: $product['Description'],
category: $product['Category'],
manufacturer: $product['Producer'],
@@ -116,7 +116,7 @@ class TMEProvider implements InfoProviderInterface
return new PartDetailDTO(
provider_key: $this->getProviderKey(),
provider_id: $product['Symbol'],
- name: !empty($product['OriginalSymbol']) ? $product['OriginalSymbol'] : $product['Symbol'],
+ name: empty($product['OriginalSymbol']) ? $product['Symbol'] : $product['OriginalSymbol'],
description: $product['Description'],
category: $product['Category'],
manufacturer: $product['Producer'],
diff --git a/src/Services/LabelSystem/Barcodes/BarcodeHelper.php b/src/Services/LabelSystem/Barcodes/BarcodeHelper.php
index d13da589..c9fe64f3 100644
--- a/src/Services/LabelSystem/Barcodes/BarcodeHelper.php
+++ b/src/Services/LabelSystem/Barcodes/BarcodeHelper.php
@@ -28,6 +28,7 @@ use Com\Tecnick\Barcode\Barcode;
/**
* This function is used to generate barcodes of various types using arbitrary (text) content.
+ * @see \App\Tests\Services\LabelSystem\Barcodes\BarcodeHelperTest
*/
class BarcodeHelper
{
@@ -66,7 +67,7 @@ class BarcodeHelper
{
$svg = $this->barcodeAsSVG($content, $type);
$base64 = $this->dataUri($svg, 'image/svg+xml');
- $alt_text = $alt_text ?? $content;
+ $alt_text ??= $content;
return '
';
}
diff --git a/src/Services/LabelSystem/Barcodes/BarcodeScanHelper.php b/src/Services/LabelSystem/Barcodes/BarcodeScanHelper.php
index b53d3f02..c9750ea3 100644
--- a/src/Services/LabelSystem/Barcodes/BarcodeScanHelper.php
+++ b/src/Services/LabelSystem/Barcodes/BarcodeScanHelper.php
@@ -48,7 +48,7 @@ use Doctrine\ORM\EntityManagerInterface;
use InvalidArgumentException;
/**
- * @see \App\Tests\Services\LabelSystem\Barcodes\BarcodeNormalizerTest
+ * @see \App\Tests\Services\LabelSystem\Barcodes\BarcodeScanHelperTest
*/
final class BarcodeScanHelper
{
diff --git a/src/Services/LabelSystem/DompdfFactory.php b/src/Services/LabelSystem/DompdfFactory.php
index ff30c480..a2c8c3cd 100644
--- a/src/Services/LabelSystem/DompdfFactory.php
+++ b/src/Services/LabelSystem/DompdfFactory.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Services\LabelSystem;
use Dompdf\Dompdf;
@@ -36,10 +38,8 @@ class DompdfFactory implements DompdfFactoryInterface
private function createDirectoryIfNotExisting(string $path): void
{
- if (!is_dir($path)) {
- if (!mkdir($concurrentDirectory = $path, 0777, true) && !is_dir($concurrentDirectory)) {
- throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
- }
+ if (!is_dir($path) && (!mkdir($concurrentDirectory = $path, 0777, true) && !is_dir($concurrentDirectory))) {
+ throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
}
}
@@ -51,4 +51,4 @@ class DompdfFactory implements DompdfFactoryInterface
'tempDir' => $this->tmpDirectory,
]);
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/LabelSystem/LabelBarcodeGenerator.php b/src/Services/LabelSystem/LabelBarcodeGenerator.php
index f5d950b4..66f74e58 100644
--- a/src/Services/LabelSystem/LabelBarcodeGenerator.php
+++ b/src/Services/LabelSystem/LabelBarcodeGenerator.php
@@ -49,7 +49,7 @@ use App\Services\LabelSystem\Barcodes\BarcodeHelper;
use InvalidArgumentException;
/**
- * @see \App\Tests\Services\LabelSystem\BarcodeGeneratorTest
+ * @see \App\Tests\Services\LabelSystem\LabelBarcodeGeneratorTest
*/
final class LabelBarcodeGenerator
{
diff --git a/src/Services/LabelSystem/PlaceholderProviders/PartProvider.php b/src/Services/LabelSystem/PlaceholderProviders/PartProvider.php
index 9d9b3416..0df4d3d7 100644
--- a/src/Services/LabelSystem/PlaceholderProviders/PartProvider.php
+++ b/src/Services/LabelSystem/PlaceholderProviders/PartProvider.php
@@ -119,7 +119,7 @@ final class PartProvider implements PlaceholderProviderInterface
}
if ('[[DESCRIPTION_T]]' === $placeholder) {
- return strip_tags($parsedown->line($part->getDescription()));
+ return strip_tags((string) $parsedown->line($part->getDescription()));
}
if ('[[COMMENT]]' === $placeholder) {
@@ -127,7 +127,7 @@ final class PartProvider implements PlaceholderProviderInterface
}
if ('[[COMMENT_T]]' === $placeholder) {
- return strip_tags($parsedown->line($part->getComment()));
+ return strip_tags((string) $parsedown->line($part->getComment()));
}
return null;
diff --git a/src/Services/LabelSystem/PlaceholderProviders/StructuralDBElementProvider.php b/src/Services/LabelSystem/PlaceholderProviders/StructuralDBElementProvider.php
index ca8088da..f37f5901 100644
--- a/src/Services/LabelSystem/PlaceholderProviders/StructuralDBElementProvider.php
+++ b/src/Services/LabelSystem/PlaceholderProviders/StructuralDBElementProvider.php
@@ -52,7 +52,7 @@ final class StructuralDBElementProvider implements PlaceholderProviderInterface
return $label_target->getComment();
}
if ('[[COMMENT_T]]' === $placeholder) {
- return strip_tags($label_target->getComment());
+ return strip_tags((string) $label_target->getComment());
}
if ('[[FULL_PATH]]' === $placeholder) {
return $label_target->getFullPath();
diff --git a/src/Services/LogSystem/EventUndoMode.php b/src/Services/LogSystem/EventUndoMode.php
index 51ad664e..de30dcfd 100644
--- a/src/Services/LogSystem/EventUndoMode.php
+++ b/src/Services/LogSystem/EventUndoMode.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Services\LogSystem;
use InvalidArgumentException;
diff --git a/src/Services/LogSystem/LogEntryExtraFormatter.php b/src/Services/LogSystem/LogEntryExtraFormatter.php
index fdfd72c8..ae2a5eba 100644
--- a/src/Services/LogSystem/LogEntryExtraFormatter.php
+++ b/src/Services/LogSystem/LogEntryExtraFormatter.php
@@ -135,7 +135,7 @@ class LogEntryExtraFormatter
}
if ($context instanceof LogWithCommentInterface && $context->hasComment()) {
- $array[] = htmlspecialchars($context->getComment());
+ $array[] = htmlspecialchars((string) $context->getComment());
}
if ($context instanceof ElementCreatedLogEntry && $context->hasCreationInstockValue()) {
@@ -193,7 +193,7 @@ class LogEntryExtraFormatter
htmlspecialchars($this->elementTypeNameGenerator->getLocalizedTypeLabel(PartLot::class))
.' ' . $context->getMoveToTargetID();
}
- if ($context->getActionTimestamp()) {
+ if ($context->getActionTimestamp() !== null) {
$formatter = new \IntlDateFormatter($this->translator->getLocale(), \IntlDateFormatter::SHORT, \IntlDateFormatter::SHORT);
$array['log.part_stock_changed.timestamp'] = $formatter->format($context->getActionTimestamp());
}
diff --git a/src/Services/OAuth/OAuthTokenManager.php b/src/Services/OAuth/OAuthTokenManager.php
index dddde20a..9c22503b 100644
--- a/src/Services/OAuth/OAuthTokenManager.php
+++ b/src/Services/OAuth/OAuthTokenManager.php
@@ -47,7 +47,7 @@ final class OAuthTokenManager
$tokenEntity = $this->entityManager->getRepository(OAuthToken::class)->findOneBy(['name' => $app_name]);
//If the token was already existing, we just replace it with the new one
- if ($tokenEntity) {
+ if ($tokenEntity !== null) {
$tokenEntity->replaceWithNewToken($token);
$this->entityManager->flush();
@@ -96,7 +96,7 @@ final class OAuthTokenManager
{
$token = $this->getToken($app_name);
- if (!$token) {
+ if ($token === null) {
throw new \RuntimeException('No token was saved yet for '.$app_name);
}
@@ -128,7 +128,7 @@ final class OAuthTokenManager
$token = $this->getToken($app_name);
//If the token is not existing, we return null
- if (!$token) {
+ if ($token === null) {
return null;
}
diff --git a/src/Services/System/BannerHelper.php b/src/Services/System/BannerHelper.php
index c0dbf600..1b6da52a 100644
--- a/src/Services/System/BannerHelper.php
+++ b/src/Services/System/BannerHelper.php
@@ -43,7 +43,7 @@ class BannerHelper
if (!is_string($banner)) {
throw new \RuntimeException('The parameter "partdb.banner" must be a string.');
}
- if (empty($banner)) {
+ if ($banner === '') {
$banner_path = $this->project_dir
.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'banner.md';
diff --git a/src/Services/UserSystem/TFA/DecoratedGoogleAuthenticator.php b/src/Services/UserSystem/TFA/DecoratedGoogleAuthenticator.php
index 8ec411f1..05e5ed4c 100644
--- a/src/Services/UserSystem/TFA/DecoratedGoogleAuthenticator.php
+++ b/src/Services/UserSystem/TFA/DecoratedGoogleAuthenticator.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Services\UserSystem\TFA;
use Scheb\TwoFactorBundle\Model\Google\TwoFactorInterface;
@@ -67,4 +69,4 @@ class DecoratedGoogleAuthenticator implements GoogleAuthenticatorInterface
{
return $this->inner->generateSecret();
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/UserSystem/VoterHelper.php b/src/Services/UserSystem/VoterHelper.php
index c13cf22a..644351f4 100644
--- a/src/Services/UserSystem/VoterHelper.php
+++ b/src/Services/UserSystem/VoterHelper.php
@@ -29,6 +29,9 @@ use App\Security\ApiTokenAuthenticatedToken;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
+/**
+ * @see \App\Tests\Services\UserSystem\VoterHelperTest
+ */
final class VoterHelper
{
private readonly UserRepository $userRepository;
diff --git a/src/State/PartDBInfoProvider.php b/src/State/PartDBInfoProvider.php
index 7d09d721..c6760ede 100644
--- a/src/State/PartDBInfoProvider.php
+++ b/src/State/PartDBInfoProvider.php
@@ -1,5 +1,7 @@
providerRegistry->getProviderByKey($key);
- } catch (\InvalidArgumentException $exception) {
+ } catch (\InvalidArgumentException) {
return null;
}
}
@@ -65,7 +65,7 @@ class InfoProviderExtension extends AbstractExtension
{
try {
return $this->providerRegistry->getProviderByKey($key)->getProviderInfo()['name'];
- } catch (\InvalidArgumentException $exception) {
+ } catch (\InvalidArgumentException) {
return null;
}
}
diff --git a/src/Twig/TwigCoreExtension.php b/src/Twig/TwigCoreExtension.php
index 94b067d5..352e09d3 100644
--- a/src/Twig/TwigCoreExtension.php
+++ b/src/Twig/TwigCoreExtension.php
@@ -42,7 +42,7 @@ final class TwigCoreExtension extends AbstractExtension
{
return [
/* Returns the enum cases as values */
- new TwigFunction('enum_cases', [$this, 'getEnumCases']),
+ new TwigFunction('enum_cases', $this->getEnumCases(...)),
];
}
diff --git a/src/Validator/Constraints/NoneOfItsChildrenValidator.php b/src/Validator/Constraints/NoneOfItsChildrenValidator.php
index 2220e664..2be5f16b 100644
--- a/src/Validator/Constraints/NoneOfItsChildrenValidator.php
+++ b/src/Validator/Constraints/NoneOfItsChildrenValidator.php
@@ -30,6 +30,7 @@ use Symfony\Component\Validator\Exception\UnexpectedValueException;
/**
* The validator for the NoneOfItsChildren annotation.
+ * @see \App\Tests\Validator\Constraints\NoneOfItsChildrenValidatorTest
*/
class NoneOfItsChildrenValidator extends ConstraintValidator
{
diff --git a/src/Validator/Constraints/SelectableValidator.php b/src/Validator/Constraints/SelectableValidator.php
index dfe8eba8..013a3964 100644
--- a/src/Validator/Constraints/SelectableValidator.php
+++ b/src/Validator/Constraints/SelectableValidator.php
@@ -30,6 +30,7 @@ use Symfony\Component\Validator\Exception\UnexpectedValueException;
/**
* The validator for the Selectable constraint.
+ * @see \App\Tests\Validator\Constraints\SelectableValidatorTest
*/
class SelectableValidator extends ConstraintValidator
{
diff --git a/src/Validator/Constraints/UniqueObjectCollection.php b/src/Validator/Constraints/UniqueObjectCollection.php
index d432892c..c71fcc5d 100644
--- a/src/Validator/Constraints/UniqueObjectCollection.php
+++ b/src/Validator/Constraints/UniqueObjectCollection.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Validator\Constraints;
use InvalidArgumentException;
@@ -59,4 +61,4 @@ class UniqueObjectCollection extends Constraint
throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', get_debug_type($this->normalizer)));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Validator/Constraints/UniqueObjectCollectionValidator.php b/src/Validator/Constraints/UniqueObjectCollectionValidator.php
index 244b6c9c..b80889a4 100644
--- a/src/Validator/Constraints/UniqueObjectCollectionValidator.php
+++ b/src/Validator/Constraints/UniqueObjectCollectionValidator.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Validator\Constraints;
use App\Validator\UniqueValidatableInterface;
@@ -26,6 +28,9 @@ use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
+/**
+ * @see \App\Tests\Validator\Constraints\UniqueObjectCollectionValidatorTest
+ */
class UniqueObjectCollectionValidator extends ConstraintValidator
{
@@ -106,4 +111,4 @@ class UniqueObjectCollectionValidator extends ConstraintValidator
return $output;
}
-}
\ No newline at end of file
+}
diff --git a/src/Validator/Constraints/UrlOrBuiltinValidator.php b/src/Validator/Constraints/UrlOrBuiltinValidator.php
index af498d2a..71407a6a 100644
--- a/src/Validator/Constraints/UrlOrBuiltinValidator.php
+++ b/src/Validator/Constraints/UrlOrBuiltinValidator.php
@@ -34,6 +34,7 @@ use function is_object;
* The validator for UrlOrBuiltin.
* It checks if the value is either a builtin ressource or a valid url.
* In both cases it is not checked, if the ressource is really existing.
+ * @see \App\Tests\Validator\Constraints\UrlOrBuiltinValidatorTest
*/
class UrlOrBuiltinValidator extends UrlValidator
{
diff --git a/src/Validator/Constraints/ValidGoogleAuthCodeValidator.php b/src/Validator/Constraints/ValidGoogleAuthCodeValidator.php
index f7f9e26e..25afe57b 100644
--- a/src/Validator/Constraints/ValidGoogleAuthCodeValidator.php
+++ b/src/Validator/Constraints/ValidGoogleAuthCodeValidator.php
@@ -33,6 +33,9 @@ use Symfony\Component\Validator\Exception\UnexpectedValueException;
use function is_string;
use function strlen;
+/**
+ * @see \App\Tests\Validator\Constraints\ValidGoogleAuthCodeValidatorTest
+ */
class ValidGoogleAuthCodeValidator extends ConstraintValidator
{
public function __construct(private readonly GoogleAuthenticatorInterface $googleAuthenticator, private readonly Security $security)
diff --git a/src/Validator/Constraints/ValidPermissionValidator.php b/src/Validator/Constraints/ValidPermissionValidator.php
index b1a5b623..afb7721b 100644
--- a/src/Validator/Constraints/ValidPermissionValidator.php
+++ b/src/Validator/Constraints/ValidPermissionValidator.php
@@ -63,11 +63,11 @@ class ValidPermissionValidator extends ConstraintValidator
if ($changed) {
//Check if this was called in context of UserController
$request = $this->requestStack->getMainRequest();
- if (!$request) {
+ if ($request === null) {
return;
}
//Determine the controller class (the part before the ::)
- $controller_class = explode('::', $request->attributes->get('_controller'))[0];
+ $controller_class = explode('::', (string) $request->attributes->get('_controller'))[0];
if (in_array($controller_class, [UserController::class, GroupController::class], true)) {
/** @var Session $session */
diff --git a/src/Validator/Constraints/ValidThemeValidator.php b/src/Validator/Constraints/ValidThemeValidator.php
index 5d222934..713be9a5 100644
--- a/src/Validator/Constraints/ValidThemeValidator.php
+++ b/src/Validator/Constraints/ValidThemeValidator.php
@@ -26,6 +26,9 @@ use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
+/**
+ * @see \App\Tests\Validator\Constraints\ValidThemeValidatorTest
+ */
class ValidThemeValidator extends ConstraintValidator
{
public function __construct(private readonly array $available_themes)
diff --git a/src/Validator/UniqueValidatableInterface.php b/src/Validator/UniqueValidatableInterface.php
index 97e3a0b9..3d954490 100644
--- a/src/Validator/UniqueValidatableInterface.php
+++ b/src/Validator/UniqueValidatableInterface.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Validator;
interface UniqueValidatableInterface
@@ -29,4 +31,4 @@ interface UniqueValidatableInterface
* @return array An array of the form ['field1' => 'value1', 'field2' => 'value2', ...]
*/
public function getComparableFields(): array;
-}
\ No newline at end of file
+}
diff --git a/tests/API/APITokenAuthenticationTest.php b/tests/API/APITokenAuthenticationTest.php
index fa251839..a78b0594 100644
--- a/tests/API/APITokenAuthenticationTest.php
+++ b/tests/API/APITokenAuthenticationTest.php
@@ -34,7 +34,7 @@ class APITokenAuthenticationTest extends ApiTestCase
self::ensureKernelShutdown();
$client = static::createClient();
$client->request('GET', '/api/parts');
- self::assertResponseStatusCodeSame(401);
+ $this->assertResponseStatusCodeSame(401);
}
public function testExpiredToken(): void
@@ -42,7 +42,7 @@ class APITokenAuthenticationTest extends ApiTestCase
self::ensureKernelShutdown();
$client = $this->createClientWithCredentials(APITokenFixtures::TOKEN_EXPIRED);
$client->request('GET', '/api/parts');
- self::assertResponseStatusCodeSame(401);
+ $this->assertResponseStatusCodeSame(401);
}
public function testReadOnlyToken(): void
@@ -52,14 +52,14 @@ class APITokenAuthenticationTest extends ApiTestCase
//Read should be possible
$client->request('GET', '/api/parts');
- self::assertResponseIsSuccessful();
+ $this->assertResponseIsSuccessful();
//Trying to list all users and create a new footprint should fail
$client->request('GET', '/api/users');
- self::assertResponseStatusCodeSame(403);
+ $this->assertResponseStatusCodeSame(403);
$client->request('POST', '/api/footprints', ['json' => ['name' => 'post test']]);
- self::assertResponseStatusCodeSame(403);
+ $this->assertResponseStatusCodeSame(403);
}
public function testEditToken(): void
@@ -69,14 +69,14 @@ class APITokenAuthenticationTest extends ApiTestCase
//Read should be possible
$client->request('GET', '/api/parts');
- self::assertResponseIsSuccessful();
+ $this->assertResponseIsSuccessful();
//Trying to list all users
$client->request('GET', '/api/users');
- self::assertResponseStatusCodeSame(403);
+ $this->assertResponseStatusCodeSame(403);
$client->request('POST', '/api/footprints', ['json' => ['name' => 'post test']]);
- self::assertResponseIsSuccessful();
+ $this->assertResponseIsSuccessful();
}
public function testAdminToken(): void
@@ -86,14 +86,14 @@ class APITokenAuthenticationTest extends ApiTestCase
//Read should be possible
$client->request('GET', '/api/parts');
- self::assertResponseIsSuccessful();
+ $this->assertResponseIsSuccessful();
//Trying to list all users
$client->request('GET', '/api/users');
- self::assertResponseIsSuccessful();
+ $this->assertResponseIsSuccessful();
$client->request('POST', '/api/footprints', ['json' => ['name' => 'post test']]);
- self::assertResponseIsSuccessful();
+ $this->assertResponseIsSuccessful();
}
public function testWithAuthorizationToken(): void
@@ -104,14 +104,14 @@ class APITokenAuthenticationTest extends ApiTestCase
//Read should be possible
$client->request('GET', '/api/parts');
- self::assertResponseIsSuccessful();
+ $this->assertResponseIsSuccessful();
//Trying to list all users
$client->request('GET', '/api/users');
- self::assertResponseIsSuccessful();
+ $this->assertResponseIsSuccessful();
$client->request('POST', '/api/footprints', ['json' => ['name' => 'post test']]);
- self::assertResponseIsSuccessful();
+ $this->assertResponseIsSuccessful();
}
protected function createClientWithCredentials(string $token): Client
diff --git a/tests/API/Endpoints/ApiTokenEnpointTest.php b/tests/API/Endpoints/ApiTokenEnpointTest.php
index 1050eb1c..99340182 100644
--- a/tests/API/Endpoints/ApiTokenEnpointTest.php
+++ b/tests/API/Endpoints/ApiTokenEnpointTest.php
@@ -30,9 +30,9 @@ class ApiTokenEnpointTest extends AuthenticatedApiTestCase
public function testGetCurrentToken(): void
{
$response = self::createAuthenticatedClient()->request('GET', '/api/tokens/current');
- self::assertResponseIsSuccessful();
+ $this->assertResponseIsSuccessful();
- self::assertJsonContains([
+ $this->assertJsonContains([
'name' => 'admin',
'level' => 3,
]);
diff --git a/tests/Doctrine/SQLiteRegexMiddlewareTest.php b/tests/Doctrine/SQLiteRegexMiddlewareTest.php
index 25358705..01abb16e 100644
--- a/tests/Doctrine/SQLiteRegexMiddlewareTest.php
+++ b/tests/Doctrine/SQLiteRegexMiddlewareTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Doctrine;
use App\Doctrine\Middleware\SQLiteRegexExtensionMiddlewareDriver;
diff --git a/tests/Entity/Attachments/AttachmentTest.php b/tests/Entity/Attachments/AttachmentTest.php
index e775f32f..a2179e53 100644
--- a/tests/Entity/Attachments/AttachmentTest.php
+++ b/tests/Entity/Attachments/AttachmentTest.php
@@ -72,22 +72,20 @@ class AttachmentTest extends TestCase
$this->assertEmpty($attachment->getFilename());
}
- public function subClassesDataProvider(): array
+ public function subClassesDataProvider(): \Iterator
{
- return [
- [AttachmentTypeAttachment::class, AttachmentType::class],
- [CategoryAttachment::class, Category::class],
- [CurrencyAttachment::class, Currency::class],
- [ProjectAttachment::class, Project::class],
- [FootprintAttachment::class, Footprint::class],
- [GroupAttachment::class, Group::class],
- [ManufacturerAttachment::class, Manufacturer::class],
- [MeasurementUnitAttachment::class, MeasurementUnit::class],
- [PartAttachment::class, Part::class],
- [StorageLocationAttachment::class, StorageLocation::class],
- [SupplierAttachment::class, Supplier::class],
- [UserAttachment::class, User::class],
- ];
+ yield [AttachmentTypeAttachment::class, AttachmentType::class];
+ yield [CategoryAttachment::class, Category::class];
+ yield [CurrencyAttachment::class, Currency::class];
+ yield [ProjectAttachment::class, Project::class];
+ yield [FootprintAttachment::class, Footprint::class];
+ yield [GroupAttachment::class, Group::class];
+ yield [ManufacturerAttachment::class, Manufacturer::class];
+ yield [MeasurementUnitAttachment::class, MeasurementUnit::class];
+ yield [PartAttachment::class, Part::class];
+ yield [StorageLocationAttachment::class, StorageLocation::class];
+ yield [SupplierAttachment::class, Supplier::class];
+ yield [UserAttachment::class, User::class];
}
/**
@@ -117,27 +115,21 @@ class AttachmentTest extends TestCase
/** @var Attachment $attachment */
$attachment = new $attachment_class();
- if (Project::class !== $allowed_class) {
- $element = new Project();
- } else {
- $element = new Category();
- }
+ $element = Project::class !== $allowed_class ? new Project() : new Category();
$attachment->setElement($element);
}
- public function externalDataProvider(): array
+ public function externalDataProvider(): \Iterator
{
- return [
- ['', false],
- ['%MEDIA%/foo/bar.txt', false],
- ['%BASE%/foo/bar.jpg', false],
- ['%FOOTPRINTS%/foo/bar.jpg', false],
- ['%FOOTPRINTS3D%/foo/bar.jpg', false],
- ['%SECURE%/test.txt', false],
- ['%test%/foo/bar.ghp', true],
- ['foo%MEDIA%/foo.jpg', true],
- ['foo%MEDIA%/%BASE%foo.jpg', true],
- ];
+ yield ['', false];
+ yield ['%MEDIA%/foo/bar.txt', false];
+ yield ['%BASE%/foo/bar.jpg', false];
+ yield ['%FOOTPRINTS%/foo/bar.jpg', false];
+ yield ['%FOOTPRINTS3D%/foo/bar.jpg', false];
+ yield ['%SECURE%/test.txt', false];
+ yield ['%test%/foo/bar.ghp', true];
+ yield ['foo%MEDIA%/foo.jpg', true];
+ yield ['foo%MEDIA%/%BASE%foo.jpg', true];
}
/**
@@ -150,20 +142,18 @@ class AttachmentTest extends TestCase
$this->assertSame($expected, $attachment->isExternal());
}
- public function extensionDataProvider(): array
+ public function extensionDataProvider(): \Iterator
{
- return [
- ['%MEDIA%/foo/bar.txt', null, 'txt'],
- ['%MEDIA%/foo/bar.JPeg', null, 'jpeg'],
- ['%MEDIA%/foo/bar.JPeg', 'test.txt', 'txt'],
- ['%MEDIA%/foo/bar', null, ''],
- ['%MEDIA%/foo.bar', 'bar', ''],
- ['http://google.de', null, null],
- ['https://foo.bar', null, null],
- ['https://foo.bar/test.jpeg', null, null],
- ['test', null, null],
- ['test.txt', null, null],
- ];
+ yield ['%MEDIA%/foo/bar.txt', null, 'txt'];
+ yield ['%MEDIA%/foo/bar.JPeg', null, 'jpeg'];
+ yield ['%MEDIA%/foo/bar.JPeg', 'test.txt', 'txt'];
+ yield ['%MEDIA%/foo/bar', null, ''];
+ yield ['%MEDIA%/foo.bar', 'bar', ''];
+ yield ['http://google.de', null, null];
+ yield ['https://foo.bar', null, null];
+ yield ['https://foo.bar/test.jpeg', null, null];
+ yield ['test', null, null];
+ yield ['test.txt', null, null];
}
/**
@@ -177,21 +167,19 @@ class AttachmentTest extends TestCase
$this->assertSame($expected, $attachment->getExtension());
}
- public function pictureDataProvider(): array
+ public function pictureDataProvider(): \Iterator
{
- return [
- ['%MEDIA%/foo/bar.txt', false],
- ['https://test.de/picture.jpeg', true],
- ['https://test.de/picture.png?test=fdsj&width=34', true],
- ['https://invalid.invalid/file.txt', false],
- ['http://infsf.inda/file.zip?test', false],
- ['https://test.de', true],
- ['https://invalid.com/invalid/pic', true],
- ['%MEDIA%/foo/bar.jpeg', true],
- ['%MEDIA%/foo/bar.webp', true],
- ['%MEDIA%/foo', false],
- ['%SECURE%/foo.txt/test', false],
- ];
+ yield ['%MEDIA%/foo/bar.txt', false];
+ yield ['https://test.de/picture.jpeg', true];
+ yield ['https://test.de/picture.png?test=fdsj&width=34', true];
+ yield ['https://invalid.invalid/file.txt', false];
+ yield ['http://infsf.inda/file.zip?test', false];
+ yield ['https://test.de', true];
+ yield ['https://invalid.com/invalid/pic', true];
+ yield ['%MEDIA%/foo/bar.jpeg', true];
+ yield ['%MEDIA%/foo/bar.webp', true];
+ yield ['%MEDIA%/foo', false];
+ yield ['%SECURE%/foo.txt/test', false];
}
/**
@@ -204,16 +192,14 @@ class AttachmentTest extends TestCase
$this->assertSame($expected, $attachment->isPicture());
}
- public function builtinDataProvider(): array
+ public function builtinDataProvider(): \Iterator
{
- return [
- ['', false],
- ['%MEDIA%/foo/bar.txt', false],
- ['%BASE%/foo/bar.txt', false],
- ['/', false],
- ['https://google.de', false],
- ['%FOOTPRINTS%/foo/bar.txt', true],
- ];
+ yield ['', false];
+ yield ['%MEDIA%/foo/bar.txt', false];
+ yield ['%BASE%/foo/bar.txt', false];
+ yield ['/', false];
+ yield ['https://google.de', false];
+ yield ['%FOOTPRINTS%/foo/bar.txt', true];
}
/**
@@ -226,13 +212,11 @@ class AttachmentTest extends TestCase
$this->assertSame($expected, $attachment->isBuiltIn());
}
- public function hostDataProvider(): array
+ public function hostDataProvider(): \Iterator
{
- return [
- ['%MEDIA%/foo/bar.txt', null],
- ['https://www.google.de/test.txt', 'www.google.de'],
- ['https://foo.bar/test?txt=test', 'foo.bar'],
- ];
+ yield ['%MEDIA%/foo/bar.txt', null];
+ yield ['https://www.google.de/test.txt', 'www.google.de'];
+ yield ['https://foo.bar/test?txt=test', 'foo.bar'];
}
/**
@@ -245,13 +229,11 @@ class AttachmentTest extends TestCase
$this->assertSame($expected, $attachment->getHost());
}
- public function filenameProvider(): array
+ public function filenameProvider(): \Iterator
{
- return [
- ['%MEDIA%/foo/bar.txt', null, 'bar.txt'],
- ['%MEDIA%/foo/bar.JPeg', 'test.txt', 'test.txt'],
- ['https://www.google.de/test.txt', null, null],
- ];
+ yield ['%MEDIA%/foo/bar.txt', null, 'bar.txt'];
+ yield ['%MEDIA%/foo/bar.JPeg', 'test.txt', 'test.txt'];
+ yield ['https://www.google.de/test.txt', null, null];
}
/**
diff --git a/tests/Entity/LogSystem/LogLevelTest.php b/tests/Entity/LogSystem/LogLevelTest.php
index 634d5dd5..402942e1 100644
--- a/tests/Entity/LogSystem/LogLevelTest.php
+++ b/tests/Entity/LogSystem/LogLevelTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Entity\LogSystem;
use App\Entity\LogSystem\LogLevel;
diff --git a/tests/Entity/LogSystem/LogTargetTypeTest.php b/tests/Entity/LogSystem/LogTargetTypeTest.php
index 2d7675da..46682496 100644
--- a/tests/Entity/LogSystem/LogTargetTypeTest.php
+++ b/tests/Entity/LogSystem/LogTargetTypeTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Entity\LogSystem;
use App\Entity\Attachments\Attachment;
diff --git a/tests/Entity/Parameters/PartParameterTest.php b/tests/Entity/Parameters/PartParameterTest.php
index c8005d6c..c42b3cbe 100644
--- a/tests/Entity/Parameters/PartParameterTest.php
+++ b/tests/Entity/Parameters/PartParameterTest.php
@@ -46,29 +46,25 @@ use PHPUnit\Framework\TestCase;
class PartParameterTest extends TestCase
{
- public function valueWithUnitDataProvider(): array
+ public function valueWithUnitDataProvider(): \Iterator
{
- return [
- ['1', 1.0, ''],
- ['1 V', 1.0, 'V'],
- ['1.23', 1.23, ''],
- ['1.23 V', 1.23, 'V'],
- ];
+ yield ['1', 1.0, ''];
+ yield ['1 V', 1.0, 'V'];
+ yield ['1.23', 1.23, ''];
+ yield ['1.23 V', 1.23, 'V'];
}
- public function formattedValueDataProvider(): array
+ public function formattedValueDataProvider(): \Iterator
{
- return [
- ['Text Test', null, null, null, 'V', 'Text Test'],
- ['10.23 V', null, 10.23, null, 'V', ''],
- ['10.23 V [Text]', null, 10.23, null, 'V', 'Text'],
- ['max. 10.23 V', null, null, 10.23, 'V', ''],
- ['max. 10.23 [Text]', null, null, 10.23, '', 'Text'],
- ['min. 10.23 V', 10.23, null, null, 'V', ''],
- ['10.23 V ... 11 V', 10.23, null, 11, 'V', ''],
- ['10.23 V (9 V ... 11 V)', 9, 10.23, 11, 'V', ''],
- ['10.23 V (9 V ... 11 V) [Test]', 9, 10.23, 11, 'V', 'Test'],
- ];
+ yield ['Text Test', null, null, null, 'V', 'Text Test'];
+ yield ['10.23 V', null, 10.23, null, 'V', ''];
+ yield ['10.23 V [Text]', null, 10.23, null, 'V', 'Text'];
+ yield ['max. 10.23 V', null, null, 10.23, 'V', ''];
+ yield ['max. 10.23 [Text]', null, null, 10.23, '', 'Text'];
+ yield ['min. 10.23 V', 10.23, null, null, 'V', ''];
+ yield ['10.23 V ... 11 V', 10.23, null, 11, 'V', ''];
+ yield ['10.23 V (9 V ... 11 V)', 9, 10.23, 11, 'V', ''];
+ yield ['10.23 V (9 V ... 11 V) [Test]', 9, 10.23, 11, 'V', 'Test'];
}
/**
diff --git a/tests/Entity/Parts/InfoProviderReferenceTest.php b/tests/Entity/Parts/InfoProviderReferenceTest.php
index 365eb68c..a1a8d5de 100644
--- a/tests/Entity/Parts/InfoProviderReferenceTest.php
+++ b/tests/Entity/Parts/InfoProviderReferenceTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Entity\Parts;
use App\Entity\Parts\InfoProviderReference;
@@ -46,9 +48,9 @@ class InfoProviderReferenceTest extends TestCase
//The provider reference instance should return true for the providerCreated method
$this->assertTrue($provider->isProviderCreated());
//And the correct values for all other methods
- $this->assertEquals('test', $provider->getProviderKey());
- $this->assertEquals('id', $provider->getProviderId());
- $this->assertEquals('url', $provider->getProviderUrl());
+ $this->assertSame('test', $provider->getProviderKey());
+ $this->assertSame('id', $provider->getProviderId());
+ $this->assertSame('url', $provider->getProviderUrl());
$this->assertNotNull($provider->getLastUpdated());
}
@@ -60,9 +62,9 @@ class InfoProviderReferenceTest extends TestCase
//The provider reference instance should return true for the providerCreated method
$this->assertTrue($reference->isProviderCreated());
//And the correct values for all other methods
- $this->assertEquals('test', $reference->getProviderKey());
- $this->assertEquals('id', $reference->getProviderId());
- $this->assertEquals('url', $reference->getProviderUrl());
+ $this->assertSame('test', $reference->getProviderKey());
+ $this->assertSame('id', $reference->getProviderId());
+ $this->assertSame('url', $reference->getProviderUrl());
$this->assertNotNull($reference->getLastUpdated());
}
}
diff --git a/tests/Entity/Parts/PartAssociationTest.php b/tests/Entity/Parts/PartAssociationTest.php
index d541c468..e002846e 100644
--- a/tests/Entity/Parts/PartAssociationTest.php
+++ b/tests/Entity/Parts/PartAssociationTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Entity\Parts;
use App\Entity\Parts\AssociationType;
@@ -34,7 +36,7 @@ class PartAssociationTest extends TestCase
$assoc->setOtherType('Custom Type');
//If the type is not OTHER the translation key should be the same as the type
- $this->assertEquals($assoc->getType()->getTranslationKey(), $assoc->getTypeTranslationKey());
+ $this->assertSame($assoc->getType()->getTranslationKey(), $assoc->getTypeTranslationKey());
//If the type is OTHER the translation key should be the other type
$assoc->setType(AssociationType::OTHER);
diff --git a/tests/Entity/Parts/PartTest.php b/tests/Entity/Parts/PartTest.php
index 275d39d2..fa1ecc39 100644
--- a/tests/Entity/Parts/PartTest.php
+++ b/tests/Entity/Parts/PartTest.php
@@ -55,15 +55,15 @@ class PartTest extends TestCase
//Without a set measurement unit the part must return an int
$part->setMinAmount(1.345);
- $this->assertSame(1.0, $part->getMinAmount());
+ $this->assertEqualsWithDelta(1.0, $part->getMinAmount(), PHP_FLOAT_EPSILON);
//If a non-int-based unit is assigned, a float is returned
$part->setPartUnit($measurement_unit);
- $this->assertSame(1.345, $part->getMinAmount());
+ $this->assertEqualsWithDelta(1.345, $part->getMinAmount(), PHP_FLOAT_EPSILON);
//If an int-based unit is assigned an int is returned
$measurement_unit->setIsInteger(true);
- $this->assertSame(1.0, $part->getMinAmount());
+ $this->assertEqualsWithDelta(1.0, $part->getMinAmount(), PHP_FLOAT_EPSILON);
}
public function testUseFloatAmount(): void
@@ -87,7 +87,7 @@ class PartTest extends TestCase
$measurement_unit = new MeasurementUnit();
$datetime = new DateTime();
- $this->assertSame(0.0, $part->getAmountSum());
+ $this->assertEqualsWithDelta(0.0, $part->getAmountSum(), PHP_FLOAT_EPSILON);
$part->addPartLot((new PartLot())->setAmount(3.141));
$part->addPartLot((new PartLot())->setAmount(10.0));
@@ -98,15 +98,15 @@ class PartTest extends TestCase
->setExpirationDate($datetime->setTimestamp(strtotime('now -1 hour')))
);
- $this->assertSame(13.0, $part->getAmountSum());
+ $this->assertEqualsWithDelta(13.0, $part->getAmountSum(), PHP_FLOAT_EPSILON);
$part->setPartUnit($measurement_unit);
- $this->assertSame(13.141, $part->getAmountSum());
+ $this->assertEqualsWithDelta(13.141, $part->getAmountSum(), PHP_FLOAT_EPSILON);
//1 billion part lot
$part->addPartLot((new PartLot())->setAmount(1_000_000_000));
- $this->assertSame(1_000_000_013.141, $part->getAmountSum());
+ $this->assertEqualsWithDelta(1_000_000_013.141, $part->getAmountSum(), PHP_FLOAT_EPSILON);
$measurement_unit->setIsInteger(true);
- $this->assertSame(1_000_000_013.0, $part->getAmountSum());
+ $this->assertEqualsWithDelta(1_000_000_013.0, $part->getAmountSum(), PHP_FLOAT_EPSILON);
}
}
diff --git a/tests/Entity/PriceSystem/PricedetailTest.php b/tests/Entity/PriceSystem/PricedetailTest.php
index dd5abb25..8a3cf328 100644
--- a/tests/Entity/PriceSystem/PricedetailTest.php
+++ b/tests/Entity/PriceSystem/PricedetailTest.php
@@ -60,18 +60,18 @@ class PricedetailTest extends TestCase
$orderdetail2->method('getPart')->willReturn($part2);
//By default a price detail returns 1
- $this->assertSame(1.0, $pricedetail->getPriceRelatedQuantity());
+ $this->assertEqualsWithDelta(1.0, $pricedetail->getPriceRelatedQuantity(), PHP_FLOAT_EPSILON);
$pricedetail->setOrderdetail($orderdetail);
$pricedetail->setPriceRelatedQuantity(10.23);
- $this->assertSame(10.0, $pricedetail->getPriceRelatedQuantity());
+ $this->assertEqualsWithDelta(10.0, $pricedetail->getPriceRelatedQuantity(), PHP_FLOAT_EPSILON);
//Price related quantity must not be zero!
$pricedetail->setPriceRelatedQuantity(0.23);
- $this->assertSame(1.0, $pricedetail->getPriceRelatedQuantity());
+ $this->assertEqualsWithDelta(1.0, $pricedetail->getPriceRelatedQuantity(), PHP_FLOAT_EPSILON);
//With a part that has a float amount unit, also values like 0.23 can be returned
$pricedetail->setOrderdetail($orderdetail2);
- $this->assertSame(0.23, $pricedetail->getPriceRelatedQuantity());
+ $this->assertEqualsWithDelta(0.23, $pricedetail->getPriceRelatedQuantity(), PHP_FLOAT_EPSILON);
}
public function testGetMinDiscountQuantity(): void
@@ -88,17 +88,17 @@ class PricedetailTest extends TestCase
$orderdetail2->method('getPart')->willReturn($part2);
//By default a price detail returns 1
- $this->assertSame(1.0, $pricedetail->getMinDiscountQuantity());
+ $this->assertEqualsWithDelta(1.0, $pricedetail->getMinDiscountQuantity(), PHP_FLOAT_EPSILON);
$pricedetail->setOrderdetail($orderdetail);
$pricedetail->setMinDiscountQuantity(10.23);
- $this->assertSame(10.0, $pricedetail->getMinDiscountQuantity());
+ $this->assertEqualsWithDelta(10.0, $pricedetail->getMinDiscountQuantity(), PHP_FLOAT_EPSILON);
//Price related quantity must not be zero!
$pricedetail->setMinDiscountQuantity(0.23);
- $this->assertSame(1.0, $pricedetail->getMinDiscountQuantity());
+ $this->assertEqualsWithDelta(1.0, $pricedetail->getMinDiscountQuantity(), PHP_FLOAT_EPSILON);
//With a part that has a float amount unit, also values like 0.23 can be returned
$pricedetail->setOrderdetail($orderdetail2);
- $this->assertSame(0.23, $pricedetail->getMinDiscountQuantity());
+ $this->assertEqualsWithDelta(0.23, $pricedetail->getMinDiscountQuantity(), PHP_FLOAT_EPSILON);
}
}
diff --git a/tests/Entity/UserSystem/ApiTokenTypeTest.php b/tests/Entity/UserSystem/ApiTokenTypeTest.php
index d504f39d..21d14b69 100644
--- a/tests/Entity/UserSystem/ApiTokenTypeTest.php
+++ b/tests/Entity/UserSystem/ApiTokenTypeTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Entity\UserSystem;
use App\Entity\UserSystem\ApiTokenType;
@@ -28,7 +30,7 @@ class ApiTokenTypeTest extends TestCase
public function testGetTokenPrefix(): void
{
- $this->assertEquals('tcp_', ApiTokenType::PERSONAL_ACCESS_TOKEN->getTokenPrefix());
+ $this->assertSame('tcp_', ApiTokenType::PERSONAL_ACCESS_TOKEN->getTokenPrefix());
}
public function testGetTypeFromToken(): void
diff --git a/tests/Entity/UserSystem/UserTest.php b/tests/Entity/UserSystem/UserTest.php
index 11837b77..a8b2cd5f 100644
--- a/tests/Entity/UserSystem/UserTest.php
+++ b/tests/Entity/UserSystem/UserTest.php
@@ -45,13 +45,11 @@ class UserTest extends TestCase
$this->assertSame('John (@username)', $user->getFullName(true));
}
- public function googleAuthenticatorEnabledDataProvider(): array
+ public function googleAuthenticatorEnabledDataProvider(): \Iterator
{
- return [
- [null, false],
- ['', false],
- ['SSSk38498', true],
- ];
+ yield [null, false];
+ yield ['', false];
+ yield ['SSSk38498', true];
}
/**
diff --git a/tests/Helpers/Projects/ProjectBuildRequestTest.php b/tests/Helpers/Projects/ProjectBuildRequestTest.php
index c561613d..baccfcd1 100644
--- a/tests/Helpers/Projects/ProjectBuildRequestTest.php
+++ b/tests/Helpers/Projects/ProjectBuildRequestTest.php
@@ -120,11 +120,11 @@ class ProjectBuildRequestTest extends TestCase
//The values should be already prefilled correctly
$request = new ProjectBuildRequest($this->project1, 10);
//We need totally 20: Take 10 from the first (maximum 10) and 10 from the second (maximum 20)
- $this->assertSame(10.0, $request->getLotWithdrawAmount($this->lot1a));
- $this->assertSame(10.0, $request->getLotWithdrawAmount($this->lot1b));
+ $this->assertEqualsWithDelta(10.0, $request->getLotWithdrawAmount($this->lot1a), PHP_FLOAT_EPSILON);
+ $this->assertEqualsWithDelta(10.0, $request->getLotWithdrawAmount($this->lot1b), PHP_FLOAT_EPSILON);
//If the needed amount is higher than the maximum, we should get the maximum
- $this->assertSame(2.5, $request->getLotWithdrawAmount($this->lot2));
+ $this->assertEqualsWithDelta(2.5, $request->getLotWithdrawAmount($this->lot2), PHP_FLOAT_EPSILON);
}
public function testGetNumberOfBuilds(): void
@@ -142,9 +142,9 @@ class ProjectBuildRequestTest extends TestCase
public function testGetNeededAmountForBOMEntry(): void
{
$build_request = new ProjectBuildRequest($this->project1, 5);
- $this->assertSame(10.0, $build_request->getNeededAmountForBOMEntry($this->bom_entry1a));
- $this->assertSame(7.5, $build_request->getNeededAmountForBOMEntry($this->bom_entry1b));
- $this->assertSame(20.0, $build_request->getNeededAmountForBOMEntry($this->bom_entry1c));
+ $this->assertEqualsWithDelta(10.0, $build_request->getNeededAmountForBOMEntry($this->bom_entry1a), PHP_FLOAT_EPSILON);
+ $this->assertEqualsWithDelta(7.5, $build_request->getNeededAmountForBOMEntry($this->bom_entry1b), PHP_FLOAT_EPSILON);
+ $this->assertEqualsWithDelta(20.0, $build_request->getNeededAmountForBOMEntry($this->bom_entry1c), PHP_FLOAT_EPSILON);
}
public function testGetSetLotWithdrawAmount(): void
@@ -156,8 +156,8 @@ class ProjectBuildRequestTest extends TestCase
$build_request->setLotWithdrawAmount($this->lot1b->getID(), 3);
//And it should be possible to get the amount via the lot object or via the ID
- $this->assertSame(2.0, $build_request->getLotWithdrawAmount($this->lot1a->getID()));
- $this->assertSame(3.0, $build_request->getLotWithdrawAmount($this->lot1b));
+ $this->assertEqualsWithDelta(2.0, $build_request->getLotWithdrawAmount($this->lot1a->getID()), PHP_FLOAT_EPSILON);
+ $this->assertEqualsWithDelta(3.0, $build_request->getLotWithdrawAmount($this->lot1b), PHP_FLOAT_EPSILON);
}
public function testGetWithdrawAmountSum(): void
@@ -168,9 +168,9 @@ class ProjectBuildRequestTest extends TestCase
$build_request->setLotWithdrawAmount($this->lot1a, 2);
$build_request->setLotWithdrawAmount($this->lot1b, 3);
- $this->assertSame(5.0, $build_request->getWithdrawAmountSum($this->bom_entry1a));
+ $this->assertEqualsWithDelta(5.0, $build_request->getWithdrawAmountSum($this->bom_entry1a), PHP_FLOAT_EPSILON);
$build_request->setLotWithdrawAmount($this->lot2, 1.5);
- $this->assertSame(1.5, $build_request->getWithdrawAmountSum($this->bom_entry1b));
+ $this->assertEqualsWithDelta(1.5, $build_request->getWithdrawAmountSum($this->bom_entry1b), PHP_FLOAT_EPSILON);
}
diff --git a/tests/Helpers/TrinaryLogicHelperTest.php b/tests/Helpers/TrinaryLogicHelperTest.php
index f8ec35b1..3082571b 100644
--- a/tests/Helpers/TrinaryLogicHelperTest.php
+++ b/tests/Helpers/TrinaryLogicHelperTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Helpers;
use App\Helpers\TrinaryLogicHelper;
diff --git a/tests/Repository/AttachmentContainingDBElementRepositoryTest.php b/tests/Repository/AttachmentContainingDBElementRepositoryTest.php
index e11bd138..f61750d9 100644
--- a/tests/Repository/AttachmentContainingDBElementRepositoryTest.php
+++ b/tests/Repository/AttachmentContainingDBElementRepositoryTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Repository;
use App\Entity\Parts\Category;
diff --git a/tests/Repository/DBElementRepositoryTest.php b/tests/Repository/DBElementRepositoryTest.php
index c803302b..05ede7e2 100644
--- a/tests/Repository/DBElementRepositoryTest.php
+++ b/tests/Repository/DBElementRepositoryTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Repository;
use App\Entity\Attachments\Attachment;
diff --git a/tests/Repository/UserRepositoryTest.php b/tests/Repository/UserRepositoryTest.php
index dea4a294..0e6f3c2d 100644
--- a/tests/Repository/UserRepositoryTest.php
+++ b/tests/Repository/UserRepositoryTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Repository;
use App\Entity\UserSystem\User;
diff --git a/tests/Serializer/PartNormalizerTest.php b/tests/Serializer/PartNormalizerTest.php
index de5ac2db..cd93d93c 100644
--- a/tests/Serializer/PartNormalizerTest.php
+++ b/tests/Serializer/PartNormalizerTest.php
@@ -110,7 +110,7 @@ class PartNormalizerTest extends WebTestCase
$this->assertCount(1, $part->getPartLots());
/** @var PartLot $partLot */
$partLot = $part->getPartLots()->first();
- $this->assertSame(5.0, $partLot->getAmount());
+ $this->assertEqualsWithDelta(5.0, $partLot->getAmount(), PHP_FLOAT_EPSILON);
$this->assertNotNull($partLot->getStorageLocation());
$this->assertSame('Test Storage Location', $partLot->getStorageLocation()->getName());
@@ -130,7 +130,7 @@ class PartNormalizerTest extends WebTestCase
//Must be in base currency
$this->assertNull($priceDetail->getCurrency());
//Must be for 1 part and 1 minimum order quantity
- $this->assertSame(1.0, $priceDetail->getPriceRelatedQuantity());
- $this->assertSame(1.0, $priceDetail->getMinDiscountQuantity());
+ $this->assertEqualsWithDelta(1.0, $priceDetail->getPriceRelatedQuantity(), PHP_FLOAT_EPSILON);
+ $this->assertEqualsWithDelta(1.0, $priceDetail->getMinDiscountQuantity(), PHP_FLOAT_EPSILON);
}
}
diff --git a/tests/Services/Attachments/AttachmentPathResolverTest.php b/tests/Services/Attachments/AttachmentPathResolverTest.php
index 22809390..3c432f48 100644
--- a/tests/Services/Attachments/AttachmentPathResolverTest.php
+++ b/tests/Services/Attachments/AttachmentPathResolverTest.php
@@ -69,7 +69,7 @@ class AttachmentPathResolverTest extends WebTestCase
$this->assertNull($this->service->parameterToAbsolutePath('/./this/one/too'));
}
- public function placeholderDataProvider(): array
+ public function placeholderDataProvider(): \Iterator
{
//We need to do initialization (again), as dataprovider is called before setUp()
self::bootKernel();
@@ -77,28 +77,28 @@ class AttachmentPathResolverTest extends WebTestCase
$this->projectDir = str_replace('\\', '/', $this->projectDir_orig);
$this->media_path = $this->projectDir.'/public/media';
$this->footprint_path = $this->projectDir.'/public/img/footprints';
-
- return [
- ['%FOOTPRINTS%/test/test.jpg', $this->footprint_path.'/test/test.jpg'],
- ['%FOOTPRINTS%/test/', $this->footprint_path.'/test/'],
- ['%MEDIA%/test', $this->media_path.'/test'],
- ['%MEDIA%', $this->media_path],
- ['%FOOTPRINTS%', $this->footprint_path],
- //Footprints 3D are disabled
- ['%FOOTPRINTS_3D%', null],
- //Check that invalid pathes return null
- ['/no/placeholder', null],
- ['%INVALID_PLACEHOLDER%', null],
- ['%FOOTPRINTS/test/', null], //Malformed placeholder
- ['/wrong/%FOOTRPINTS%/', null], //Placeholder not at beginning
- ['%FOOTPRINTS%/%MEDIA%', null], //No more than one placholder
- ['%FOOTPRINTS%/%FOOTPRINTS%', null],
- ['%FOOTPRINTS%/../../etc/passwd', null],
- ['%FOOTPRINTS%/0\..\test', null],
- ];
+ yield ['%FOOTPRINTS%/test/test.jpg', $this->footprint_path.'/test/test.jpg'];
+ yield ['%FOOTPRINTS%/test/', $this->footprint_path.'/test/'];
+ yield ['%MEDIA%/test', $this->media_path.'/test'];
+ yield ['%MEDIA%', $this->media_path];
+ yield ['%FOOTPRINTS%', $this->footprint_path];
+ //Footprints 3D are disabled
+ yield ['%FOOTPRINTS_3D%', null];
+ //Check that invalid pathes return null
+ yield ['/no/placeholder', null];
+ yield ['%INVALID_PLACEHOLDER%', null];
+ yield ['%FOOTPRINTS/test/', null];
+ //Malformed placeholder
+ yield ['/wrong/%FOOTRPINTS%/', null];
+ //Placeholder not at beginning
+ yield ['%FOOTPRINTS%/%MEDIA%', null];
+ //No more than one placholder
+ yield ['%FOOTPRINTS%/%FOOTPRINTS%', null];
+ yield ['%FOOTPRINTS%/../../etc/passwd', null];
+ yield ['%FOOTPRINTS%/0\..\test', null];
}
- public function realPathDataProvider(): array
+ public function realPathDataProvider(): \Iterator
{
//We need to do initialization (again), as dataprovider is called before setUp()
self::bootKernel();
@@ -106,20 +106,17 @@ class AttachmentPathResolverTest extends WebTestCase
$this->projectDir = str_replace('\\', '/', $this->projectDir_orig);
$this->media_path = $this->projectDir.'/public/media';
$this->footprint_path = $this->projectDir.'/public/img/footprints';
-
- return [
- [$this->media_path.'/test/img.jpg', '%MEDIA%/test/img.jpg'],
- [$this->media_path.'/test/img.jpg', '%BASE%/data/media/test/img.jpg', true],
- [$this->footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg'],
- [$this->footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg', true],
- //Every kind of absolute path, that is not based with our placeholder dirs must be invald
- ['/etc/passwd', null],
- ['C:\\not\\existing.txt', null],
- //More than one placeholder is not allowed
- [$this->footprint_path.'/test/'.$this->footprint_path, null],
- //Path must begin with path
- ['/not/root'.$this->footprint_path, null],
- ];
+ yield [$this->media_path.'/test/img.jpg', '%MEDIA%/test/img.jpg'];
+ yield [$this->media_path.'/test/img.jpg', '%BASE%/data/media/test/img.jpg', true];
+ yield [$this->footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg'];
+ yield [$this->footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg', true];
+ //Every kind of absolute path, that is not based with our placeholder dirs must be invald
+ yield ['/etc/passwd', null];
+ yield ['C:\\not\\existing.txt', null];
+ //More than one placeholder is not allowed
+ yield [$this->footprint_path.'/test/'.$this->footprint_path, null];
+ //Path must begin with path
+ yield ['/not/root'.$this->footprint_path, null];
}
/**
diff --git a/tests/Services/Attachments/FileTypeFilterToolsTest.php b/tests/Services/Attachments/FileTypeFilterToolsTest.php
index 63aa8bde..a6032a4b 100644
--- a/tests/Services/Attachments/FileTypeFilterToolsTest.php
+++ b/tests/Services/Attachments/FileTypeFilterToolsTest.php
@@ -35,56 +35,52 @@ class FileTypeFilterToolsTest extends WebTestCase
self::$service = self::getContainer()->get(FileTypeFilterTools::class);
}
- public function validateDataProvider(): array
+ public function validateDataProvider(): \Iterator
{
- return [
- ['', true], //Empty string is valid
- ['.jpeg,.png, .gif', true], //Only extensions are valid
- ['image/*, video/*, .mp4, video/x-msvideo, application/vnd.amazon.ebook', true],
- ['application/vnd.amazon.ebook, audio/opus', true],
-
- ['*.notvalid, .png', false], //No stars in extension
- ['test.png', false], //No full filename
- ['application/*', false], //Only certain placeholders are allowed
- ['.png;.png,.jpg', false], //Wrong separator
- ['.png .jpg .gif', false],
- ];
+ yield ['', true];
+ //Empty string is valid
+ yield ['.jpeg,.png, .gif', true];
+ //Only extensions are valid
+ yield ['image/*, video/*, .mp4, video/x-msvideo, application/vnd.amazon.ebook', true];
+ yield ['application/vnd.amazon.ebook, audio/opus', true];
+ yield ['*.notvalid, .png', false];
+ //No stars in extension
+ yield ['test.png', false];
+ //No full filename
+ yield ['application/*', false];
+ //Only certain placeholders are allowed
+ yield ['.png;.png,.jpg', false];
+ //Wrong separator
+ yield ['.png .jpg .gif', false];
}
- public function normalizeDataProvider(): array
+ public function normalizeDataProvider(): \Iterator
{
- return [
- ['', ''],
- ['.jpeg,.png,.gif', '.jpeg,.png,.gif'],
- ['.jpeg, .png, .gif,', '.jpeg,.png,.gif'],
- ['jpg, *.gif', '.jpg,.gif'],
- ['video, image/', 'video/*,image/*'],
- ['video/*', 'video/*'],
- ['video/x-msvideo,.jpeg', 'video/x-msvideo,.jpeg'],
- ['.video', '.video'],
- //Remove duplicate entries
- ['png, .gif, .png,', '.png,.gif'],
- ];
+ yield ['', ''];
+ yield ['.jpeg,.png,.gif', '.jpeg,.png,.gif'];
+ yield ['.jpeg, .png, .gif,', '.jpeg,.png,.gif'];
+ yield ['jpg, *.gif', '.jpg,.gif'];
+ yield ['video, image/', 'video/*,image/*'];
+ yield ['video/*', 'video/*'];
+ yield ['video/x-msvideo,.jpeg', 'video/x-msvideo,.jpeg'];
+ yield ['.video', '.video'];
+ //Remove duplicate entries
+ yield ['png, .gif, .png,', '.png,.gif'];
}
- public function extensionAllowedDataProvider(): array
+ public function extensionAllowedDataProvider(): \Iterator
{
- return [
- ['', 'txt', true],
- ['', 'everything_should_match', true],
-
- ['.jpg,.png', 'jpg', true],
- ['.jpg,.png', 'png', true],
- ['.jpg,.png', 'txt', false],
-
- ['image/*', 'jpeg', true],
- ['image/*', 'png', true],
- ['image/*', 'txt', false],
-
- ['application/pdf,.txt', 'pdf', true],
- ['application/pdf,.txt', 'txt', true],
- ['application/pdf,.txt', 'jpg', false],
- ];
+ yield ['', 'txt', true];
+ yield ['', 'everything_should_match', true];
+ yield ['.jpg,.png', 'jpg', true];
+ yield ['.jpg,.png', 'png', true];
+ yield ['.jpg,.png', 'txt', false];
+ yield ['image/*', 'jpeg', true];
+ yield ['image/*', 'png', true];
+ yield ['image/*', 'txt', false];
+ yield ['application/pdf,.txt', 'pdf', true];
+ yield ['application/pdf,.txt', 'txt', true];
+ yield ['application/pdf,.txt', 'jpg', false];
}
/**
diff --git a/tests/Services/EntityMergers/Mergers/EntityMergerHelperTraitTest.php b/tests/Services/EntityMergers/Mergers/EntityMergerHelperTraitTest.php
index 7daedef2..22fa220b 100644
--- a/tests/Services/EntityMergers/Mergers/EntityMergerHelperTraitTest.php
+++ b/tests/Services/EntityMergers/Mergers/EntityMergerHelperTraitTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Services\EntityMergers\Mergers;
use App\Entity\Parts\Part;
diff --git a/tests/Services/EntityMergers/Mergers/MergeTestClass.php b/tests/Services/EntityMergers/Mergers/MergeTestClass.php
index da7ad67c..73fa9314 100644
--- a/tests/Services/EntityMergers/Mergers/MergeTestClass.php
+++ b/tests/Services/EntityMergers/Mergers/MergeTestClass.php
@@ -37,7 +37,7 @@ class MergeTestClass
public Collection $collection;
- public ?Category $category;
+ public ?Category $category = null;
public function __construct()
{
diff --git a/tests/Services/EntityMergers/Mergers/PartMergerTest.php b/tests/Services/EntityMergers/Mergers/PartMergerTest.php
index d607ee72..fc60ca23 100644
--- a/tests/Services/EntityMergers/Mergers/PartMergerTest.php
+++ b/tests/Services/EntityMergers/Mergers/PartMergerTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Services\EntityMergers\Mergers;
use App\Entity\Parts\AssociationType;
diff --git a/tests/Services/ImportExportSystem/BOMImporterTest.php b/tests/Services/ImportExportSystem/BOMImporterTest.php
index b7379537..b9aba1d4 100644
--- a/tests/Services/ImportExportSystem/BOMImporterTest.php
+++ b/tests/Services/ImportExportSystem/BOMImporterTest.php
@@ -84,7 +84,7 @@ class BOMImporterTest extends WebTestCase
$this->assertCount(4, $bom);
$this->assertSame('R19,R17', $bom[0]->getMountnames());
- $this->assertSame(2.0, $bom[0]->getQuantity());
+ $this->assertEqualsWithDelta(2.0, $bom[0]->getQuantity(), PHP_FLOAT_EPSILON);
$this->assertSame('4.7k (R_0805_2012Metric_Pad1.20x1.40mm_HandSolder)', $bom[0]->getName());
$this->assertSame('Test', $bom[0]->getComment());
@@ -103,7 +103,7 @@ class BOMImporterTest extends WebTestCase
$this->assertCount(4, $bom);
$this->assertSame('R19,R17', $bom[0]->getMountnames());
- $this->assertSame(2.0, $bom[0]->getQuantity());
+ $this->assertEqualsWithDelta(2.0, $bom[0]->getQuantity(), PHP_FLOAT_EPSILON);
$this->assertSame('4.7k (R_0805_2012Metric_Pad1.20x1.40mm_HandSolder)', $bom[0]->getName());
$this->assertSame('Test', $bom[0]->getComment());
}
diff --git a/tests/Services/ImportExportSystem/EntityImporterTest.php b/tests/Services/ImportExportSystem/EntityImporterTest.php
index 07ac0017..43c41689 100644
--- a/tests/Services/ImportExportSystem/EntityImporterTest.php
+++ b/tests/Services/ImportExportSystem/EntityImporterTest.php
@@ -172,16 +172,14 @@ EOT;
$this->assertSame($longName, $errors[0]['entity']->getName());
}
- public function formatDataProvider(): array
+ public function formatDataProvider(): \Iterator
{
- return [
- ['csv', 'csv'],
- ['csv', 'CSV'],
- ['xml', 'Xml'],
- ['json', 'json'],
- ['yaml', 'yml'],
- ['yaml', 'YAML'],
- ];
+ yield ['csv', 'csv'];
+ yield ['csv', 'CSV'];
+ yield ['xml', 'Xml'];
+ yield ['json', 'json'];
+ yield ['yaml', 'yml'];
+ yield ['yaml', 'YAML'];
}
/**
diff --git a/tests/Services/InfoProviderSystem/DTOs/ParameterDTOTest.php b/tests/Services/InfoProviderSystem/DTOs/ParameterDTOTest.php
index 105cbfcf..7bbebf0b 100644
--- a/tests/Services/InfoProviderSystem/DTOs/ParameterDTOTest.php
+++ b/tests/Services/InfoProviderSystem/DTOs/ParameterDTOTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Services\InfoProviderSystem\DTOs;
use App\Services\InfoProviderSystem\DTOs\ParameterDTO;
@@ -241,18 +243,18 @@ class ParameterDTOTest extends TestCase
public function testSplitIntoValueAndUnit(): void
{
- $this->assertEquals(['1.0', 'kg'], ParameterDTO::splitIntoValueAndUnit('1.0 kg'));
- $this->assertEquals(['1.0', 'kg'], ParameterDTO::splitIntoValueAndUnit('1.0kg'));
- $this->assertEquals(['1', 'kg'], ParameterDTO::splitIntoValueAndUnit('1 kg'));
+ $this->assertSame(['1.0', 'kg'], ParameterDTO::splitIntoValueAndUnit('1.0 kg'));
+ $this->assertSame(['1.0', 'kg'], ParameterDTO::splitIntoValueAndUnit('1.0kg'));
+ $this->assertSame(['1', 'kg'], ParameterDTO::splitIntoValueAndUnit('1 kg'));
- $this->assertEquals(['1.0', '°C'], ParameterDTO::splitIntoValueAndUnit('1.0°C'));
- $this->assertEquals(['1.0', '°C'], ParameterDTO::splitIntoValueAndUnit('1.0 °C'));
+ $this->assertSame(['1.0', '°C'], ParameterDTO::splitIntoValueAndUnit('1.0°C'));
+ $this->assertSame(['1.0', '°C'], ParameterDTO::splitIntoValueAndUnit('1.0 °C'));
- $this->assertEquals(['1.0', 'C_m'], ParameterDTO::splitIntoValueAndUnit('1.0C_m'));
- $this->assertEquals(["70", "℃"], ParameterDTO::splitIntoValueAndUnit("70℃"));
+ $this->assertSame(['1.0', 'C_m'], ParameterDTO::splitIntoValueAndUnit('1.0C_m'));
+ $this->assertSame(["70", "℃"], ParameterDTO::splitIntoValueAndUnit("70℃"));
- $this->assertEquals(["-5.0", "kg"], ParameterDTO::splitIntoValueAndUnit("-5.0 kg"));
- $this->assertEquals(["-5.0", "µg"], ParameterDTO::splitIntoValueAndUnit("-5.0 µg"));
+ $this->assertSame(["-5.0", "kg"], ParameterDTO::splitIntoValueAndUnit("-5.0 kg"));
+ $this->assertSame(["-5.0", "µg"], ParameterDTO::splitIntoValueAndUnit("-5.0 µg"));
$this->assertNull(ParameterDTO::splitIntoValueAndUnit('kg'));
$this->assertNull(ParameterDTO::splitIntoValueAndUnit('Test'));
diff --git a/tests/Services/InfoProviderSystem/DTOs/PurchaseInfoDTOTest.php b/tests/Services/InfoProviderSystem/DTOs/PurchaseInfoDTOTest.php
index 0442a873..14a3c03f 100644
--- a/tests/Services/InfoProviderSystem/DTOs/PurchaseInfoDTOTest.php
+++ b/tests/Services/InfoProviderSystem/DTOs/PurchaseInfoDTOTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Services\InfoProviderSystem\DTOs;
use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO;
diff --git a/tests/Services/InfoProviderSystem/DTOs/SearchResultDTOTest.php b/tests/Services/InfoProviderSystem/DTOs/SearchResultDTOTest.php
index f23439f8..dd516c8d 100644
--- a/tests/Services/InfoProviderSystem/DTOs/SearchResultDTOTest.php
+++ b/tests/Services/InfoProviderSystem/DTOs/SearchResultDTOTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Services\InfoProviderSystem\DTOs;
use App\Services\InfoProviderSystem\DTOs\SearchResultDTO;
@@ -45,8 +47,8 @@ class SearchResultDTOTest extends TestCase
'description',
preview_image_url: 'https://invalid.com/preview_image_url.jpg'
);
- $this->assertEquals('https://invalid.com/preview_image_url.jpg', $searchResultDTO->preview_image_url);
- $this->assertEquals('https://invalid.com/preview_image_url.jpg', $searchResultDTO->preview_image_file->url);
+ $this->assertSame('https://invalid.com/preview_image_url.jpg', $searchResultDTO->preview_image_url);
+ $this->assertSame('https://invalid.com/preview_image_url.jpg', $searchResultDTO->preview_image_file->url);
//Invalid url characters should be replaced with their URL encoded version (similar to FileDTO)
$searchResultDTO = new SearchResultDTO(
@@ -56,7 +58,7 @@ class SearchResultDTOTest extends TestCase
'description',
preview_image_url: 'https://invalid.com/preview_image^url.jpg?param1=1¶m2=2'
);
- $this->assertEquals('https://invalid.com/preview_image%5Eurl.jpg?param1=1¶m2=2', $searchResultDTO->preview_image_url);
- $this->assertEquals('https://invalid.com/preview_image%5Eurl.jpg?param1=1¶m2=2', $searchResultDTO->preview_image_file->url);
+ $this->assertSame('https://invalid.com/preview_image%5Eurl.jpg?param1=1¶m2=2', $searchResultDTO->preview_image_url);
+ $this->assertSame('https://invalid.com/preview_image%5Eurl.jpg?param1=1¶m2=2', $searchResultDTO->preview_image_file->url);
}
}
diff --git a/tests/Services/InfoProviderSystem/DTOtoEntityConverterTest.php b/tests/Services/InfoProviderSystem/DTOtoEntityConverterTest.php
index 658f5135..6c6637c3 100644
--- a/tests/Services/InfoProviderSystem/DTOtoEntityConverterTest.php
+++ b/tests/Services/InfoProviderSystem/DTOtoEntityConverterTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Services\InfoProviderSystem;
use App\Entity\Attachments\AttachmentType;
@@ -53,7 +55,7 @@ class DTOtoEntityConverterTest extends WebTestCase
$entity = $this->service->convertParameter($dto);
- $this->assertEquals($dto->name, $entity->getName());
+ $this->assertSame($dto->name, $entity->getName());
$this->assertEquals($dto->value_text, $entity->getValueText());
$this->assertEquals($dto->value_typ, $entity->getValueTypical());
$this->assertEquals($dto->value_min, $entity->getValueMin());
@@ -74,8 +76,8 @@ class DTOtoEntityConverterTest extends WebTestCase
);
$entity = $this->service->convertPrice($dto);
- $this->assertEquals($dto->minimum_discount_amount, $entity->getMinDiscountQuantity());
- $this->assertEquals((float) $dto->price, (float) (string) $entity->getPrice());
+ $this->assertSame($dto->minimum_discount_amount, $entity->getMinDiscountQuantity());
+ $this->assertSame((float) $dto->price, (float) (string) $entity->getPrice());
$this->assertEquals($dto->price_related_quantity, $entity->getPriceRelatedQuantity());
//For non-base currencies, a new currency entity is created
@@ -114,8 +116,8 @@ class DTOtoEntityConverterTest extends WebTestCase
$entity = $this->service->convertPurchaseInfo($dto);
- $this->assertEquals($dto->distributor_name, $entity->getSupplier()->getName());
- $this->assertEquals($dto->order_number, $entity->getSupplierPartNr());
+ $this->assertSame($dto->distributor_name, $entity->getSupplier()->getName());
+ $this->assertSame($dto->order_number, $entity->getSupplierPartNr());
$this->assertEquals($dto->product_url, $entity->getSupplierProductUrl());
}
@@ -128,7 +130,7 @@ class DTOtoEntityConverterTest extends WebTestCase
$entity = $this->service->convertFile($dto, $type);
$this->assertEquals($dto->name, $entity->getName());
- $this->assertEquals($dto->url, $entity->getUrl());
+ $this->assertSame($dto->url, $entity->getUrl());
$this->assertEquals($type, $entity->getAttachmentType());
}
@@ -141,8 +143,8 @@ class DTOtoEntityConverterTest extends WebTestCase
$entity = $this->service->convertFile($dto, $type);
//If no name is given, the name is derived from the url
- $this->assertEquals('file.pdf', $entity->getName());
- $this->assertEquals($dto->url, $entity->getUrl());
+ $this->assertSame('file.pdf', $entity->getName());
+ $this->assertSame($dto->url, $entity->getUrl());
$this->assertEquals($type, $entity->getAttachmentType());
}
@@ -184,11 +186,11 @@ class DTOtoEntityConverterTest extends WebTestCase
$this->assertCount(3, $entity->getAttachments());
//The attachments should have the name of the named duplicate file
$image1 = $entity->getAttachments()[0];
- $this->assertEquals('Main image', $image1->getName());
+ $this->assertSame('Main image', $image1->getName());
$image1 = $entity->getAttachments()[1];
$datasheet = $entity->getAttachments()[2];
- $this->assertEquals('TestFile', $datasheet->getName());
+ $this->assertSame('TestFile', $datasheet->getName());
}
}
diff --git a/tests/Services/InfoProviderSystem/ProviderRegistryTest.php b/tests/Services/InfoProviderSystem/ProviderRegistryTest.php
index 5e6bec28..9026c5bf 100644
--- a/tests/Services/InfoProviderSystem/ProviderRegistryTest.php
+++ b/tests/Services/InfoProviderSystem/ProviderRegistryTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Services\InfoProviderSystem;
use App\Services\InfoProviderSystem\ProviderRegistry;
diff --git a/tests/Services/LabelSystem/Barcodes/BarcodeContentGeneratorTest.php b/tests/Services/LabelSystem/Barcodes/BarcodeContentGeneratorTest.php
index e14d9bc5..9d0ed7e2 100644
--- a/tests/Services/LabelSystem/Barcodes/BarcodeContentGeneratorTest.php
+++ b/tests/Services/LabelSystem/Barcodes/BarcodeContentGeneratorTest.php
@@ -57,22 +57,18 @@ class BarcodeContentGeneratorTest extends KernelTestCase
$this->service = self::getContainer()->get(BarcodeContentGenerator::class);
}
- public function Barcode1DDataProvider(): array
+ public function Barcode1DDataProvider(): \Iterator
{
- return [
- ['P0000', Part::class],
- ['L0000', PartLot::class],
- ['S0000', StorageLocation::class],
- ];
+ yield ['P0000', Part::class];
+ yield ['L0000', PartLot::class];
+ yield ['S0000', StorageLocation::class];
}
- public function Barcode2DDataProvider(): array
+ public function Barcode2DDataProvider(): \Iterator
{
- return [
- ['/scan/part/0', Part::class],
- ['/scan/lot/0', PartLot::class],
- ['/scan/location/0', StorageLocation::class],
- ];
+ yield ['/scan/part/0', Part::class];
+ yield ['/scan/lot/0', PartLot::class];
+ yield ['/scan/location/0', StorageLocation::class];
}
/**
diff --git a/tests/Services/LabelSystem/Barcodes/BarcodeHelperTest.php b/tests/Services/LabelSystem/Barcodes/BarcodeHelperTest.php
index e0639427..d681b3b9 100644
--- a/tests/Services/LabelSystem/Barcodes/BarcodeHelperTest.php
+++ b/tests/Services/LabelSystem/Barcodes/BarcodeHelperTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Services\LabelSystem\Barcodes;
use App\Entity\LabelSystem\BarcodeType;
diff --git a/tests/Services/LabelSystem/Barcodes/BarcodeRedirectorTest.php b/tests/Services/LabelSystem/Barcodes/BarcodeRedirectorTest.php
index 08390896..b2b94bab 100644
--- a/tests/Services/LabelSystem/Barcodes/BarcodeRedirectorTest.php
+++ b/tests/Services/LabelSystem/Barcodes/BarcodeRedirectorTest.php
@@ -58,14 +58,12 @@ final class BarcodeRedirectorTest extends KernelTestCase
$this->service = self::getContainer()->get(BarcodeRedirector::class);
}
- public static function urlDataProvider(): array
+ public static function urlDataProvider(): \Iterator
{
- return [
- [new BarcodeScanResult(LabelSupportedElement::PART, 1, BarcodeSourceType::INTERNAL), '/en/part/1'],
- //Part lot redirects to Part info page (Part lot 1 is associated with part 3)
- [new BarcodeScanResult(LabelSupportedElement::PART_LOT, 1, BarcodeSourceType::INTERNAL), '/en/part/3'],
- [new BarcodeScanResult(LabelSupportedElement::STORELOCATION, 1, BarcodeSourceType::INTERNAL), '/en/store_location/1/parts'],
- ];
+ yield [new BarcodeScanResult(LabelSupportedElement::PART, 1, BarcodeSourceType::INTERNAL), '/en/part/1'];
+ //Part lot redirects to Part info page (Part lot 1 is associated with part 3)
+ yield [new BarcodeScanResult(LabelSupportedElement::PART_LOT, 1, BarcodeSourceType::INTERNAL), '/en/part/3'];
+ yield [new BarcodeScanResult(LabelSupportedElement::STORELOCATION, 1, BarcodeSourceType::INTERNAL), '/en/store_location/1/parts'];
}
/**
diff --git a/tests/Services/LabelSystem/Barcodes/BarcodeScanHelperTest.php b/tests/Services/LabelSystem/Barcodes/BarcodeScanHelperTest.php
index 60a0a3f1..65cb02d4 100644
--- a/tests/Services/LabelSystem/Barcodes/BarcodeScanHelperTest.php
+++ b/tests/Services/LabelSystem/Barcodes/BarcodeScanHelperTest.php
@@ -113,16 +113,19 @@ class BarcodeScanHelperTest extends WebTestCase
'lot2_vendor_barcode'];
}
- public static function invalidDataProvider(): array
+ public static function invalidDataProvider(): \Iterator
{
- return [
- ['https://localhost/part/1'], //Without scan
- ['L-'], //Without number
- ['L-123'], //Too short
- ['X-123456'], //Unknown prefix
- ['XXXWADSDF sdf'], //Garbage
- [''], //Empty
- ];
+ yield ['https://localhost/part/1'];
+ //Without scan
+ yield ['L-'];
+ //Without number
+ yield ['L-123'];
+ //Too short
+ yield ['X-123456'];
+ //Unknown prefix
+ yield ['XXXWADSDF sdf'];
+ //Garbage
+ yield [''];
}
/**
diff --git a/tests/Services/LabelSystem/LabelGeneratorTest.php b/tests/Services/LabelSystem/LabelGeneratorTest.php
index ff347a93..88ab97c5 100644
--- a/tests/Services/LabelSystem/LabelGeneratorTest.php
+++ b/tests/Services/LabelSystem/LabelGeneratorTest.php
@@ -63,13 +63,11 @@ class LabelGeneratorTest extends WebTestCase
$this->service = self::getContainer()->get(LabelGenerator::class);
}
- public static function supportsDataProvider(): array
+ public static function supportsDataProvider(): \Iterator
{
- return [
- [LabelSupportedElement::PART, Part::class],
- [LabelSupportedElement::PART_LOT, PartLot::class],
- [LabelSupportedElement::STORELOCATION, StorageLocation::class],
- ];
+ yield [LabelSupportedElement::PART, Part::class];
+ yield [LabelSupportedElement::PART_LOT, PartLot::class];
+ yield [LabelSupportedElement::STORELOCATION, StorageLocation::class];
}
/**
diff --git a/tests/Services/LabelSystem/LabelTextReplacerTest.php b/tests/Services/LabelSystem/LabelTextReplacerTest.php
index 0d9aa3ae..e5c7c26e 100644
--- a/tests/Services/LabelSystem/LabelTextReplacerTest.php
+++ b/tests/Services/LabelSystem/LabelTextReplacerTest.php
@@ -70,32 +70,28 @@ class LabelTextReplacerTest extends WebTestCase
$this->target->setComment('P Comment');
}
- public function handlePlaceholderDataProvider(): array
+ public function handlePlaceholderDataProvider(): \Iterator
{
- return [
- ['Part 1', '[[NAME]]'],
- ['P Description', '[[DESCRIPTION]]'],
- ['[[UNKNOWN]]', '[[UNKNOWN]]', '[[UNKNOWN]]'],
- ['[[INVALID', '[[INVALID'],
- ['[[', '[['],
- ['NAME', 'NAME'],
- ['[[NAME', '[[NAME'],
- ['Test [[NAME]]', 'Test [[NAME]]', 'Test [[NAME]]'],
- ];
+ yield ['Part 1', '[[NAME]]'];
+ yield ['P Description', '[[DESCRIPTION]]'];
+ yield ['[[UNKNOWN]]', '[[UNKNOWN]]', '[[UNKNOWN]]'];
+ yield ['[[INVALID', '[[INVALID'];
+ yield ['[[', '[['];
+ yield ['NAME', 'NAME'];
+ yield ['[[NAME', '[[NAME'];
+ yield ['Test [[NAME]]', 'Test [[NAME]]', 'Test [[NAME]]'];
}
- public function replaceDataProvider(): array
+ public function replaceDataProvider(): \Iterator
{
- return [
- ['Part 1', '[[NAME]]'],
- ['TestPart 1', 'Test[[NAME]]'],
- ["P Description\nPart 1", "[[DESCRIPTION_T]]\n[[NAME]]"],
- ['Part 1 Part 1', '[[NAME]] [[NAME]]'],
- ['[[UNKNOWN]] Test', '[[UNKNOWN]] Test'],
- ["[[NAME\n]] [[NAME ]]", "[[NAME\n]] [[NAME ]]"],
- ['[[]]', '[[]]'],
- ['TEST[[ ]]TEST', 'TEST[[ ]]TEST'],
- ];
+ yield ['Part 1', '[[NAME]]'];
+ yield ['TestPart 1', 'Test[[NAME]]'];
+ yield ["P Description\nPart 1", "[[DESCRIPTION_T]]\n[[NAME]]"];
+ yield ['Part 1 Part 1', '[[NAME]] [[NAME]]'];
+ yield ['[[UNKNOWN]] Test', '[[UNKNOWN]] Test'];
+ yield ["[[NAME\n]] [[NAME ]]", "[[NAME\n]] [[NAME ]]"];
+ yield ['[[]]', '[[]]'];
+ yield ['TEST[[ ]]TEST', 'TEST[[ ]]TEST'];
}
/**
diff --git a/tests/Services/LabelSystem/SandboxedTwigFactoryTest.php b/tests/Services/LabelSystem/SandboxedTwigFactoryTest.php
index 7d43db7a..13a06b54 100644
--- a/tests/Services/LabelSystem/SandboxedTwigFactoryTest.php
+++ b/tests/Services/LabelSystem/SandboxedTwigFactoryTest.php
@@ -61,50 +61,46 @@ class SandboxedTwigFactoryTest extends WebTestCase
$this->service = self::getContainer()->get(SandboxedTwigFactory::class);
}
- public function twigDataProvider(): array
+ public function twigDataProvider(): \Iterator
{
- return [
- [' {% for i in range(1, 3) %}
+ yield [' {% for i in range(1, 3) %}
{{ part.id }}
{{ part.name }}
{{ part.lastModified | format_datetime }}
{% endfor %}
- '],
- [' {% if part.category %}
+ '];
+ yield [' {% if part.category %}
{{ part.category }}
{% endif %}
- '],
- [' {% set a = random(1, 3) %}
+ '];
+ yield [' {% set a = random(1, 3) %}
{{ 1 + 2 | abs }}
{{ "test" | capitalize | escape | lower | raw }}
{{ "\n" | nl2br | trim | title | url_encode | reverse }}
- '],
- ['
+ '];
+ yield ['
{{ location.isRoot}} {{ location.isChildOf(location) }} {{ location.comment }} {{ location.level }}
{{ location.fullPath }} {% set arr = location.pathArray %} {% set child = location.children %} {{location.childrenNotSelectable}}
- '],
- ['
+ '];
+ yield ['
{{ part.reviewNeeded }} {{ part.tags }} {{ part.mass }}
- '],
- ['
+ '];
+ yield ['
{{ entity_type(part) is object }}
- '],
- ['
+ '];
+ yield ['
{% apply placeholders(part) %}[[NAME]]{% endapply %}
{{ placeholder("[[NAME]]", part) }}
- ']
- ];
+ '];
}
- public function twigNotAllowedDataProvider(): array
+ public function twigNotAllowedDataProvider(): \Iterator
{
- return [
- ['{% block test %} {% endblock %}'],
- ['{% deprecated test %}'],
- ['{% flush %}'],
- ["{{ part.setName('test') }}"],
- ['{{ part.setCategory(null) }}'],
- ];
+ yield ['{% block test %} {% endblock %}'];
+ yield ['{% deprecated test %}'];
+ yield ['{% flush %}'];
+ yield ["{{ part.setName('test') }}"];
+ yield ['{{ part.setCategory(null) }}'];
}
/**
diff --git a/tests/Services/Misc/FAIconGeneratorTest.php b/tests/Services/Misc/FAIconGeneratorTest.php
index 4ca318d0..1bfc740c 100644
--- a/tests/Services/Misc/FAIconGeneratorTest.php
+++ b/tests/Services/Misc/FAIconGeneratorTest.php
@@ -41,60 +41,58 @@ class FAIconGeneratorTest extends WebTestCase
$this->service = self::getContainer()->get(FAIconGenerator::class);
}
- public function fileExtensionDataProvider(): array
+ public function fileExtensionDataProvider(): \Iterator
{
- return [
- ['pdf', 'fa-file-pdf'],
- ['jpeg','fa-file-image'],
- ['txt', 'fa-file-lines'],
- ['doc', 'fa-file-word'],
- ['zip', 'fa-file-zipper'],
- ['png', 'fa-file-image'],
- ['jpg', 'fa-file-image'],
- ['gif', 'fa-file-image'],
- ['svg', 'fa-file-image'],
- ['xls', 'fa-file-excel'],
- ['xlsx', 'fa-file-excel'],
- ['ppt', 'fa-file-powerpoint'],
- ['pptx', 'fa-file-powerpoint'],
- ['docx', 'fa-file-word'],
- ['odt', 'fa-file-word'],
- ['ods', 'fa-file-excel'],
- ['odp', 'fa-file-powerpoint'],
- ['py', 'fa-file-code'],
- ['js', 'fa-file-code'],
- ['html', 'fa-file-code'],
- ['css', 'fa-file-code'],
- ['xml', 'fa-file-code'],
- ['json', 'fa-file-code'],
- ['yml', 'fa-file-code'],
- ['yaml', 'fa-file-code'],
- ['csv', 'fa-file-csv'],
- ['sql', 'fa-file-code'],
- ['sh', 'fa-file-code'],
- ['bat', 'fa-file-code'],
- ['exe', 'fa-file-code'],
- ['dll', 'fa-file-code'],
- ['lib', 'fa-file-code'],
- ['so', 'fa-file-code'],
- ['a', 'fa-file-code'],
- ['o', 'fa-file-code'],
- ['class', 'fa-file-code'],
- ['jar', 'fa-file-code'],
- ['rar', 'fa-file-zipper'],
- ['7z', 'fa-file-zipper'],
- ['tar', 'fa-file-zipper'],
- ['gz', 'fa-file-zipper'],
- ['tgz', 'fa-file-zipper'],
- ['bz2', 'fa-file-zipper'],
- ['tbz', 'fa-file-zipper'],
- ['xz', 'fa-file-zipper'],
- ['txz', 'fa-file-zipper'],
- ['zip', 'fa-file-zipper'],
- ['php', 'fa-file-code'],
- ['tmp', 'fa-file'],
- ['fgd', 'fa-file'],
- ];
+ yield ['pdf', 'fa-file-pdf'];
+ yield ['jpeg','fa-file-image'];
+ yield ['txt', 'fa-file-lines'];
+ yield ['doc', 'fa-file-word'];
+ yield ['zip', 'fa-file-zipper'];
+ yield ['png', 'fa-file-image'];
+ yield ['jpg', 'fa-file-image'];
+ yield ['gif', 'fa-file-image'];
+ yield ['svg', 'fa-file-image'];
+ yield ['xls', 'fa-file-excel'];
+ yield ['xlsx', 'fa-file-excel'];
+ yield ['ppt', 'fa-file-powerpoint'];
+ yield ['pptx', 'fa-file-powerpoint'];
+ yield ['docx', 'fa-file-word'];
+ yield ['odt', 'fa-file-word'];
+ yield ['ods', 'fa-file-excel'];
+ yield ['odp', 'fa-file-powerpoint'];
+ yield ['py', 'fa-file-code'];
+ yield ['js', 'fa-file-code'];
+ yield ['html', 'fa-file-code'];
+ yield ['css', 'fa-file-code'];
+ yield ['xml', 'fa-file-code'];
+ yield ['json', 'fa-file-code'];
+ yield ['yml', 'fa-file-code'];
+ yield ['yaml', 'fa-file-code'];
+ yield ['csv', 'fa-file-csv'];
+ yield ['sql', 'fa-file-code'];
+ yield ['sh', 'fa-file-code'];
+ yield ['bat', 'fa-file-code'];
+ yield ['exe', 'fa-file-code'];
+ yield ['dll', 'fa-file-code'];
+ yield ['lib', 'fa-file-code'];
+ yield ['so', 'fa-file-code'];
+ yield ['a', 'fa-file-code'];
+ yield ['o', 'fa-file-code'];
+ yield ['class', 'fa-file-code'];
+ yield ['jar', 'fa-file-code'];
+ yield ['rar', 'fa-file-zipper'];
+ yield ['7z', 'fa-file-zipper'];
+ yield ['tar', 'fa-file-zipper'];
+ yield ['gz', 'fa-file-zipper'];
+ yield ['tgz', 'fa-file-zipper'];
+ yield ['bz2', 'fa-file-zipper'];
+ yield ['tbz', 'fa-file-zipper'];
+ yield ['xz', 'fa-file-zipper'];
+ yield ['txz', 'fa-file-zipper'];
+ yield ['zip', 'fa-file-zipper'];
+ yield ['php', 'fa-file-code'];
+ yield ['tmp', 'fa-file'];
+ yield ['fgd', 'fa-file'];
}
/**
diff --git a/tests/Services/Misc/RangeParserTest.php b/tests/Services/Misc/RangeParserTest.php
index 27f45e98..1a9b2146 100644
--- a/tests/Services/Misc/RangeParserTest.php
+++ b/tests/Services/Misc/RangeParserTest.php
@@ -81,21 +81,19 @@ class RangeParserTest extends WebTestCase
yield [[], '1, 2, test', true];
}
- public function validDataProvider(): array
+ public function validDataProvider(): \Iterator
{
- return [
- [true, ''],
- [true, ' '],
- [true, '1, 2, 3'],
- [true, '1-2,3, 4- 5'],
- [true, '1 -2, 3- 4, 6'],
- [true, '1--2'],
- [true, '1- -2'],
- [true, ',,12,33'],
- [false, 'test'],
- [false, '1-2-3'],
- [false, '1, 2 test'],
- ];
+ yield [true, ''];
+ yield [true, ' '];
+ yield [true, '1, 2, 3'];
+ yield [true, '1-2,3, 4- 5'];
+ yield [true, '1 -2, 3- 4, 6'];
+ yield [true, '1--2'];
+ yield [true, '1- -2'];
+ yield [true, ',,12,33'];
+ yield [false, 'test'];
+ yield [false, '1-2-3'];
+ yield [false, '1, 2 test'];
}
/**
diff --git a/tests/Services/Parameters/ParameterExtractorTest.php b/tests/Services/Parameters/ParameterExtractorTest.php
index 842f8b80..148470d1 100644
--- a/tests/Services/Parameters/ParameterExtractorTest.php
+++ b/tests/Services/Parameters/ParameterExtractorTest.php
@@ -56,19 +56,17 @@ class ParameterExtractorTest extends WebTestCase
$this->service = self::getContainer()->get(ParameterExtractor::class);
}
- public function emptyDataProvider(): array
+ public function emptyDataProvider(): \Iterator
{
- return [
- [''],
- [' '],
- ["\t\n"],
- [':;'],
- ['NPN Transistor'],
- ['=BC547 rewr'],
- ['For good, [b]bad[/b], evil'],
- ['Param:; Test'],
- ['A [link](https://demo.part-db.de) should not be matched']
- ];
+ yield [''];
+ yield [' '];
+ yield ["\t\n"];
+ yield [':;'];
+ yield ['NPN Transistor'];
+ yield ['=BC547 rewr'];
+ yield ['For good, [b]bad[/b], evil'];
+ yield ['Param:; Test'];
+ yield ['A [link](https://demo.part-db.de) should not be matched'];
}
/**
diff --git a/tests/Services/Parts/PartLotWithdrawAddHelperTest.php b/tests/Services/Parts/PartLotWithdrawAddHelperTest.php
index 05a88f49..697d3983 100644
--- a/tests/Services/Parts/PartLotWithdrawAddHelperTest.php
+++ b/tests/Services/Parts/PartLotWithdrawAddHelperTest.php
@@ -119,15 +119,15 @@ class PartLotWithdrawAddHelperTest extends WebTestCase
{
//Add 5 to lot 1
$this->service->add($this->partLot1, 5, "Test");
- $this->assertSame(15.0, $this->partLot1->getAmount());
+ $this->assertEqualsWithDelta(15.0, $this->partLot1->getAmount(), PHP_FLOAT_EPSILON);
//Add 3.2 to lot 2
$this->service->add($this->partLot2, 3.2, "Test");
- $this->assertSame(5.0, $this->partLot2->getAmount());
+ $this->assertEqualsWithDelta(5.0, $this->partLot2->getAmount(), PHP_FLOAT_EPSILON);
//Add 1.5 to lot 3
$this->service->add($this->partLot3, 1.5, "Test");
- $this->assertSame(2.0, $this->partLot3->getAmount());
+ $this->assertEqualsWithDelta(2.0, $this->partLot3->getAmount(), PHP_FLOAT_EPSILON);
}
@@ -135,23 +135,23 @@ class PartLotWithdrawAddHelperTest extends WebTestCase
{
//Withdraw 5 from lot 1
$this->service->withdraw($this->partLot1, 5, "Test");
- $this->assertSame(5.0, $this->partLot1->getAmount());
+ $this->assertEqualsWithDelta(5.0, $this->partLot1->getAmount(), PHP_FLOAT_EPSILON);
//Withdraw 2.2 from lot 2
$this->service->withdraw($this->partLot2, 2.2, "Test");
- $this->assertSame(0.0, $this->partLot2->getAmount());
+ $this->assertEqualsWithDelta(0.0, $this->partLot2->getAmount(), PHP_FLOAT_EPSILON);
}
public function testMove(): void
{
//Move 5 from lot 1 to lot 2
$this->service->move($this->partLot1, $this->partLot2, 5, "Test");
- $this->assertSame(5.0, $this->partLot1->getAmount());
- $this->assertSame(7.0, $this->partLot2->getAmount());
+ $this->assertEqualsWithDelta(5.0, $this->partLot1->getAmount(), PHP_FLOAT_EPSILON);
+ $this->assertEqualsWithDelta(7.0, $this->partLot2->getAmount(), PHP_FLOAT_EPSILON);
//Move 2.2 from lot 2 to lot 3
$this->service->move($this->partLot2, $this->partLot3, 2.2, "Test");
- $this->assertSame(5.0, $this->partLot2->getAmount());
- $this->assertSame(2.0, $this->partLot3->getAmount());
+ $this->assertEqualsWithDelta(5.0, $this->partLot2->getAmount(), PHP_FLOAT_EPSILON);
+ $this->assertEqualsWithDelta(2.0, $this->partLot3->getAmount(), PHP_FLOAT_EPSILON);
}
}
diff --git a/tests/Services/UserSystem/PermissionManagerTest.php b/tests/Services/UserSystem/PermissionManagerTest.php
index 9d4aa11b..cfe74ce7 100644
--- a/tests/Services/UserSystem/PermissionManagerTest.php
+++ b/tests/Services/UserSystem/PermissionManagerTest.php
@@ -91,16 +91,14 @@ class PermissionManagerTest extends WebTestCase
$this->group->method('getParent')->willReturn($parent_group);
}
- public function getPermissionNames(): array
+ public function getPermissionNames(): \Iterator
{
//List some permission names
- return [
- ['parts'],
- ['system'],
- ['footprints'],
- ['suppliers'],
- ['tools']
- ];
+ yield ['parts'];
+ yield ['system'];
+ yield ['footprints'];
+ yield ['suppliers'];
+ yield ['tools'];
}
/**
diff --git a/tests/Services/UserSystem/TFA/BackupCodeGeneratorTest.php b/tests/Services/UserSystem/TFA/BackupCodeGeneratorTest.php
index b731ec87..b489eec2 100644
--- a/tests/Services/UserSystem/TFA/BackupCodeGeneratorTest.php
+++ b/tests/Services/UserSystem/TFA/BackupCodeGeneratorTest.php
@@ -46,9 +46,12 @@ class BackupCodeGeneratorTest extends TestCase
new BackupCodeGenerator(4, 10);
}
- public function codeLengthDataProvider(): array
+ public function codeLengthDataProvider(): \Iterator
{
- return [[6], [8], [10], [16]];
+ yield [6];
+ yield [8];
+ yield [10];
+ yield [16];
}
/**
@@ -60,9 +63,11 @@ class BackupCodeGeneratorTest extends TestCase
$this->assertMatchesRegularExpression("/^([a-f0-9]){{$code_length}}\$/", $generator->generateSingleCode());
}
- public function codeCountDataProvider(): array
+ public function codeCountDataProvider(): \Iterator
{
- return [[2], [8], [10]];
+ yield [2];
+ yield [8];
+ yield [10];
}
/**
diff --git a/tests/Services/UserSystem/VoterHelperTest.php b/tests/Services/UserSystem/VoterHelperTest.php
index 28bb9ba8..53d7ee82 100644
--- a/tests/Services/UserSystem/VoterHelperTest.php
+++ b/tests/Services/UserSystem/VoterHelperTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Services\UserSystem;
use App\Entity\UserSystem\ApiToken;
diff --git a/tests/Validator/Constraints/NoneOfItsChildrenValidatorTest.php b/tests/Validator/Constraints/NoneOfItsChildrenValidatorTest.php
index 973e6cfa..0efcd5de 100644
--- a/tests/Validator/Constraints/NoneOfItsChildrenValidatorTest.php
+++ b/tests/Validator/Constraints/NoneOfItsChildrenValidatorTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Validator\Constraints;
use App\Entity\Attachments\AttachmentType;
diff --git a/tests/Validator/Constraints/SelectableValidatorTest.php b/tests/Validator/Constraints/SelectableValidatorTest.php
index bb6f7bcc..bc520621 100644
--- a/tests/Validator/Constraints/SelectableValidatorTest.php
+++ b/tests/Validator/Constraints/SelectableValidatorTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Validator\Constraints;
use App\Entity\Attachments\AttachmentType;
diff --git a/tests/Validator/Constraints/UniqueObjectCollectionValidatorTest.php b/tests/Validator/Constraints/UniqueObjectCollectionValidatorTest.php
index bddd3d49..d9fab6cf 100644
--- a/tests/Validator/Constraints/UniqueObjectCollectionValidatorTest.php
+++ b/tests/Validator/Constraints/UniqueObjectCollectionValidatorTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Validator\Constraints;
use App\Tests\Validator\DummyUniqueValidatableObject;
diff --git a/tests/Validator/Constraints/UrlOrBuiltinValidatorTest.php b/tests/Validator/Constraints/UrlOrBuiltinValidatorTest.php
index de7e47d5..c75754df 100644
--- a/tests/Validator/Constraints/UrlOrBuiltinValidatorTest.php
+++ b/tests/Validator/Constraints/UrlOrBuiltinValidatorTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Validator\Constraints;
use App\Validator\Constraints\UrlOrBuiltin;
diff --git a/tests/Validator/Constraints/ValidGoogleAuthCodeValidatorTest.php b/tests/Validator/Constraints/ValidGoogleAuthCodeValidatorTest.php
index 5ba98a47..a1bc1a74 100644
--- a/tests/Validator/Constraints/ValidGoogleAuthCodeValidatorTest.php
+++ b/tests/Validator/Constraints/ValidGoogleAuthCodeValidatorTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Validator\Constraints;
use App\Entity\UserSystem\User;
@@ -61,7 +63,7 @@ class ValidGoogleAuthCodeValidatorTest extends ConstraintValidatorTestCase
{
//Leave empty
}
- public function getUser(): ?\Symfony\Component\Security\Core\User\UserInterface
+ public function getUser(): ?UserInterface
{
return new class implements TwoFactorInterface, UserInterface {
diff --git a/tests/Validator/Constraints/ValidThemeValidatorTest.php b/tests/Validator/Constraints/ValidThemeValidatorTest.php
index 8ad95e7a..9db8f33b 100644
--- a/tests/Validator/Constraints/ValidThemeValidatorTest.php
+++ b/tests/Validator/Constraints/ValidThemeValidatorTest.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Validator\Constraints;
use App\Validator\Constraints\ValidTheme;
diff --git a/tests/Validator/DummyUniqueValidatableObject.php b/tests/Validator/DummyUniqueValidatableObject.php
index 7ca2565d..a7dd9d7a 100644
--- a/tests/Validator/DummyUniqueValidatableObject.php
+++ b/tests/Validator/DummyUniqueValidatableObject.php
@@ -1,4 +1,7 @@
.
*/
-
namespace App\Tests\Validator;
use App\Validator\UniqueValidatableInterface;
@@ -38,4 +40,4 @@ class DummyUniqueValidatableObject implements UniqueValidatableInterface, \Strin
{
return 'objectString';
}
-}
\ No newline at end of file
+}