Fixed phpstan issues

This commit is contained in:
Jan Böhmer 2025-09-21 23:27:56 +02:00
parent 07db1554c7
commit 1bfea3c48a
6 changed files with 22 additions and 2 deletions

View file

@ -72,7 +72,8 @@ final class PartController extends AbstractController
private readonly TranslatorInterface $translator, private readonly TranslatorInterface $translator,
private readonly AttachmentSubmitHandler $attachmentSubmitHandler, private readonly AttachmentSubmitHandler $attachmentSubmitHandler,
private readonly EntityManagerInterface $em, private readonly EntityManagerInterface $em,
private readonly EventCommentHelper $commentHelper private readonly EventCommentHelper $commentHelper,
private readonly PartInfoSettings $partInfoSettings,
) { ) {
} }

View file

@ -170,6 +170,7 @@ class EventLoggerListener
public function hasFieldRestrictions(AbstractDBElement $element): bool public function hasFieldRestrictions(AbstractDBElement $element): bool
{ {
foreach (array_keys(static::FIELD_BLACKLIST) as $class) { foreach (array_keys(static::FIELD_BLACKLIST) as $class) {
/** @var string $class */
if ($element instanceof $class) { if ($element instanceof $class) {
return true; return true;
} }
@ -184,6 +185,7 @@ class EventLoggerListener
public function shouldFieldBeSaved(AbstractDBElement $element, string $field_name): bool public function shouldFieldBeSaved(AbstractDBElement $element, string $field_name): bool
{ {
foreach (static::FIELD_BLACKLIST as $class => $blacklist) { foreach (static::FIELD_BLACKLIST as $class => $blacklist) {
/** @var string $class */
if ($element instanceof $class && in_array($field_name, $blacklist, true)) { if ($element instanceof $class && in_array($field_name, $blacklist, true)) {
return false; return false;
} }
@ -215,6 +217,7 @@ class EventLoggerListener
$mappings = $metadata->getAssociationMappings(); $mappings = $metadata->getAssociationMappings();
//Check if class is whitelisted for CollectionElementDeleted entry //Check if class is whitelisted for CollectionElementDeleted entry
foreach (static::TRIGGER_ASSOCIATION_LOG_WHITELIST as $class => $whitelist) { foreach (static::TRIGGER_ASSOCIATION_LOG_WHITELIST as $class => $whitelist) {
/** @var string $class */
if ($entity instanceof $class) { if ($entity instanceof $class) {
//Check names //Check names
foreach ($mappings as $field => $mapping) { foreach ($mappings as $field => $mapping) {

View file

@ -24,7 +24,9 @@ declare(strict_types=1);
namespace App\Form\InfoProviderSystem; namespace App\Form\InfoProviderSystem;
use App\Services\InfoProviderSystem\ProviderRegistry; use App\Services\InfoProviderSystem\ProviderRegistry;
use App\Services\InfoProviderSystem\Providers\InfoProviderInterface;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\ChoiceList\ChoiceList;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;

View file

@ -57,6 +57,9 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
*/ */
class AttachmentSubmitHandler class AttachmentSubmitHandler
{ {
/**
* @var array<string, string> The mapping used to determine which folder will be used for an attachment type
*/
protected array $folder_mapping; protected array $folder_mapping;
private ?int $max_upload_size_bytes = null; private ?int $max_upload_size_bytes = null;
@ -160,6 +163,7 @@ class AttachmentSubmitHandler
} else { } else {
//If not, check for instance of: //If not, check for instance of:
foreach ($this->folder_mapping as $class => $folder) { foreach ($this->folder_mapping as $class => $folder) {
/** @var string $class */
if ($attachment instanceof $class) { if ($attachment instanceof $class) {
$prefix = $folder; $prefix = $folder;
break; break;

View file

@ -95,6 +95,11 @@ final class BarcodeContentGenerator
return $prefix.$id; return $prefix.$id;
} }
/**
* @param array<string, string> $map
* @param object $target
* @return string
*/
private function classToString(array $map, object $target): string private function classToString(array $map, object $target): string
{ {
$class = $target::class; $class = $target::class;

View file

@ -34,9 +34,14 @@ use function is_array;
*/ */
final class InheritanceSecurityPolicy implements SecurityPolicyInterface final class InheritanceSecurityPolicy implements SecurityPolicyInterface
{ {
/**
* @var array<string, string[]>
*/
private array $allowedMethods; 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<string, string|string[]> */
private array $allowedProperties = [], private array $allowedFunctions = [])
{ {
$this->setAllowedMethods($allowedMethods); $this->setAllowedMethods($allowedMethods);
} }