From 1bfea3c48aa48414e380cf69e793ee98d941d124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 21 Sep 2025 23:27:56 +0200 Subject: [PATCH] Fixed phpstan issues --- src/Controller/PartController.php | 3 ++- src/EventListener/LogSystem/EventLoggerListener.php | 3 +++ src/Form/InfoProviderSystem/ProviderSelectType.php | 2 ++ src/Services/Attachments/AttachmentSubmitHandler.php | 4 ++++ .../LabelSystem/Barcodes/BarcodeContentGenerator.php | 5 +++++ src/Twig/Sandbox/InheritanceSecurityPolicy.php | 7 ++++++- 6 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Controller/PartController.php b/src/Controller/PartController.php index 1a7cea4d..aeb2664e 100644 --- a/src/Controller/PartController.php +++ b/src/Controller/PartController.php @@ -72,7 +72,8 @@ final class PartController extends AbstractController private readonly TranslatorInterface $translator, private readonly AttachmentSubmitHandler $attachmentSubmitHandler, private readonly EntityManagerInterface $em, - private readonly EventCommentHelper $commentHelper + private readonly EventCommentHelper $commentHelper, + private readonly PartInfoSettings $partInfoSettings, ) { } diff --git a/src/EventListener/LogSystem/EventLoggerListener.php b/src/EventListener/LogSystem/EventLoggerListener.php index 96c6ef51..f5029c28 100644 --- a/src/EventListener/LogSystem/EventLoggerListener.php +++ b/src/EventListener/LogSystem/EventLoggerListener.php @@ -170,6 +170,7 @@ class EventLoggerListener public function hasFieldRestrictions(AbstractDBElement $element): bool { foreach (array_keys(static::FIELD_BLACKLIST) as $class) { + /** @var string $class */ if ($element instanceof $class) { return true; } @@ -184,6 +185,7 @@ class EventLoggerListener public function shouldFieldBeSaved(AbstractDBElement $element, string $field_name): bool { foreach (static::FIELD_BLACKLIST as $class => $blacklist) { + /** @var string $class */ if ($element instanceof $class && in_array($field_name, $blacklist, true)) { return false; } @@ -215,6 +217,7 @@ class EventLoggerListener $mappings = $metadata->getAssociationMappings(); //Check if class is whitelisted for CollectionElementDeleted entry foreach (static::TRIGGER_ASSOCIATION_LOG_WHITELIST as $class => $whitelist) { + /** @var string $class */ if ($entity instanceof $class) { //Check names foreach ($mappings as $field => $mapping) { diff --git a/src/Form/InfoProviderSystem/ProviderSelectType.php b/src/Form/InfoProviderSystem/ProviderSelectType.php index c0921f48..95e10791 100644 --- a/src/Form/InfoProviderSystem/ProviderSelectType.php +++ b/src/Form/InfoProviderSystem/ProviderSelectType.php @@ -24,7 +24,9 @@ declare(strict_types=1); namespace App\Form\InfoProviderSystem; use App\Services\InfoProviderSystem\ProviderRegistry; +use App\Services\InfoProviderSystem\Providers\InfoProviderInterface; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\ChoiceList\ChoiceList; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; diff --git a/src/Services/Attachments/AttachmentSubmitHandler.php b/src/Services/Attachments/AttachmentSubmitHandler.php index a30163ae..9fbc3fe3 100644 --- a/src/Services/Attachments/AttachmentSubmitHandler.php +++ b/src/Services/Attachments/AttachmentSubmitHandler.php @@ -57,6 +57,9 @@ use Symfony\Contracts\HttpClient\HttpClientInterface; */ class AttachmentSubmitHandler { + /** + * @var array The mapping used to determine which folder will be used for an attachment type + */ protected array $folder_mapping; private ?int $max_upload_size_bytes = null; @@ -160,6 +163,7 @@ class AttachmentSubmitHandler } else { //If not, check for instance of: foreach ($this->folder_mapping as $class => $folder) { + /** @var string $class */ if ($attachment instanceof $class) { $prefix = $folder; break; diff --git a/src/Services/LabelSystem/Barcodes/BarcodeContentGenerator.php b/src/Services/LabelSystem/Barcodes/BarcodeContentGenerator.php index 7ceb30dd..3df7d227 100644 --- a/src/Services/LabelSystem/Barcodes/BarcodeContentGenerator.php +++ b/src/Services/LabelSystem/Barcodes/BarcodeContentGenerator.php @@ -95,6 +95,11 @@ final class BarcodeContentGenerator return $prefix.$id; } + /** + * @param array $map + * @param object $target + * @return string + */ private function classToString(array $map, object $target): string { $class = $target::class; diff --git a/src/Twig/Sandbox/InheritanceSecurityPolicy.php b/src/Twig/Sandbox/InheritanceSecurityPolicy.php index 93e874e9..06ab3a1f 100644 --- a/src/Twig/Sandbox/InheritanceSecurityPolicy.php +++ b/src/Twig/Sandbox/InheritanceSecurityPolicy.php @@ -34,9 +34,14 @@ use function is_array; */ final class InheritanceSecurityPolicy implements SecurityPolicyInterface { + /** + * @var array + */ private array $allowedMethods; - public function __construct(private array $allowedTags = [], private array $allowedFilters = [], array $allowedMethods = [], private array $allowedProperties = [], private array $allowedFunctions = []) + public function __construct(private array $allowedTags = [], private array $allowedFilters = [], array $allowedMethods = [], + /** @var array */ + private array $allowedProperties = [], private array $allowedFunctions = []) { $this->setAllowedMethods($allowedMethods); }