Anpassungen aus phpstan Analyse

This commit is contained in:
Marcel Diegelmann 2025-09-26 15:08:42 +02:00
parent a2f53290f4
commit 9b90a513c9
3 changed files with 10 additions and 4 deletions

View file

@ -202,6 +202,7 @@ class TypeaheadController extends AbstractController
/** @var Part $part */ /** @var Part $part */
$part = $partId !== null ? $entityManager->getRepository(Part::class)->find($partId) : new Part(); $part = $partId !== null ? $entityManager->getRepository(Part::class)->find($partId) : new Part();
/** @var Category|null $category */
$category = $entityManager->getRepository(Category::class)->find($categoryId); $category = $entityManager->getRepository(Category::class)->find($categoryId);
$clonedPart = clone $part; $clonedPart = clone $part;

View file

@ -128,7 +128,7 @@ class PartRepository extends NamedDBElementRepository
{ {
$category = $part->getCategory(); $category = $part->getCategory();
$ipnSuggestions = ['commonPrefixes' => [], 'prefixesPartIncrement' => []]; $ipnSuggestions = ['commonPrefixes' => [], 'prefixesPartIncrement' => []];
$description = base64_decode($description); $description = base64_decode($description, true);
if (strlen($description) > 150) { if (strlen($description) > 150) {
$description = substr($description, 0, 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 Part $currentPart The part entity for which the increment is being generated.
* @param int $suggestPartDigits The number of digits reserved for the increment. * @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 NonUniqueResultException If the query returns non-unique results.
* @throws NoResultException If the query fails to return a result. * @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'); $qb = $this->createQueryBuilder('part');
@ -298,7 +298,7 @@ class PartRepository extends NamedDBElementRepository
// Generate the next free $autocompletePartDigits-digit increment // Generate the next free $autocompletePartDigits-digit increment
$nextIncrement = 1; // Start at the beginning $nextIncrement = 1; // Start at the beginning
while (in_array($nextIncrement, $usedIncrements)) { while (in_array($nextIncrement, $usedIncrements, true)) {
$nextIncrement++; $nextIncrement++;
} }

View file

@ -29,6 +29,11 @@ class UniquePartIpnValidator extends ConstraintValidator
return; return;
} }
// Stelle sicher, dass es unser eigenes Constraint ist (wichtig für PHPStan)
if (!$constraint instanceof UniquePartIpnConstraint) {
return;
}
/** @var Part $currentPart */ /** @var Part $currentPart */
$currentPart = $this->context->getObject(); $currentPart = $this->context->getObject();