From ba5ae358097d39f8331ca8628bdb9d848cb27ee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 5 Feb 2023 03:01:25 +0100 Subject: [PATCH] Fixed some inspection issues --- src/Command/BackupCommand.php | 2 +- src/DataTables/Column/LocaleDateTimeColumn.php | 2 +- src/DataTables/ProjectBomEntriesDataTable.php | 3 ++- src/Doctrine/Purger/ResetAutoIncrementORMPurger.php | 4 +++- src/Entity/Attachments/CurrencyAttachment.php | 2 +- src/Entity/Base/AbstractStructuralDBElement.php | 2 +- src/Entity/LabelSystem/LabelOptions.php | 2 +- src/Entity/PriceInformations/Currency.php | 6 +++--- src/Entity/PriceInformations/Orderdetail.php | 10 +++++----- src/Entity/PriceInformations/Pricedetail.php | 2 +- src/Entity/ProjectSystem/Project.php | 2 +- src/Entity/ProjectSystem/ProjectBOMEntry.php | 4 ++-- .../Filters/Constraints/DateTimeConstraintType.php | 2 +- src/Form/Type/RichTextEditorType.php | 2 +- src/Form/Type/StructuralEntityType.php | 7 +------ src/Form/Type/TriStateCheckboxType.php | 2 +- src/Repository/LogEntryRepository.php | 2 +- src/Repository/UserRepository.php | 4 ++-- .../PlaceholderProviders/GlobalProviders.php | 2 +- src/Services/LogSystem/TimeTravel.php | 9 +++++---- 20 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/Command/BackupCommand.php b/src/Command/BackupCommand.php index 10ea68cb..7ee535c6 100644 --- a/src/Command/BackupCommand.php +++ b/src/Command/BackupCommand.php @@ -117,7 +117,7 @@ class BackupCommand extends Command * Constructs the MySQL PDO DSN. * Taken from https://github.com/doctrine/dbal/blob/3.5.x/src/Driver/PDO/MySQL/Driver.php * - * @param mixed[] $params + * @param array $params */ private function configureDumper(array $params, DbDumper $dumper): void { diff --git a/src/DataTables/Column/LocaleDateTimeColumn.php b/src/DataTables/Column/LocaleDateTimeColumn.php index 07fa3f8d..3904a4cd 100644 --- a/src/DataTables/Column/LocaleDateTimeColumn.php +++ b/src/DataTables/Column/LocaleDateTimeColumn.php @@ -74,7 +74,7 @@ class LocaleDateTimeColumn extends AbstractColumn return sprintf('%s', $long_formatter->format($value->getTimestamp()), //Long form - $formatter->format($value->getTimestamp()), //Short form + $formatter->format($value->getTimestamp()) //Short form ); } diff --git a/src/DataTables/ProjectBomEntriesDataTable.php b/src/DataTables/ProjectBomEntriesDataTable.php index 7fabff8b..8d7c839d 100644 --- a/src/DataTables/ProjectBomEntriesDataTable.php +++ b/src/DataTables/ProjectBomEntriesDataTable.php @@ -102,6 +102,7 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface } return $tmp; } + throw new \Exception('This should never happen!'); }, ]) @@ -175,7 +176,7 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface ->from(ProjectBOMEntry::class, 'bom_entry') ->leftJoin('bom_entry.part', 'part') ->where('bom_entry.project = :project') - ->setParameter('project', $options['project']); + ->setParameter('project', $options['project']) ; } diff --git a/src/Doctrine/Purger/ResetAutoIncrementORMPurger.php b/src/Doctrine/Purger/ResetAutoIncrementORMPurger.php index a0de16e6..a38045d4 100644 --- a/src/Doctrine/Purger/ResetAutoIncrementORMPurger.php +++ b/src/Doctrine/Purger/ResetAutoIncrementORMPurger.php @@ -32,6 +32,8 @@ use Doctrine\DBAL\Schema\Identifier; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\ClassMetadataInfo; + use function array_reverse; use function array_search; use function assert; @@ -282,7 +284,7 @@ class ResetAutoIncrementORMPurger implements PurgerInterface, ORMPurgerInterface foreach ($classes as $class) { foreach ($class->associationMappings as $assoc) { - if (! $assoc['isOwningSide'] || $assoc['type'] !== ClassMetadata::MANY_TO_MANY) { + if (! $assoc['isOwningSide'] || $assoc['type'] !== ClassMetadataInfo::MANY_TO_MANY) { continue; } diff --git a/src/Entity/Attachments/CurrencyAttachment.php b/src/Entity/Attachments/CurrencyAttachment.php index a45efd03..73ad1145 100644 --- a/src/Entity/Attachments/CurrencyAttachment.php +++ b/src/Entity/Attachments/CurrencyAttachment.php @@ -27,7 +27,7 @@ use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** - * A attachment attached to a currency element. + * An attachment attached to a currency element. * * @ORM\Entity() * @UniqueEntity({"name", "attachment_type", "element"}) diff --git a/src/Entity/Base/AbstractStructuralDBElement.php b/src/Entity/Base/AbstractStructuralDBElement.php index 4384173f..cbe2c7be 100644 --- a/src/Entity/Base/AbstractStructuralDBElement.php +++ b/src/Entity/Base/AbstractStructuralDBElement.php @@ -149,7 +149,7 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement } //If the parent element is equal to the element we want to compare, return true - if ($this->getParent()->getID() === null || $this->getParent()->getID() === null) { + if ($this->getParent()->getID() === null) { //If the IDs are not yet defined, we have to compare the objects itself if ($this->getParent() === $another_element) { return true; diff --git a/src/Entity/LabelSystem/LabelOptions.php b/src/Entity/LabelSystem/LabelOptions.php index 75b815c4..f3f448ad 100644 --- a/src/Entity/LabelSystem/LabelOptions.php +++ b/src/Entity/LabelSystem/LabelOptions.php @@ -199,7 +199,7 @@ class LabelOptions } /** - * Gets additional CSS (it will simply be attached. + * Gets additional CSS (it will simply be attended to base CSS). */ public function getAdditionalCss(): string { diff --git a/src/Entity/PriceInformations/Currency.php b/src/Entity/PriceInformations/Currency.php index 41a9964c..e5d0439d 100644 --- a/src/Entity/PriceInformations/Currency.php +++ b/src/Entity/PriceInformations/Currency.php @@ -35,7 +35,7 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Validator\Constraints as Assert; /** - * This entity describes a currency that can be used for price informations. + * This entity describes a currency that can be used for price information. * * @UniqueEntity("iso_code") * @ORM\Entity() @@ -57,7 +57,7 @@ class Currency extends AbstractStructuralDBElement protected ?BigDecimal $exchange_rate = null; /** - * @var string the 3 letter ISO code of the currency + * @var string the 3-letter ISO code of the currency * @ORM\Column(type="string") * @Assert\Currency() */ @@ -107,7 +107,7 @@ class Currency extends AbstractStructuralDBElement } /** - * Returns the 3 letter ISO code of this currency. + * Returns the 3-letter ISO code of this currency. * * @return string */ diff --git a/src/Entity/PriceInformations/Orderdetail.php b/src/Entity/PriceInformations/Orderdetail.php index 96ef6443..e2f0187f 100644 --- a/src/Entity/PriceInformations/Orderdetail.php +++ b/src/Entity/PriceInformations/Orderdetail.php @@ -180,10 +180,10 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N } /** - * Get the link to the website of the article on the suppliers website. + * Get the link to the website of the article on the supplier's website. * * @param bool $no_automatic_url Set this to true, if you only want to get the local set product URL for this Orderdetail - * and not a automatic generated one, based from the Supplier + * and not an automatic generated one, based from the Supplier * * @return string the link to the article */ @@ -212,7 +212,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N } /** - * Adds an pricedetail to this orderdetail. + * Adds a price detail to this orderdetail. * * @param Pricedetail $pricedetail The pricedetail to add * @@ -227,7 +227,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N } /** - * Removes an pricedetail from this orderdetail. + * Removes a price detail from this orderdetail. * * @return Orderdetail */ @@ -244,7 +244,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N * * @param float $quantity this is the quantity to choose the correct pricedetails * - * @return Pricedetail|null: the price as a bcmath string. Null if there are no orderdetails for the given quantity + * @return Pricedetail|null the price as a bcmath string. Null if there are no orderdetails for the given quantity */ public function findPriceForQty(float $quantity = 1.0): ?Pricedetail { diff --git a/src/Entity/PriceInformations/Pricedetail.php b/src/Entity/PriceInformations/Pricedetail.php index 8c119ee8..0229baf5 100644 --- a/src/Entity/PriceInformations/Pricedetail.php +++ b/src/Entity/PriceInformations/Pricedetail.php @@ -244,7 +244,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface } /** - * Sets the currency associated with the price informations. + * Sets the currency associated with the price information. * Set to null, to use the global base currency. * * @return Pricedetail diff --git a/src/Entity/ProjectSystem/Project.php b/src/Entity/ProjectSystem/Project.php index a319264d..4c71b507 100644 --- a/src/Entity/ProjectSystem/Project.php +++ b/src/Entity/ProjectSystem/Project.php @@ -252,7 +252,7 @@ class Project extends AbstractStructuralDBElement } /** - * Checks if this project has a associated part representing the builds of this project in the stock. + * Checks if this project has an associated part representing the builds of this project in the stock. * @return bool */ public function hasBuildPart(): bool diff --git a/src/Entity/ProjectSystem/ProjectBOMEntry.php b/src/Entity/ProjectSystem/ProjectBOMEntry.php index 9d8be815..e7ef436f 100644 --- a/src/Entity/ProjectSystem/ProjectBOMEntry.php +++ b/src/Entity/ProjectSystem/ProjectBOMEntry.php @@ -35,7 +35,7 @@ use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Context\ExecutionContextInterface; /** - * The ProjectBOMEntry class represents a entry in a project's BOM. + * The ProjectBOMEntry class represents an entry in a project's BOM. * * @ORM\Table("project_bom_entries") * @ORM\HasLifecycleCallbacks() @@ -303,7 +303,7 @@ class ProjectBOMEntry extends AbstractDBElement ->addViolation(); } - //Prices are only only allowed on non-part BOM entries + //Prices are only allowed on non-part BOM entries if ($this->part !== null && $this->price !== null) { $context->buildViolation('project.bom_entry.price_not_allowed_on_parts') ->atPath('price') diff --git a/src/Form/Filters/Constraints/DateTimeConstraintType.php b/src/Form/Filters/Constraints/DateTimeConstraintType.php index 6fc46654..f476f0ed 100644 --- a/src/Form/Filters/Constraints/DateTimeConstraintType.php +++ b/src/Form/Filters/Constraints/DateTimeConstraintType.php @@ -38,7 +38,7 @@ class DateTimeConstraintType extends AbstractType $resolver->setDefaults([ 'compound' => true, 'data_class' => DateTimeConstraint::class, - 'text_suffix' => '', // An suffix which is attached as text-append to the input group. This can for example be used for units + 'text_suffix' => '', // A suffix which is attached as text-append to the input group. This can for example be used for units 'value1_options' => [], // Options for the first value input 'value2_options' => [], // Options for the second value input diff --git a/src/Form/Type/RichTextEditorType.php b/src/Form/Type/RichTextEditorType.php index 10ae78f6..a572fa2e 100644 --- a/src/Form/Type/RichTextEditorType.php +++ b/src/Form/Type/RichTextEditorType.php @@ -55,7 +55,7 @@ class RichTextEditorType extends AbstractType { $tmp = []; - //Set novalidate attribute or we will get problems that form can not be submitted as textarea is not focusable + //Set novalidate attribute, or we will get problems that form can not be submitted as textarea is not focusable $tmp['novalidate'] = 'novalidate'; $tmp['data-mode'] = $options['mode']; diff --git a/src/Form/Type/StructuralEntityType.php b/src/Form/Type/StructuralEntityType.php index 42f3686b..011efe5a 100644 --- a/src/Form/Type/StructuralEntityType.php +++ b/src/Form/Type/StructuralEntityType.php @@ -109,12 +109,7 @@ class StructuralEntityType extends AbstractType return null; } - if ($element->getID() === null) { - //Must be the same as the separator in the choice_loader, otherwise this will not work! - return $element->getFullPath('->'); - } - - return $element->getID(); + return (string) $element->getID() ?? $element->getFullPath('->'); }, //Use the element id as option value and for comparing items 'choice_loader' => function (Options $options) { return new StructuralEntityChoiceLoader($options, $this->builder, $this->em); diff --git a/src/Form/Type/TriStateCheckboxType.php b/src/Form/Type/TriStateCheckboxType.php index 341b3fc8..6e8dafc4 100644 --- a/src/Form/Type/TriStateCheckboxType.php +++ b/src/Form/Type/TriStateCheckboxType.php @@ -70,7 +70,7 @@ final class TriStateCheckboxType extends AbstractType implements DataTransformer * * 1. Model transformers which normalize the model data. * This is mainly useful when the same form type (the same configuration) - * has to handle different kind of underlying data, e.g The DateType can + * has to handle different kind of underlying data, e.g. The DateType can * deal with strings or \DateTime objects as input. * * 2. View transformers which adapt the normalized data to the view format. diff --git a/src/Repository/LogEntryRepository.php b/src/Repository/LogEntryRepository.php index d8bfe24a..857aac5b 100644 --- a/src/Repository/LogEntryRepository.php +++ b/src/Repository/LogEntryRepository.php @@ -52,7 +52,7 @@ class LogEntryRepository extends DBElementRepository * Find log entries associated with the given element (the history of the element). * * @param AbstractDBElement $element The element for which the history should be generated - * @param string $order By default newest entries are shown first. Change this to ASC to show oldest entries first. + * @param string $order By default, the newest entries are shown first. Change this to ASC to show the oldest entries first. * @param null $limit * @param null $offset * diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php index 2d82fb58..2d4fea12 100644 --- a/src/Repository/UserRepository.php +++ b/src/Repository/UserRepository.php @@ -82,10 +82,10 @@ final class UserRepository extends NamedDBElementRepository implements PasswordU } } - public function upgradePassword(UserInterface $user, string $newEncodedPassword): void + public function upgradePassword(UserInterface $user, string $newHashedPassword): void { if ($user instanceof User) { - $user->setPassword($newEncodedPassword); + $user->setPassword($newHashedPassword); $this->getEntityManager()->flush(); } } diff --git a/src/Services/LabelSystem/PlaceholderProviders/GlobalProviders.php b/src/Services/LabelSystem/PlaceholderProviders/GlobalProviders.php index 4ff58f79..1dd7188a 100644 --- a/src/Services/LabelSystem/PlaceholderProviders/GlobalProviders.php +++ b/src/Services/LabelSystem/PlaceholderProviders/GlobalProviders.php @@ -124,7 +124,7 @@ final class GlobalProviders implements PlaceholderProviderInterface } if ('[[INSTANCE_URL]]' === $placeholder) { - return $this->url_generator->generate('homepage', [], UrlGenerator::ABSOLUTE_URL); + return $this->url_generator->generate('homepage', [], UrlGeneratorInterface::ABSOLUTE_URL); } return null; diff --git a/src/Services/LogSystem/TimeTravel.php b/src/Services/LogSystem/TimeTravel.php index 01cfaa6a..9933d235 100644 --- a/src/Services/LogSystem/TimeTravel.php +++ b/src/Services/LogSystem/TimeTravel.php @@ -36,6 +36,7 @@ use DateTime; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\MappingException; use DoctrineExtensions\Query\Mysql\Date; use Exception; @@ -139,16 +140,16 @@ class TimeTravel //Revert many to one association (one element in property) if ( - ClassMetadata::MANY_TO_ONE === $mapping['type'] - || ClassMetadata::ONE_TO_ONE === $mapping['type'] + ClassMetadataInfo::MANY_TO_ONE === $mapping['type'] + || ClassMetadataInfo::ONE_TO_ONE === $mapping['type'] ) { $target_element = $this->getField($element, $field); if (null !== $target_element && $element->getLastModified() > $timestamp) { $this->revertEntityToTimestamp($target_element, $timestamp, $reverted_elements); } } elseif ( //Revert *_TO_MANY associations (collection properties) - (ClassMetadata::MANY_TO_MANY === $mapping['type'] - || ClassMetadata::ONE_TO_MANY === $mapping['type']) + (ClassMetadataInfo::MANY_TO_MANY === $mapping['type'] + || ClassMetadataInfo::ONE_TO_MANY === $mapping['type']) && false === $mapping['isOwningSide'] ) { $target_elements = $this->getField($element, $field);