diff options
Diffstat (limited to 'Acl')
-rw-r--r-- | Acl/Dbal/AclProvider.php | 8 | ||||
-rw-r--r-- | Acl/Dbal/MutableAclProvider.php | 21 | ||||
-rw-r--r-- | Acl/Domain/Acl.php | 22 | ||||
-rw-r--r-- | Acl/Permission/MaskBuilder.php | 2 | ||||
-rw-r--r-- | Acl/Tests/Dbal/AclProviderBenchmarkTest.php | 8 | ||||
-rw-r--r-- | Acl/Tests/Dbal/MutableAclProviderTest.php | 11 | ||||
-rw-r--r-- | Acl/Tests/Domain/AclTest.php | 4 | ||||
-rw-r--r-- | Acl/Tests/Domain/AuditLoggerTest.php | 2 | ||||
-rw-r--r-- | Acl/Tests/Domain/PermissionGrantingStrategyTest.php | 3 | ||||
-rw-r--r-- | Acl/Tests/Domain/SecurityIdentityRetrievalStrategyTest.php | 2 | ||||
-rw-r--r-- | Acl/Voter/AclVoter.php | 4 |
11 files changed, 45 insertions, 42 deletions
diff --git a/Acl/Dbal/AclProvider.php b/Acl/Dbal/AclProvider.php index c422c2d..96b6a4b 100644 --- a/Acl/Dbal/AclProvider.php +++ b/Acl/Dbal/AclProvider.php @@ -104,7 +104,7 @@ class AclProvider implements AclProviderInterface $currentBatch = array(); $oidLookup = array(); - for ($i=0,$c=count($oids); $i<$c; $i++) { + for ($i = 0,$c = count($oids); $i<$c; $i++) { $oid = $oids[$i]; $oidLookupKey = $oid->getIdentifier().$oid->getType(); $oidLookup[$oidLookupKey] = $oid; @@ -500,8 +500,8 @@ QUERY; $acls = $aces = $emptyArray = array(); $oidCache = $oidLookup; $result = new \SplObjectStorage(); - $loadedAces =& $this->loadedAces; - $loadedAcls =& $this->loadedAcls; + $loadedAces = & $this->loadedAces; + $loadedAcls = & $this->loadedAcls; $permissionGrantingStrategy = $this->permissionGrantingStrategy; // we need these to set protected properties on hydrated objects @@ -593,7 +593,7 @@ QUERY; // It is important to only ever have one ACE instance per actual row since // some ACEs are shared between ACL instances if (!isset($loadedAces[$aceId])) { - if (!isset($sids[$key = ($username?'1':'0').$securityIdentifier])) { + if (!isset($sids[$key = ($username ? '1' : '0').$securityIdentifier])) { if ($username) { $sids[$key] = new UserSecurityIdentity( substr($securityIdentifier, 1 + $pos = strpos($securityIdentifier, '-')), diff --git a/Acl/Dbal/MutableAclProvider.php b/Acl/Dbal/MutableAclProvider.php index b8f5fb8..2a4eac0 100644 --- a/Acl/Dbal/MutableAclProvider.php +++ b/Acl/Dbal/MutableAclProvider.php @@ -188,7 +188,7 @@ class MutableAclProvider extends AclProvider implements MutableAclProviderInterf $propertyChanges['aces'] = new \SplObjectStorage(); } - $acePropertyChanges = $propertyChanges['aces']->contains($ace)? $propertyChanges['aces']->offsetGet($ace) : array(); + $acePropertyChanges = $propertyChanges['aces']->contains($ace) ? $propertyChanges['aces']->offsetGet($ace) : array(); if (isset($acePropertyChanges[$propertyName])) { $oldValue = $acePropertyChanges[$propertyName][0]; @@ -448,8 +448,8 @@ QUERY; $query, $this->options['entry_table_name'], $classId, - null === $objectIdentityId? 'NULL' : intval($objectIdentityId), - null === $field? 'NULL' : $this->connection->quote($field), + null === $objectIdentityId ? 'NULL' : intval($objectIdentityId), + null === $field ? 'NULL' : $this->connection->quote($field), $aceOrder, $securityIdentityId, $mask, @@ -767,7 +767,7 @@ QUERY; $classIds = new \SplObjectStorage(); $currentIds = array(); foreach ($changes[1] as $field => $new) { - for ($i=0,$c=count($new); $i<$c; $i++) { + for ($i = 0,$c = count($new); $i<$c; $i++) { $ace = $new[$i]; if (null === $ace->getId()) { @@ -844,7 +844,7 @@ QUERY; $sids = new \SplObjectStorage(); $classIds = new \SplObjectStorage(); $currentIds = array(); - for ($i=0,$c=count($new); $i<$c; $i++) { + for ($i = 0,$c = count($new); $i<$c; $i++) { $ace = $new[$i]; if (null === $ace->getId()) { @@ -887,7 +887,7 @@ QUERY; list($old, $new) = $changes; $currentIds = array(); - for ($i=0,$c=count($new); $i<$c; $i++) { + for ($i = 0,$c = count($new); $i<$c; $i++) { $ace = $new[$i]; if (null !== $ace->getId()) { @@ -925,11 +925,11 @@ QUERY; if (isset($propertyChanges['aceOrder']) && $propertyChanges['aceOrder'][1] > $propertyChanges['aceOrder'][0] && $propertyChanges == $aces->offsetGet($ace)) { - $aces->next(); - if ($aces->valid()) { - $this->updateAce($aces, $aces->current()); - } + $aces->next(); + if ($aces->valid()) { + $this->updateAce($aces, $aces->current()); } + } if (isset($propertyChanges['mask'])) { $sets[] = sprintf('mask = %d', $propertyChanges['mask'][1]); @@ -949,5 +949,4 @@ QUERY; $this->connection->executeQuery($this->getUpdateAccessControlEntrySql($ace->getId(), $sets)); } - } diff --git a/Acl/Domain/Acl.php b/Acl/Domain/Acl.php index 5be5831..d3aecfb 100644 --- a/Acl/Domain/Acl.php +++ b/Acl/Domain/Acl.php @@ -119,7 +119,7 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged */ public function getClassFieldAces($field) { - return isset($this->classFieldAces[$field])? $this->classFieldAces[$field] : array(); + return isset($this->classFieldAces[$field]) ? $this->classFieldAces[$field] : array(); } /** @@ -397,7 +397,7 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged */ private function deleteAce($property, $index) { - $aces =& $this->$property; + $aces = & $this->$property; if (!isset($aces[$index])) { throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index)); } @@ -407,7 +407,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); } } @@ -422,7 +422,7 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged */ private function deleteFieldAce($property, $index, $field) { - $aces =& $this->$property; + $aces = & $this->$property; if (!isset($aces[$field][$index])) { throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index)); } @@ -432,7 +432,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); } } @@ -467,7 +467,7 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged } } - $aces =& $this->$property; + $aces = & $this->$property; $oldValue = $this->$property; if (isset($aces[$index])) { $this->$property = array_merge( @@ -476,7 +476,7 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged 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); } } @@ -516,7 +516,7 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged } } - $aces =& $this->$property; + $aces = & $this->$property; if (!isset($aces[$field])) { $aces[$field] = array(); } @@ -533,7 +533,7 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged 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); } } @@ -553,7 +553,7 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged */ private function updateAce($property, $index, $mask, $strategy = null) { - $aces =& $this->$property; + $aces = & $this->$property; if (!isset($aces[$index])) { throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index)); } @@ -612,7 +612,7 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged throw new \InvalidArgumentException('$field cannot be empty.'); } - $aces =& $this->$property; + $aces = & $this->$property; if (!isset($aces[$field][$index])) { throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index)); } diff --git a/Acl/Permission/MaskBuilder.php b/Acl/Permission/MaskBuilder.php index 4d475fb..8ca25bc 100644 --- a/Acl/Permission/MaskBuilder.php +++ b/Acl/Permission/MaskBuilder.php @@ -128,7 +128,7 @@ class MaskBuilder $length = strlen($pattern); $bitmask = str_pad(decbin($this->mask), $length, '0', STR_PAD_LEFT); - for ($i=$length-1; $i>=0; $i--) { + for ($i = $length-1; $i >= 0; $i--) { if ('1' === $bitmask[$i]) { try { $pattern[$i] = self::getCode(1 << ($length - $i - 1)); diff --git a/Acl/Tests/Dbal/AclProviderBenchmarkTest.php b/Acl/Tests/Dbal/AclProviderBenchmarkTest.php index 8f68f1f..c7383dc 100644 --- a/Acl/Tests/Dbal/AclProviderBenchmarkTest.php +++ b/Acl/Tests/Dbal/AclProviderBenchmarkTest.php @@ -92,7 +92,7 @@ class AclProviderBenchmarkTest extends \PHPUnit_Framework_TestCase $this->insertEntryStmt = $this->con->prepare('INSERT INTO acl_entries (id, class_id, object_identity_id, field_name, ace_order, security_identity_id, mask, granting, granting_strategy, audit_success, audit_failure) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'); $this->insertOidAncestorStmt = $this->con->prepare('INSERT INTO acl_object_identity_ancestors (object_identity_id, ancestor_id) VALUES (?, ?)'); - for ($i=0; $i<40000; $i++) { + for ($i = 0; $i<40000; $i++) { $this->generateAclHierarchy(); } } @@ -107,7 +107,7 @@ class AclProviderBenchmarkTest extends \PHPUnit_Framework_TestCase protected function generateAclLevel($depth, $parentId, $ancestors) { $level = count($ancestors); - for ($i=0,$t=rand(1, 10); $i<$t; $i++) { + for ($i = 0,$t = rand(1, 10); $i<$t; $i++) { $id = $this->generateAcl($this->chooseClassId(), $parentId, $ancestors); if ($level < $depth) { @@ -161,7 +161,7 @@ class AclProviderBenchmarkTest extends \PHPUnit_Framework_TestCase $this->insertSidStmt->execute(array( $id, $this->getRandomString(rand(5, 30)), - rand(0, 1) + rand(0, 1), )); $id += 1; @@ -178,7 +178,7 @@ class AclProviderBenchmarkTest extends \PHPUnit_Framework_TestCase $sids = array(); $fieldOrder = array(); - for ($i=0; $i<=30; $i++) { + for ($i = 0; $i <= 30; $i++) { $fieldName = rand(0, 1) ? null : $this->getRandomString(rand(10, 20)); do { diff --git a/Acl/Tests/Dbal/MutableAclProviderTest.php b/Acl/Tests/Dbal/MutableAclProviderTest.php index 440f69c..f74e04c 100644 --- a/Acl/Tests/Dbal/MutableAclProviderTest.php +++ b/Acl/Tests/Dbal/MutableAclProviderTest.php @@ -88,7 +88,8 @@ class MutableAclProviderTest extends \PHPUnit_Framework_TestCase try { $provider->findAcl($oid); $this->fail('ACL has not been properly deleted.'); - } catch (AclNotFoundException $notFound) { } + } catch (AclNotFoundException $notFound) { + } } public function testDeleteAclDeletesChildren() @@ -103,7 +104,8 @@ class MutableAclProviderTest extends \PHPUnit_Framework_TestCase try { $provider->findAcl(new ObjectIdentity(1, 'Foo')); $this->fail('Child-ACLs have not been deleted.'); - } catch (AclNotFoundException $notFound) { } + } catch (AclNotFoundException $notFound) { + } } public function testFindAclsAddsPropertyListener() @@ -148,7 +150,7 @@ class MutableAclProviderTest extends \PHPUnit_Framework_TestCase 'parent' => array( 'object_identifier' => '1', 'class_type' => 'anotherFoo', - ) + ), )); $propertyChanges = $this->getField($provider, 'propertyChanges'); @@ -288,7 +290,8 @@ class MutableAclProviderTest extends \PHPUnit_Framework_TestCase try { $provider->updateAcl($acl1); $this->fail('Provider failed to detect a concurrent modification.'); - } catch (ConcurrentModificationException $ex) { } + } catch (ConcurrentModificationException $ex) { + } } public function testUpdateAcl() diff --git a/Acl/Tests/Domain/AclTest.php b/Acl/Tests/Domain/AclTest.php index 2034c21..ff29bcf 100644 --- a/Acl/Tests/Domain/AclTest.php +++ b/Acl/Tests/Domain/AclTest.php @@ -128,7 +128,7 @@ class AclTest extends \PHPUnit_Framework_TestCase $acl = $this->getAcl(); $listener = $this->getListener(array( - $property, 'aceOrder', $property, 'aceOrder', $property + $property, 'aceOrder', $property, 'aceOrder', $property, )); $acl->addPropertyChangedListener($listener); @@ -358,7 +358,7 @@ class AclTest extends \PHPUnit_Framework_TestCase $acl->{'insert'.$type}('foo', new UserSecurityIdentity('foo', 'Foo'), 1); $listener = $this->getListener(array( - 'mask', 'mask', 'strategy' + 'mask', 'mask', 'strategy', )); $acl->addPropertyChangedListener($listener); diff --git a/Acl/Tests/Domain/AuditLoggerTest.php b/Acl/Tests/Domain/AuditLoggerTest.php index fe56b8c..6c600fb 100644 --- a/Acl/Tests/Domain/AuditLoggerTest.php +++ b/Acl/Tests/Domain/AuditLoggerTest.php @@ -28,7 +28,7 @@ class AuditLoggerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($audit)) ; - $ace + $ace ->expects($this->never()) ->method('isAuditFailure') ; diff --git a/Acl/Tests/Domain/PermissionGrantingStrategyTest.php b/Acl/Tests/Domain/PermissionGrantingStrategyTest.php index 490d256..c7675ea 100644 --- a/Acl/Tests/Domain/PermissionGrantingStrategyTest.php +++ b/Acl/Tests/Domain/PermissionGrantingStrategyTest.php @@ -154,7 +154,8 @@ class PermissionGrantingStrategyTest extends \PHPUnit_Framework_TestCase try { $strategy->isGranted($acl, array($requiredMask), array($sid)); $this->fail('The ACE is not supposed to match.'); - } catch (NoAceFoundException $noAce) { } + } catch (NoAceFoundException $noAce) { + } } else { $this->assertTrue($strategy->isGranted($acl, array($requiredMask), array($sid))); } diff --git a/Acl/Tests/Domain/SecurityIdentityRetrievalStrategyTest.php b/Acl/Tests/Domain/SecurityIdentityRetrievalStrategyTest.php index 02fbe67..160c27c 100644 --- a/Acl/Tests/Domain/SecurityIdentityRetrievalStrategyTest.php +++ b/Acl/Tests/Domain/SecurityIdentityRetrievalStrategyTest.php @@ -103,7 +103,7 @@ class SecurityIdentityRetrievalStrategyTest extends \PHPUnit_Framework_TestCase array('guest', array('ROLE_FOO'), 'anonymous', array( new RoleSecurityIdentity('ROLE_FOO'), new RoleSecurityIdentity('IS_AUTHENTICATED_ANONYMOUSLY'), - )) + )), ); } diff --git a/Acl/Voter/AclVoter.php b/Acl/Voter/AclVoter.php index b21b1e6..9657eed 100644 --- a/Acl/Voter/AclVoter.php +++ b/Acl/Voter/AclVoter.php @@ -64,7 +64,7 @@ class AclVoter implements VoterInterface if (null === $object) { if (null !== $this->logger) { - $this->logger->debug(sprintf('Object identity unavailable. Voting to %s', $this->allowIfObjectIdentityUnavailable? 'grant access' : 'abstain')); + $this->logger->debug(sprintf('Object identity unavailable. Voting to %s', $this->allowIfObjectIdentityUnavailable ? 'grant access' : 'abstain')); } return $this->allowIfObjectIdentityUnavailable ? self::ACCESS_GRANTED : self::ACCESS_ABSTAIN; @@ -79,7 +79,7 @@ class AclVoter implements VoterInterface $oid = $object; } elseif (null === $oid = $this->objectIdentityRetrievalStrategy->getObjectIdentity($object)) { if (null !== $this->logger) { - $this->logger->debug(sprintf('Object identity unavailable. Voting to %s', $this->allowIfObjectIdentityUnavailable? 'grant access' : 'abstain')); + $this->logger->debug(sprintf('Object identity unavailable. Voting to %s', $this->allowIfObjectIdentityUnavailable ? 'grant access' : 'abstain')); } return $this->allowIfObjectIdentityUnavailable ? self::ACCESS_GRANTED : self::ACCESS_ABSTAIN; |