Fixed some issues detected by PHPstan.

This commit is contained in:
Jan Böhmer 2020-02-01 17:00:03 +01:00
parent f2ff77a8b3
commit dd1f806c4e
30 changed files with 310 additions and 45 deletions

View file

@ -38,7 +38,6 @@ use Doctrine\ORM\Mapping\PreUpdate;
use function get_class;
use InvalidArgumentException;
use ReflectionClass;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Security\Core\Security;
/**
@ -59,7 +58,7 @@ class ElementPermissionListener
protected $perm_cache;
public function __construct(Security $security, Reader $reader, EntityManagerInterface $em, KernelInterface $kernel)
public function __construct(Security $security, Reader $reader, EntityManagerInterface $em)
{
$this->security = $security;
$this->reader = $reader;

View file

@ -34,14 +34,17 @@ class AttachmentVoter extends ExtendedVoter
* Similar to voteOnAttribute, but checking for the anonymous user is already done.
* The current user (or the anonymous user) is passed by $user.
*
* @param $attribute
* @param $subject
* @param string $attribute
* @param mixed $subject
* @return bool
*/
protected function voteOnUser($attribute, $subject, User $user): bool
{
if ($subject instanceof Attachment) {
return $this->resolver->inherit($user, 'parts_attachments', $attribute) ?? false;
}
return false;
}
/**

View file

@ -72,8 +72,9 @@ abstract class ExtendedVoter extends Voter
* Similar to voteOnAttribute, but checking for the anonymous user is already done.
* The current user (or the anonymous user) is passed by $user.
*
* @param $attribute
* @param $subject
* @param string $attribute
* @param mixed $subject
* @return bool
*/
abstract protected function voteOnUser($attribute, $subject, User $user): bool;
}

View file

@ -33,8 +33,9 @@ class GroupVoter extends ExtendedVoter
* Similar to voteOnAttribute, but checking for the anonymous user is already done.
* The current user (or the anonymous user) is passed by $user.
*
* @param $attribute
* @param $subject
* @param string $attribute
* @param mixed $subject
* @return bool
*/
protected function voteOnUser($attribute, $subject, User $user): bool
{

View file

@ -37,8 +37,8 @@ class PermissionVoter extends ExtendedVoter
* Similar to voteOnAttribute, but checking for the anonymous user is already done.
* The current user (or the anonymous user) is passed by $user.
*
* @param $attribute
* @param $subject
* @param string $attribute
* @param mixed $subject
*/
protected function voteOnUser($attribute, $subject, User $user): bool
{

View file

@ -54,6 +54,7 @@ class StructureVoter extends ExtendedVoter
//If permission name is null, then the subject is not supported
return (null !== $permission_name) && $this->resolver->isValidOperation($permission_name, $attribute);
}
return false;
}
/**
@ -94,8 +95,9 @@ class StructureVoter extends ExtendedVoter
* Similar to voteOnAttribute, but checking for the anonymous user is already done.
* The current user (or the anonymous user) is passed by $user.
*
* @param $attribute
* @param $subject
* @param string $attribute
* @param mixed $subject
* @return bool
*/
protected function voteOnUser($attribute, $subject, User $user): bool
{

View file

@ -54,8 +54,9 @@ class UserVoter extends ExtendedVoter
* Similar to voteOnAttribute, but checking for the anonymous user is already done.
* The current user (or the anonymous user) is passed by $user.
*
* @param $attribute
* @param $subject
* @param string $attribute
* @param mixed $subject
* @return bool
*/
protected function voteOnUser($attribute, $subject, User $user): bool
{