mirror of
https://github.com/symfony/security-acl.git
synced 2026-03-24 00:12:18 +01:00
Fix Psalm level 6
This commit is contained in:
@@ -97,6 +97,7 @@ class AclProvider implements AclProviderInterface
|
||||
*/
|
||||
public function findAcls(array $oids, array $sids = [])
|
||||
{
|
||||
/** @var \SplObjectStorage<ObjectIdentityInterface,AclInterface> */
|
||||
$result = new \SplObjectStorage();
|
||||
$currentBatch = [];
|
||||
$oidLookup = [];
|
||||
@@ -451,7 +452,7 @@ QUERY;
|
||||
* This method is called for object identities which could not be retrieved
|
||||
* from the cache, and for which thus a database query is required.
|
||||
*
|
||||
* @return \SplObjectStorage mapping object identities to ACL instances
|
||||
* @return \SplObjectStorage<ObjectIdentityInterface,AclInterface> mapping object identities to ACL instances
|
||||
*
|
||||
* @throws AclNotFoundException
|
||||
*/
|
||||
@@ -477,15 +478,17 @@ QUERY;
|
||||
* Keep in mind that changes to this method might severely reduce the
|
||||
* performance of the entire ACL system.
|
||||
*
|
||||
* @return \SplObjectStorage
|
||||
* @return \SplObjectStorage<ObjectIdentityInterface,AclInterface>
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
private function hydrateObjectIdentities(Result $stmt, array $oidLookup, array $sids)
|
||||
{
|
||||
/** @var \SplObjectStorage<Acl,string> */
|
||||
$parentIdToFill = new \SplObjectStorage();
|
||||
$acls = $aces = $emptyArray = [];
|
||||
$oidCache = $oidLookup;
|
||||
/** @var \SplObjectStorage<ObjectIdentityInterface,AclInterface> */
|
||||
$result = new \SplObjectStorage();
|
||||
$loadedAces = &$this->loadedAces;
|
||||
$loadedAcls = &$this->loadedAcls;
|
||||
|
||||
@@ -576,10 +576,10 @@ QUERY;
|
||||
/**
|
||||
* Constructs the SQL for selecting an ACE.
|
||||
*
|
||||
* @param int $classId
|
||||
* @param int $oid
|
||||
* @param string $field
|
||||
* @param int $order
|
||||
* @param int $classId
|
||||
* @param int|null $oid
|
||||
* @param string|null $field
|
||||
* @param int $order
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
||||
@@ -217,17 +217,17 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isSidLoaded($sids)
|
||||
public function isSidLoaded($securityIdentities)
|
||||
{
|
||||
if (!$this->loadedSids) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!\is_array($sids)) {
|
||||
$sids = [$sids];
|
||||
if (!\is_array($securityIdentities)) {
|
||||
$securityIdentities = [$securityIdentities];
|
||||
}
|
||||
|
||||
foreach ($sids as $sid) {
|
||||
foreach ($securityIdentities as $sid) {
|
||||
if (!$sid instanceof SecurityIdentityInterface) {
|
||||
throw new \InvalidArgumentException('$sid must be an instance of SecurityIdentityInterface.');
|
||||
}
|
||||
|
||||
@@ -31,17 +31,7 @@ class Entry implements AuditableEntryInterface
|
||||
private $auditSuccess;
|
||||
private $granting;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $strategy
|
||||
* @param int $mask
|
||||
* @param bool $granting
|
||||
* @param bool $auditFailure
|
||||
* @param bool $auditSuccess
|
||||
*/
|
||||
public function __construct($id, AclInterface $acl, SecurityIdentityInterface $sid, $strategy, $mask, $granting, $auditFailure, $auditSuccess)
|
||||
public function __construct(?int $id, AclInterface $acl, SecurityIdentityInterface $sid, string $strategy, int $mask, bool $granting, bool $auditFailure, bool $auditSuccess)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->acl = $acl;
|
||||
|
||||
@@ -24,18 +24,7 @@ class FieldEntry extends Entry implements FieldEntryInterface
|
||||
{
|
||||
private $field;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $field
|
||||
* @param string $strategy
|
||||
* @param int $mask
|
||||
* @param bool $granting
|
||||
* @param bool $auditFailure
|
||||
* @param bool $auditSuccess
|
||||
*/
|
||||
public function __construct($id, AclInterface $acl, $field, SecurityIdentityInterface $sid, $strategy, $mask, $granting, $auditFailure, $auditSuccess)
|
||||
public function __construct(?int $id, AclInterface $acl, string $field, SecurityIdentityInterface $sid, string $strategy, int $mask, bool $granting, bool $auditFailure, $auditSuccess)
|
||||
{
|
||||
parent::__construct($id, $acl, $sid, $strategy, $mask, $granting, $auditFailure, $auditSuccess);
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
|
||||
namespace Symfony\Component\Security\Acl\Exception;
|
||||
|
||||
use Symfony\Component\Security\Acl\Model\AclInterface;
|
||||
use Symfony\Component\Security\Acl\Model\ObjectIdentityInterface;
|
||||
|
||||
/**
|
||||
* This exception is thrown when you have requested ACLs for multiple object
|
||||
* identities, but the AclProvider implementation failed to find ACLs for all
|
||||
@@ -25,7 +28,7 @@ class NotAllAclsFoundException extends AclNotFoundException
|
||||
private $partialResult;
|
||||
|
||||
/**
|
||||
* Sets the partial result.
|
||||
* @param \SplObjectStorage<ObjectIdentityInterface,AclInterface> $result
|
||||
*/
|
||||
public function setPartialResult(\SplObjectStorage $result)
|
||||
{
|
||||
@@ -35,7 +38,7 @@ class NotAllAclsFoundException extends AclNotFoundException
|
||||
/**
|
||||
* Returns the partial result.
|
||||
*
|
||||
* @return \SplObjectStorage
|
||||
* @return \SplObjectStorage<ObjectIdentityInterface,AclInterface>
|
||||
*/
|
||||
public function getPartialResult()
|
||||
{
|
||||
|
||||
@@ -21,9 +21,9 @@ interface AclCacheInterface
|
||||
/**
|
||||
* Removes an ACL from the cache.
|
||||
*
|
||||
* @param string $primaryKey a serialized primary key
|
||||
* @param string $aclId a serialized primary key
|
||||
*/
|
||||
public function evictFromCacheById($primaryKey);
|
||||
public function evictFromCacheById($aclId);
|
||||
|
||||
/**
|
||||
* Removes an ACL from the cache.
|
||||
@@ -35,11 +35,11 @@ interface AclCacheInterface
|
||||
/**
|
||||
* Retrieves an ACL for the given object identity primary key from the cache.
|
||||
*
|
||||
* @param int $primaryKey
|
||||
* @param int $aclId
|
||||
*
|
||||
* @return AclInterface|null
|
||||
*/
|
||||
public function getFromCacheById($primaryKey);
|
||||
public function getFromCacheById($aclId);
|
||||
|
||||
/**
|
||||
* Retrieves an ACL for the given object identity from the cache.
|
||||
|
||||
@@ -31,7 +31,7 @@ interface EntryInterface extends \Serializable
|
||||
/**
|
||||
* The primary key of this ACE.
|
||||
*
|
||||
* @return int
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
|
||||
@@ -24,5 +24,5 @@ interface SecurityIdentityInterface
|
||||
* This method is used to compare two security identities in order to
|
||||
* not rely on referential equality.
|
||||
*/
|
||||
public function equals(self $identity);
|
||||
public function equals(self $sid);
|
||||
}
|
||||
|
||||
@@ -51,33 +51,33 @@ class AclVoter implements VoterInterface
|
||||
return \is_string($attribute) && $this->permissionMap->contains($attribute);
|
||||
}
|
||||
|
||||
public function vote(TokenInterface $token, $object, array $attributes)
|
||||
public function vote(TokenInterface $token, $subject, array $attributes)
|
||||
{
|
||||
foreach ($attributes as $attribute) {
|
||||
if (!$this->supportsAttribute($attribute)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (null === $masks = $this->permissionMap->getMasks($attribute, $object)) {
|
||||
if (null === $masks = $this->permissionMap->getMasks($attribute, $subject)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (null === $object) {
|
||||
if (null === $subject) {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf('Object identity unavailable. Voting to %s.', $this->allowIfObjectIdentityUnavailable ? 'grant access' : 'abstain'));
|
||||
}
|
||||
|
||||
return $this->allowIfObjectIdentityUnavailable ? self::ACCESS_GRANTED : self::ACCESS_ABSTAIN;
|
||||
} elseif ($object instanceof FieldVote) {
|
||||
$field = $object->getField();
|
||||
$object = $object->getDomainObject();
|
||||
} elseif ($subject instanceof FieldVote) {
|
||||
$field = $subject->getField();
|
||||
$subject = $subject->getDomainObject();
|
||||
} else {
|
||||
$field = null;
|
||||
}
|
||||
|
||||
if ($object instanceof ObjectIdentityInterface) {
|
||||
$oid = $object;
|
||||
} elseif (null === $oid = $this->objectIdentityRetrievalStrategy->getObjectIdentity($object)) {
|
||||
if ($subject instanceof ObjectIdentityInterface) {
|
||||
$oid = $subject;
|
||||
} elseif (null === $oid = $this->objectIdentityRetrievalStrategy->getObjectIdentity($subject)) {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf('Object identity unavailable. Voting to %s.', $this->allowIfObjectIdentityUnavailable ? 'grant access' : 'abstain'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user