diff --git a/config/services.yaml b/config/services.yaml index 2b97c116..f5fa21a8 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -33,6 +33,8 @@ services: bind: bool $demo_mode: '%demo_mode%' bool $gpdr_compliance : '%gpdr_compliance%' + bool $kernel_debug: '%kernel.debug%' + string $kernel_cache_dir: '%kernel.cache_dir%' # makes classes in src/ available to be used as services # this creates a service per class whose id is the fully-qualified class name diff --git a/src/Entity/Base/AbstractStructuralDBElement.php b/src/Entity/Base/AbstractStructuralDBElement.php index 3bb3da16..4ef2ab6d 100644 --- a/src/Entity/Base/AbstractStructuralDBElement.php +++ b/src/Entity/Base/AbstractStructuralDBElement.php @@ -254,6 +254,7 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement * Get all sub elements of this element. * * @return Collection|iterable all subelements as an array of objects (sorted by their full path) + * @psalm-return Collection */ public function getSubelements(): iterable { @@ -262,6 +263,7 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement /** * @return Collection|iterable + * @psalm-return Collection */ public function getChildren(): iterable { diff --git a/src/Entity/Parameters/ParametersTrait.php b/src/Entity/Parameters/ParametersTrait.php index 5ff81c12..1d088afd 100644 --- a/src/Entity/Parameters/ParametersTrait.php +++ b/src/Entity/Parameters/ParametersTrait.php @@ -31,7 +31,7 @@ trait ParametersTrait /** * Mapping done in subclasses. * - * @var Collection + * @var Collection * @Assert\Valid() */ protected $parameters; @@ -39,9 +39,9 @@ trait ParametersTrait /** * Return all associated specifications. * - * @return \Doctrine\Common\Collections\Collection + * @return Collection * - * @psalm-return \Doctrine\Common\Collections\Collection + * @psalm-return Collection */ public function getParameters(): \Doctrine\Common\Collections\Collection { diff --git a/src/EventSubscriber/SymfonyDebugToolbarSubscriber.php b/src/EventSubscriber/SymfonyDebugToolbarSubscriber.php index 9576f3c2..e132bd18 100644 --- a/src/EventSubscriber/SymfonyDebugToolbarSubscriber.php +++ b/src/EventSubscriber/SymfonyDebugToolbarSubscriber.php @@ -45,14 +45,15 @@ namespace App\EventSubscriber; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\Event\ResponseEvent; final class SymfonyDebugToolbarSubscriber implements EventSubscriberInterface { - private $kernel; + private $kernel_debug; - public function __construct(ContainerInterface $kernel) + public function __construct(bool $kernel_debug) { - $this->kernel = $kernel; + $this->kernel_debug = $kernel_debug; } /** @@ -78,9 +79,9 @@ final class SymfonyDebugToolbarSubscriber implements EventSubscriberInterface return ['kernel.response' => 'onKernelResponse']; } - public function onKernelResponse(FilterResponseEvent $event): void + public function onKernelResponse(ResponseEvent $event): void { - if (! $this->kernel->getParameter('kernel.debug')) { + if (! $this->kernel_debug) { return; } diff --git a/src/Security/Voter/ExtendedVoter.php b/src/Security/Voter/ExtendedVoter.php index 8630373b..f0ea142d 100644 --- a/src/Security/Voter/ExtendedVoter.php +++ b/src/Security/Voter/ExtendedVoter.php @@ -43,6 +43,7 @@ declare(strict_types=1); namespace App\Security\Voter; use App\Entity\UserSystem\User; +use App\Repository\UserRepository; use App\Services\PermissionResolver; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; @@ -76,6 +77,7 @@ abstract class ExtendedVoter extends Voter // if the user is anonymous, we use the anonymous user. if (! $user instanceof User) { + /** @var UserRepository $repo */ $repo = $this->entityManager->getRepository(User::class); $user = $repo->getAnonymousUser(); if (null === $user) { diff --git a/src/Services/Attachments/AttachmentURLGenerator.php b/src/Services/Attachments/AttachmentURLGenerator.php index 7d294c65..ebbb0e76 100644 --- a/src/Services/Attachments/AttachmentURLGenerator.php +++ b/src/Services/Attachments/AttachmentURLGenerator.php @@ -130,7 +130,7 @@ class AttachmentURLGenerator throw new InvalidArgumentException('Thumbnail creation only works for picture attachments!'); } - if ($attachment->isExternal()) { + if ($attachment->isExternal() && !empty($attachment->getURL())) { return $attachment->getURL(); } diff --git a/src/Services/Attachments/BuiltinAttachmentsFinder.php b/src/Services/Attachments/BuiltinAttachmentsFinder.php index 92df4a9f..5c7338b8 100644 --- a/src/Services/Attachments/BuiltinAttachmentsFinder.php +++ b/src/Services/Attachments/BuiltinAttachmentsFinder.php @@ -43,10 +43,10 @@ declare(strict_types=1); namespace App\Services\Attachments; use App\Entity\Attachments\Attachment; -use Psr\Cache\InvalidArgumentException; use Symfony\Component\Finder\Finder; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Contracts\Cache\CacheInterface; +use Psr\Cache\InvalidArgumentException; /** * This service is used to find builtin attachment ressources. diff --git a/src/Services/Attachments/FileTypeFilterTools.php b/src/Services/Attachments/FileTypeFilterTools.php index 72479ccc..bf5640f9 100644 --- a/src/Services/Attachments/FileTypeFilterTools.php +++ b/src/Services/Attachments/FileTypeFilterTools.php @@ -174,7 +174,7 @@ class FileTypeFilterTools $extensions = array_merge($extensions, static::IMAGE_EXTS); } elseif ('audio/*' === $element) { $extensions = array_merge($extensions, static::AUDIO_EXTS); - } elseif ('image/*' === $element) { + } elseif ('video/*' === $element) { $extensions = array_merge($extensions, static::VIDEO_EXTS); } elseif (preg_match('#^[-\w.]+\/[-\w.*]+#', $element)) { $extensions = array_merge($extensions, $this->mimeTypes->getExtensions($element)); diff --git a/src/Services/ElementTypeNameGenerator.php b/src/Services/ElementTypeNameGenerator.php index 64362435..797919ab 100644 --- a/src/Services/ElementTypeNameGenerator.php +++ b/src/Services/ElementTypeNameGenerator.php @@ -102,7 +102,7 @@ class ElementTypeNameGenerator * Useful when the type should be shown to user. * Throws an exception if the class is not supported. * - * @param AbstractDBElement|string $entity The element or class for which the label should be generated + * @param object|string $entity The element or class for which the label should be generated * * @return string the localized label for the entity type * diff --git a/src/Services/EntityURLGenerator.php b/src/Services/EntityURLGenerator.php index bedad20d..2d553915 100644 --- a/src/Services/EntityURLGenerator.php +++ b/src/Services/EntityURLGenerator.php @@ -94,12 +94,12 @@ class EntityURLGenerator * @param mixed $entity The element for which the page should be generated * @param string $type The page type. Currently supported: 'info', 'edit', 'create', 'clone', 'list'/'list_parts' * - * @return string the link to the desired page + * @return null|string the link to the desired page * * @throws EntityNotSupportedException thrown if the entity is not supported for the given type * @throws InvalidArgumentException thrown if the givent type is not existing */ - public function getURL($entity, string $type) + public function getURL($entity, string $type): ?string { switch ($type) { case 'info': diff --git a/src/Services/PermissionResolver.php b/src/Services/PermissionResolver.php index 15cb5845..9939c00b 100644 --- a/src/Services/PermissionResolver.php +++ b/src/Services/PermissionResolver.php @@ -62,12 +62,12 @@ class PermissionResolver /** * PermissionResolver constructor. */ - public function __construct(ContainerInterface $container) + public function __construct(bool $kernel_debug, string $kernel_cache_dir) { - $cache_dir = $container->getParameter('kernel.cache_dir'); + $cache_dir = $kernel_cache_dir; //Here the cached structure will be saved. $this->cache_file = $cache_dir.'/permissions.php.cache'; - $this->is_debug = $container->getParameter('kernel.debug'); + $this->is_debug = $kernel_debug; $this->permission_structure = $this->generatePermissionStructure(); @@ -127,7 +127,7 @@ class PermissionResolver return $allowed; } - /** @var HasPermissionsInterface $parent */ + /** @var Group $parent */ $parent = $user->getGroup(); while (null !== $parent) { //The top group, has parent == null //Check if our current element gives a info about disallow/allow