Skip to content

Commit

Permalink
Introduce Voter stub
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Jan 31, 2023
1 parent d89a521 commit 44aef78
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions extension.neon
Expand Up @@ -14,6 +14,7 @@ parameters:
featureToggles:
skipCheckGenericClasses:
- Symfony\Component\OptionsResolver\Options
- Symfony\Component\Security\Core\Authorization\Voter\Voter
- Symfony\Component\Security\Core\User\PasswordUpgraderInterface
stubFiles:
- stubs/Psr/Cache/CacheItemInterface.stub
Expand Down Expand Up @@ -50,6 +51,7 @@ parameters:
- stubs/Symfony/Component/Security/Acl/Model/AclInterface.stub
- stubs/Symfony/Component/Security/Acl/Model/EntryInterface.stub
- stubs/Symfony/Component/Security/Core/Authentication/Token/TokenInterface.stub
- stubs/Symfony/Component/Security/Core/Authorization/Voter/Voter.stub
- stubs/Symfony/Component/Security/Core/Authorization/Voter/VoterInterface.stub
- stubs/Symfony/Component/Security/Core/User/PasswordAuthenticatedUserInterface.stub
- stubs/Symfony/Component/Security/Core/User/PasswordUpgraderInterface.stub
Expand Down
@@ -0,0 +1,35 @@
<?php

namespace Symfony\Component\Security\Core\Authorization\Voter;

use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;

/**
* @template TAttribute of string
* @template TSubject of mixed
*/
abstract class Voter implements VoterInterface
{
/**
* Determines if the attribute and subject are supported by this voter.
*
* @param mixed $subject
*
* @phpstan-assert-if-true TSubject $subject
* @phpstan-assert-if-true TAttribute $attribute
*
* @return bool
*/
abstract protected function supports(string $attribute, $subject);

/**
* Perform a single access check operation on a given attribute, subject and token.
* It is safe to assume that $attribute and $subject already passed the "supports()" method check.
*
* @phpstan-param TAttribute $attribute
* @phpstan-param TSubject $subject
*
* @return bool
*/
abstract protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token);
}

0 comments on commit 44aef78

Please sign in to comment.