Fixed some more psalm issues.

This commit is contained in:
Jan Böhmer 2020-03-29 23:36:53 +02:00
parent cb0aa7bc7a
commit a28e81065f
11 changed files with 25 additions and 18 deletions

View file

@ -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();
}

View file

@ -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.

View file

@ -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));

View file

@ -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
*

View file

@ -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':

View file

@ -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