Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
+52 -61
View File
@@ -11,8 +11,8 @@
namespace Symfony\Component\Security\Acl\Domain;
use Doctrine\Common\NotifyPropertyChanged;
use Doctrine\Common\PropertyChangedListener;
use Doctrine\Persistence\NotifyPropertyChanged;
use Doctrine\Persistence\PropertyChangedListener;
use Symfony\Component\Security\Acl\Model\AclInterface;
use Symfony\Component\Security\Acl\Model\AuditableAclInterface;
use Symfony\Component\Security\Acl\Model\EntryInterface;
@@ -38,23 +38,20 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged
private $parentAcl;
private $permissionGrantingStrategy;
private $objectIdentity;
private $classAces = array();
private $classFieldAces = array();
private $objectAces = array();
private $objectFieldAces = array();
private $classAces = [];
private $classFieldAces = [];
private $objectAces = [];
private $objectFieldAces = [];
private $id;
private $loadedSids;
private $entriesInheriting;
private $listeners = array();
private $listeners = [];
/**
* Constructor.
*
* @param int $id
* @param ObjectIdentityInterface $objectIdentity
* @param PermissionGrantingStrategyInterface $permissionGrantingStrategy
* @param array $loadedSids
* @param bool $entriesInheriting
* @param int $id
* @param bool $entriesInheriting
*/
public function __construct($id, ObjectIdentityInterface $objectIdentity, PermissionGrantingStrategyInterface $permissionGrantingStrategy, array $loadedSids, $entriesInheriting)
{
@@ -67,8 +64,6 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged
/**
* Adds a property changed listener.
*
* @param PropertyChangedListener $listener
*/
public function addPropertyChangedListener(PropertyChangedListener $listener)
{
@@ -120,7 +115,7 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged
*/
public function getClassFieldAces($field)
{
return isset($this->classFieldAces[$field]) ? $this->classFieldAces[$field] : array();
return $this->classFieldAces[$field] ?? [];
}
/**
@@ -136,7 +131,7 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged
*/
public function getObjectFieldAces($field)
{
return isset($this->objectFieldAces[$field]) ? $this->objectFieldAces[$field] : array();
return $this->objectFieldAces[$field] ?? [];
}
/**
@@ -228,14 +223,13 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged
return true;
}
if (!is_array($sids)) {
$sids = array($sids);
if (!\is_array($sids)) {
$sids = [$sids];
}
foreach ($sids as $sid) {
if (!$sid instanceof SecurityIdentityInterface) {
throw new \InvalidArgumentException(
'$sid must be an instance of SecurityIdentityInterface.');
throw new \InvalidArgumentException('$sid must be an instance of SecurityIdentityInterface.');
}
foreach ($this->loadedSids as $loadedSid) {
@@ -257,7 +251,7 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged
*/
public function serialize()
{
return serialize(array(
return serialize([
null === $this->parentAcl ? null : $this->parentAcl->getId(),
$this->objectIdentity,
$this->classAces,
@@ -267,7 +261,7 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged
$this->id,
$this->loadedSids,
$this->entriesInheriting,
));
]);
}
/**
@@ -277,7 +271,7 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged
*/
public function unserialize($serialized)
{
list($this->parentAcl,
[$this->parentAcl,
$this->objectIdentity,
$this->classAces,
$this->classFieldAces,
@@ -286,9 +280,9 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged
$this->id,
$this->loadedSids,
$this->entriesInheriting
) = unserialize($serialized);
] = unserialize($serialized);
$this->listeners = array();
$this->listeners = [];
}
/**
@@ -409,7 +403,7 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged
$this->$property = array_values($this->$property);
$this->onPropertyChanged($property, $oldValue, $this->$property);
for ($i = $index, $c = count($this->$property); $i < $c; ++$i) {
for ($i = $index, $c = \count($this->$property); $i < $c; ++$i) {
$this->onEntryPropertyChanged($aces[$i], 'aceOrder', $i + 1, $i);
}
}
@@ -435,7 +429,7 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged
$aces[$field] = array_values($aces[$field]);
$this->onPropertyChanged($property, $oldValue, $this->$property);
for ($i = $index, $c = count($aces[$field]); $i < $c; ++$i) {
for ($i = $index, $c = \count($aces[$field]); $i < $c; ++$i) {
$this->onEntryPropertyChanged($aces[$field][$i], 'aceOrder', $i + 1, $i);
}
}
@@ -443,23 +437,22 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged
/**
* Inserts an ACE.
*
* @param string $property
* @param int $index
* @param int $mask
* @param SecurityIdentityInterface $sid
* @param bool $granting
* @param string $strategy
* @param string $property
* @param int $index
* @param int $mask
* @param bool $granting
* @param string $strategy
*
* @throws \OutOfBoundsException
* @throws \InvalidArgumentException
*/
private function insertAce($property, $index, $mask, SecurityIdentityInterface $sid, $granting, $strategy = null)
{
if ($index < 0 || $index > count($this->$property)) {
throw new \OutOfBoundsException(sprintf('The index must be in the interval [0, %d].', count($this->$property)));
if ($index < 0 || $index > \count($this->$property)) {
throw new \OutOfBoundsException(sprintf('The index must be in the interval [0, %d].', \count($this->$property)));
}
if (!is_int($mask)) {
if (!\is_int($mask)) {
throw new \InvalidArgumentException('$mask must be an integer.');
}
@@ -475,12 +468,12 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged
$oldValue = $this->$property;
if (isset($aces[$index])) {
$this->$property = array_merge(
array_slice($this->$property, 0, $index),
array(true),
array_slice($this->$property, $index)
\array_slice($this->$property, 0, $index),
[true],
\array_slice($this->$property, $index)
);
for ($i = $index, $c = count($this->$property) - 1; $i < $c; ++$i) {
for ($i = $index, $c = \count($this->$property) - 1; $i < $c; ++$i) {
$this->onEntryPropertyChanged($aces[$i + 1], 'aceOrder', $i, $i + 1);
}
}
@@ -492,24 +485,23 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged
/**
* Inserts a field-based ACE.
*
* @param string $property
* @param int $index
* @param string $field
* @param int $mask
* @param SecurityIdentityInterface $sid
* @param bool $granting
* @param string $strategy
* @param string $property
* @param int $index
* @param string $field
* @param int $mask
* @param bool $granting
* @param string $strategy
*
* @throws \InvalidArgumentException
* @throws \OutOfBoundsException
*/
private function insertFieldAce($property, $index, $field, $mask, SecurityIdentityInterface $sid, $granting, $strategy = null)
{
if (0 === strlen($field)) {
if (0 === \strlen($field)) {
throw new \InvalidArgumentException('$field cannot be empty.');
}
if (!is_int($mask)) {
if (!\is_int($mask)) {
throw new \InvalidArgumentException('$mask must be an integer.');
}
@@ -523,22 +515,22 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged
$aces = &$this->$property;
if (!isset($aces[$field])) {
$aces[$field] = array();
$aces[$field] = [];
}
if ($index < 0 || $index > count($aces[$field])) {
throw new \OutOfBoundsException(sprintf('The index must be in the interval [0, %d].', count($this->$property)));
if ($index < 0 || $index > \count($aces[$field])) {
throw new \OutOfBoundsException(sprintf('The index must be in the interval [0, %d].', \count($this->$property)));
}
$oldValue = $aces;
if (isset($aces[$field][$index])) {
$aces[$field] = array_merge(
array_slice($aces[$field], 0, $index),
array(true),
array_slice($aces[$field], $index)
\array_slice($aces[$field], 0, $index),
[true],
\array_slice($aces[$field], $index)
);
for ($i = $index, $c = count($aces[$field]) - 1; $i < $c; ++$i) {
for ($i = $index, $c = \count($aces[$field]) - 1; $i < $c; ++$i) {
$this->onEntryPropertyChanged($aces[$field][$i + 1], 'aceOrder', $i, $i + 1);
}
}
@@ -616,7 +608,7 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged
*/
private function updateFieldAce($property, $index, $field, $mask, $strategy = null)
{
if (0 === strlen($field)) {
if (0 === \strlen($field)) {
throw new \InvalidArgumentException('$field cannot be empty.');
}
@@ -653,10 +645,9 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged
/**
* Called when a property of an ACE associated with this ACL changes.
*
* @param EntryInterface $entry
* @param string $name
* @param mixed $oldValue
* @param mixed $newValue
* @param string $name
* @param mixed $oldValue
* @param mixed $newValue
*/
private function onEntryPropertyChanged(EntryInterface $entry, $name, $oldValue, $newValue)
{
+3 -7
View File
@@ -29,10 +29,6 @@ class AclCollectionCache
/**
* Constructor.
*
* @param AclProviderInterface $aclProvider
* @param ObjectIdentityRetrievalStrategyInterface $oidRetrievalStrategy
* @param SecurityIdentityRetrievalStrategyInterface $sidRetrievalStrategy
*/
public function __construct(AclProviderInterface $aclProvider, ObjectIdentityRetrievalStrategyInterface $oidRetrievalStrategy, SecurityIdentityRetrievalStrategyInterface $sidRetrievalStrategy)
{
@@ -48,14 +44,14 @@ class AclCollectionCache
* @param mixed $collection anything that can be passed to foreach()
* @param TokenInterface[] $tokens an array of TokenInterface implementations
*/
public function cache($collection, array $tokens = array())
public function cache($collection, array $tokens = [])
{
$sids = array();
$sids = [];
foreach ($tokens as $token) {
$sids = array_merge($sids, $this->securityIdentityRetrievalStrategy->getSecurityIdentities($token));
}
$oids = array();
$oids = [];
foreach ($collection as $domainObject) {
$oids[] = $this->objectIdentityRetrievalStrategy->getObjectIdentity($domainObject);
}
+3 -5
View File
@@ -12,8 +12,8 @@
namespace Symfony\Component\Security\Acl\Domain;
use Symfony\Component\Security\Acl\Model\AuditableEntryInterface;
use Symfony\Component\Security\Acl\Model\EntryInterface;
use Symfony\Component\Security\Acl\Model\AuditLoggerInterface;
use Symfony\Component\Security\Acl\Model\EntryInterface;
/**
* Base audit logger implementation.
@@ -25,8 +25,7 @@ abstract class AuditLogger implements AuditLoggerInterface
/**
* Performs some checks if logging was requested.
*
* @param bool $granted
* @param EntryInterface $ace
* @param bool $granted
*/
public function logIfNeeded($granted, EntryInterface $ace)
{
@@ -44,8 +43,7 @@ abstract class AuditLogger implements AuditLoggerInterface
/**
* This method is only called when logging is needed.
*
* @param bool $granted
* @param EntryInterface $ace
* @param bool $granted
*/
abstract protected function doLog($granted, EntryInterface $ace);
}
+2 -6
View File
@@ -34,15 +34,13 @@ class DoctrineAclCache implements AclCacheInterface
/**
* Constructor.
*
* @param Cache $cache
* @param PermissionGrantingStrategyInterface $permissionGrantingStrategy
* @param string $prefix
* @param string $prefix
*
* @throws \InvalidArgumentException
*/
public function __construct(Cache $cache, PermissionGrantingStrategyInterface $permissionGrantingStrategy, $prefix = self::PREFIX)
{
if (0 === strlen($prefix)) {
if (0 === \strlen($prefix)) {
throw new \InvalidArgumentException('$prefix cannot be empty.');
}
@@ -205,8 +203,6 @@ class DoctrineAclCache implements AclCacheInterface
/**
* Returns the key for the object identity.
*
* @param ObjectIdentityInterface $oid
*
* @return string
*/
private function getDataKeyByIdentity(ObjectIdentityInterface $oid)
+10 -12
View File
@@ -34,14 +34,12 @@ class Entry implements AuditableEntryInterface
/**
* Constructor.
*
* @param int $id
* @param AclInterface $acl
* @param SecurityIdentityInterface $sid
* @param string $strategy
* @param int $mask
* @param bool $granting
* @param bool $auditFailure
* @param bool $auditSuccess
* @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)
{
@@ -178,7 +176,7 @@ class Entry implements AuditableEntryInterface
*/
public function serialize()
{
return serialize(array(
return serialize([
$this->mask,
$this->id,
$this->securityIdentity,
@@ -186,7 +184,7 @@ class Entry implements AuditableEntryInterface
$this->auditFailure,
$this->auditSuccess,
$this->granting,
));
]);
}
/**
@@ -196,13 +194,13 @@ class Entry implements AuditableEntryInterface
*/
public function unserialize($serialized)
{
list($this->mask,
[$this->mask,
$this->id,
$this->securityIdentity,
$this->strategy,
$this->auditFailure,
$this->auditSuccess,
$this->granting
) = unserialize($serialized);
] = unserialize($serialized);
}
}
+13 -12
View File
@@ -27,15 +27,13 @@ class FieldEntry extends Entry implements FieldEntryInterface
/**
* Constructor.
*
* @param int $id
* @param AclInterface $acl
* @param string $field
* @param SecurityIdentityInterface $sid
* @param string $strategy
* @param int $mask
* @param bool $granting
* @param bool $auditFailure
* @param bool $auditSuccess
* @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)
{
@@ -57,10 +55,10 @@ class FieldEntry extends Entry implements FieldEntryInterface
*/
public function serialize()
{
return serialize(array(
return serialize([
$this->field,
parent::serialize(),
));
]);
}
/**
@@ -68,7 +66,10 @@ class FieldEntry extends Entry implements FieldEntryInterface
*/
public function unserialize($serialized)
{
list($this->field, $parentStr) = unserialize($serialized);
[$this->field, $parentStr] = unserialize($serialized);
if (!\is_string($parentStr)) {
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}
parent::unserialize($parentStr);
}
}
+1 -1
View File
@@ -58,7 +58,7 @@ final class ObjectIdentity implements ObjectIdentityInterface
*/
public static function fromDomainObject($domainObject)
{
if (!is_object($domainObject)) {
if (!\is_object($domainObject)) {
throw new InvalidDomainObjectException('$domainObject must be an object.');
}
@@ -33,8 +33,6 @@ class PermissionGrantingStrategy implements PermissionGrantingStrategyInterface
/**
* Sets the audit logger.
*
* @param AuditLoggerInterface $auditLogger
*/
public function setAuditLogger(AuditLoggerInterface $auditLogger)
{
@@ -124,13 +122,12 @@ class PermissionGrantingStrategy implements PermissionGrantingStrategyInterface
* permission/identity combinations are left. Finally, we will either throw
* an NoAceFoundException, or deny access.
*
* @param AclInterface $acl
* @param EntryInterface[] $aces An array of ACE to check against
* @param array $masks An array of permission masks
* @param SecurityIdentityInterface[] $sids An array of SecurityIdentityInterface implementations
* @param bool $administrativeMode True turns off audit logging
*
* @return bool true, or false; either granting, or denying access respectively.
* @return bool true, or false; either granting, or denying access respectively
*
* @throws NoAceFoundException
*/
@@ -188,8 +185,7 @@ class PermissionGrantingStrategy implements PermissionGrantingStrategyInterface
* Strategy EQUAL:
* The ACE will be considered applicable when the bitmasks are equal.
*
* @param int $requiredMask
* @param EntryInterface $ace
* @param int $requiredMask
*
* @return bool
*
@@ -11,13 +11,13 @@
namespace Symfony\Component\Security\Acl\Domain;
use Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface;
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface;
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface;
use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Security\Core\Role\RoleHierarchyInterface;
use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter;
/**
* Strategy for retrieving security identities.
@@ -31,9 +31,6 @@ class SecurityIdentityRetrievalStrategy implements SecurityIdentityRetrievalStra
/**
* Constructor.
*
* @param RoleHierarchyInterface $roleHierarchy
* @param AuthenticationTrustResolverInterface $authenticationTrustResolver
*/
public function __construct(RoleHierarchyInterface $roleHierarchy, AuthenticationTrustResolverInterface $authenticationTrustResolver)
{
@@ -46,7 +43,7 @@ class SecurityIdentityRetrievalStrategy implements SecurityIdentityRetrievalStra
*/
public function getSecurityIdentities(TokenInterface $token)
{
$sids = array();
$sids = [];
// add user security identity
if (!$token instanceof AnonymousToken) {
@@ -50,8 +50,6 @@ final class UserSecurityIdentity implements SecurityIdentityInterface
/**
* Creates a user security identity from a UserInterface.
*
* @param UserInterface $user
*
* @return UserSecurityIdentity
*/
public static function fromAccount(UserInterface $user)
@@ -62,8 +60,6 @@ final class UserSecurityIdentity implements SecurityIdentityInterface
/**
* Creates a user security identity from a TokenInterface.
*
* @param TokenInterface $token
*
* @return UserSecurityIdentity
*/
public static function fromToken(TokenInterface $token)
@@ -74,7 +70,7 @@ final class UserSecurityIdentity implements SecurityIdentityInterface
return self::fromAccount($user);
}
return new self((string) $user, is_object($user) ? ClassUtils::getRealClass($user) : ClassUtils::getRealClass($token));
return new self((string) $user, \is_object($user) ? ClassUtils::getRealClass($user) : ClassUtils::getRealClass($token));
}
/**