mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
Added phpstan template annotations to Voters to fix phpstan issues
This commit is contained in:
parent
e9d03a0c95
commit
49034fabf2
16 changed files with 43 additions and 0 deletions
|
@ -45,6 +45,9 @@ use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
|||
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* @phpstan-extends Voter<non-empty-string, Attachment|class-string>
|
||||
*/
|
||||
final class AttachmentVoter extends Voter
|
||||
{
|
||||
private const ALLOWED_ATTRIBUTES = ['read', 'view', 'edit', 'delete', 'create', 'show_private', 'show_history'];
|
||||
|
|
|
@ -29,6 +29,9 @@ use Symfony\Bundle\SecurityBundle\Security;
|
|||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
|
||||
/**
|
||||
* @phpstan-extends Voter<non-empty-string, ProjectBOMEntry|class-string>
|
||||
*/
|
||||
class BOMEntryVoter extends Voter
|
||||
{
|
||||
|
||||
|
|
|
@ -28,6 +28,9 @@ use App\Services\UserSystem\VoterHelper;
|
|||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
|
||||
/**
|
||||
* @phpstan-extends Voter<non-empty-string, Group|class-string>
|
||||
*/
|
||||
final class GroupVoter extends Voter
|
||||
{
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
|||
/**
|
||||
* This voter implements a virtual role, which can be used if the user has any permission set to allowed.
|
||||
* We use this to restrict access to the homepage.
|
||||
* @phpstan-extends Voter<non-empty-string, null>
|
||||
*/
|
||||
final class HasAccessPermissionsVoter extends Voter
|
||||
{
|
||||
|
|
|
@ -30,6 +30,11 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
|||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
/**
|
||||
* This voter implements a virtual role, which can be used if the user has any permission set to allowed.
|
||||
* We use this to restrict access to the homepage.
|
||||
* @phpstan-extends Voter<non-empty-string, User>
|
||||
*/
|
||||
final class ImpersonateUserVoter extends Voter
|
||||
{
|
||||
|
||||
|
|
|
@ -47,6 +47,9 @@ use App\Services\UserSystem\VoterHelper;
|
|||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
|
||||
/**
|
||||
* @phpstan-extends Voter<non-empty-string, LabelProfile|class-string>
|
||||
*/
|
||||
final class LabelProfileVoter extends Voter
|
||||
{
|
||||
protected const MAPPING = [
|
||||
|
|
|
@ -31,6 +31,9 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
|
||||
/**
|
||||
* @phpstan-extends Voter<non-empty-string, AbstractLogEntry>
|
||||
*/
|
||||
final class LogEntryVoter extends Voter
|
||||
{
|
||||
final public const ALLOWED_OPS = ['read', 'show_details', 'delete'];
|
||||
|
|
|
@ -51,6 +51,9 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
|
||||
/**
|
||||
* @phpstan-extends Voter<non-empty-string, Orderdetail|class-string>
|
||||
*/
|
||||
final class OrderdetailVoter extends Voter
|
||||
{
|
||||
public function __construct(private readonly Security $security, private readonly VoterHelper $helper)
|
||||
|
|
|
@ -44,6 +44,9 @@ use RuntimeException;
|
|||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
|
||||
/**
|
||||
* @phpstan-extends Voter<non-empty-string, AbstractParameter|class-string>
|
||||
*/
|
||||
final class ParameterVoter extends Voter
|
||||
{
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
|||
/**
|
||||
* This voter handles permissions for part associations.
|
||||
* The permissions are inherited from the part.
|
||||
* @phpstan-extends Voter<non-empty-string, PartAssociation|class-string>
|
||||
*/
|
||||
final class PartAssociationVoter extends Voter
|
||||
{
|
||||
|
|
|
@ -51,6 +51,9 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
|
||||
/**
|
||||
* @phpstan-extends Voter<non-empty-string, PartLot|class-string>
|
||||
*/
|
||||
final class PartLotVoter extends Voter
|
||||
{
|
||||
public function __construct(private readonly Security $security, private readonly VoterHelper $helper)
|
||||
|
|
|
@ -32,6 +32,8 @@ use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
|||
* A Voter that votes on Part entities.
|
||||
*
|
||||
* See parts permissions for valid operations.
|
||||
*
|
||||
* @phpstan-extends Voter<non-empty-string, Part|class-string>
|
||||
*/
|
||||
final class PartVoter extends Voter
|
||||
{
|
||||
|
|
|
@ -31,6 +31,7 @@ use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
|||
* This voter allows you to directly check permissions from the permission structure, without passing an object.
|
||||
* This use the syntax like "@permission.op"
|
||||
* However you should use the "normal" object based voters if possible, because they are needed for a future ACL system.
|
||||
* @phpstan-extends Voter<non-empty-string, null>
|
||||
*/
|
||||
final class PermissionVoter extends Voter
|
||||
{
|
||||
|
|
|
@ -52,6 +52,9 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
|
||||
/**
|
||||
* @phpstan-extends Voter<non-empty-string, Pricedetail|class-string>
|
||||
*/
|
||||
final class PricedetailVoter extends Voter
|
||||
{
|
||||
public function __construct(private readonly Security $security, private readonly VoterHelper $helper)
|
||||
|
|
|
@ -39,6 +39,9 @@ use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
|||
use function get_class;
|
||||
use function is_object;
|
||||
|
||||
/**
|
||||
* @phpstan-extends Voter<non-empty-string, AttachmentType|Category|Project|Footprint|Manufacturer|StorageLocation|Supplier|Currency|MeasurementUnit|class-string>
|
||||
*/
|
||||
final class StructureVoter extends Voter
|
||||
{
|
||||
protected const OBJ_PERM_MAP = [
|
||||
|
|
|
@ -30,6 +30,9 @@ use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
|||
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* @phpstan-extends Voter<non-empty-string, User|class-string>
|
||||
*/
|
||||
final class UserVoter extends Voter
|
||||
{
|
||||
public function __construct(private readonly VoterHelper $helper, private readonly PermissionManager $resolver)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue