From 9b90a513c92428bbcaf7870862562b1d72a082c5 Mon Sep 17 00:00:00 2001 From: Marcel Diegelmann Date: Fri, 26 Sep 2025 15:08:42 +0200 Subject: [PATCH] Anpassungen aus phpstan Analyse --- src/Controller/TypeaheadController.php | 1 + src/Repository/PartRepository.php | 8 ++++---- src/Validator/Constraints/UniquePartIpnValidator.php | 5 +++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Controller/TypeaheadController.php b/src/Controller/TypeaheadController.php index 8262506d..fe4f029f 100644 --- a/src/Controller/TypeaheadController.php +++ b/src/Controller/TypeaheadController.php @@ -202,6 +202,7 @@ class TypeaheadController extends AbstractController /** @var Part $part */ $part = $partId !== null ? $entityManager->getRepository(Part::class)->find($partId) : new Part(); + /** @var Category|null $category */ $category = $entityManager->getRepository(Category::class)->find($categoryId); $clonedPart = clone $part; diff --git a/src/Repository/PartRepository.php b/src/Repository/PartRepository.php index c6588731..23318635 100644 --- a/src/Repository/PartRepository.php +++ b/src/Repository/PartRepository.php @@ -128,7 +128,7 @@ class PartRepository extends NamedDBElementRepository { $category = $part->getCategory(); $ipnSuggestions = ['commonPrefixes' => [], 'prefixesPartIncrement' => []]; - $description = base64_decode($description); + $description = base64_decode($description, true); if (strlen($description) > 150) { $description = substr($description, 0, 150); @@ -251,12 +251,12 @@ class PartRepository extends NamedDBElementRepository * @param Part $currentPart The part entity for which the increment is being generated. * @param int $suggestPartDigits The number of digits reserved for the increment. * - * @return string|null The next possible increment as a zero-padded string, or null if it cannot be generated. + * @return string The next possible increment as a zero-padded string. * * @throws NonUniqueResultException If the query returns non-unique results. * @throws NoResultException If the query fails to return a result. */ - private function generateNextPossiblePartIncrement(string $currentPath, Part $currentPart, int $suggestPartDigits): ?string + private function generateNextPossiblePartIncrement(string $currentPath, Part $currentPart, int $suggestPartDigits): string { $qb = $this->createQueryBuilder('part'); @@ -298,7 +298,7 @@ class PartRepository extends NamedDBElementRepository // Generate the next free $autocompletePartDigits-digit increment $nextIncrement = 1; // Start at the beginning - while (in_array($nextIncrement, $usedIncrements)) { + while (in_array($nextIncrement, $usedIncrements, true)) { $nextIncrement++; } diff --git a/src/Validator/Constraints/UniquePartIpnValidator.php b/src/Validator/Constraints/UniquePartIpnValidator.php index 641ffe47..edee1190 100644 --- a/src/Validator/Constraints/UniquePartIpnValidator.php +++ b/src/Validator/Constraints/UniquePartIpnValidator.php @@ -29,6 +29,11 @@ class UniquePartIpnValidator extends ConstraintValidator return; } + // Stelle sicher, dass es unser eigenes Constraint ist (wichtig für PHPStan) + if (!$constraint instanceof UniquePartIpnConstraint) { + return; + } + /** @var Part $currentPart */ $currentPart = $this->context->getObject();