summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Reznichenko <kalessil@gmail.com>2015-03-06 20:37:36 +0100
committerFabien Potencier <fabien.potencier@gmail.com>2015-03-07 08:38:01 +0100
commit05fec30b749b3940e13a1115de6be46682de14dc (patch)
tree173185af0948bb2eb3db3e713fbae19d8cb59225
parent5d5a4e20a8f5db004e045a5b8137a6d455272ee4 (diff)
downloadsymfony-security-05fec30b749b3940e13a1115de6be46682de14dc.zip
symfony-security-05fec30b749b3940e13a1115de6be46682de14dc.tar.gz
symfony-security-05fec30b749b3940e13a1115de6be46682de14dc.tar.bz2
[2.3] [Config] [Console] [DependencyInjection] [DomCrawler] [Form] [HttpKernel] [PropertyAccess] [Security] [Translation] [Yaml] static code analysis, code cleanup
-rw-r--r--Acl/Dbal/AclProvider.php12
-rw-r--r--Tests/Acl/Dbal/AclProviderBenchmarkTest.php8
-rw-r--r--Tests/Core/Util/SecureRandomTest.php8
-rw-r--r--Tests/Http/Firewall/ExceptionListenerTest.php6
4 files changed, 18 insertions, 16 deletions
diff --git a/Acl/Dbal/AclProvider.php b/Acl/Dbal/AclProvider.php
index b53dc75..5074614 100644
--- a/Acl/Dbal/AclProvider.php
+++ b/Acl/Dbal/AclProvider.php
@@ -173,7 +173,8 @@ class AclProvider implements AclProviderInterface
}
// Is it time to load the current batch?
- if ((self::MAX_BATCH_SIZE === count($currentBatch) || ($i + 1) === $c) && count($currentBatch) > 0) {
+ $currentBatchesCount = count($currentBatch);
+ if ($currentBatchesCount > 0 && (self::MAX_BATCH_SIZE === $currentBatchesCount || ($i + 1) === $c)) {
try {
$loadedBatch = $this->lookupObjectIdentities($currentBatch, $sids, $oidLookup);
} catch (AclNotFoundException $aclNotFoundexception) {
@@ -557,10 +558,11 @@ QUERY;
// attach ACL to the result set; even though we do not enforce that every
// object identity has only one instance, we must make sure to maintain
// referential equality with the oids passed to findAcls()
- if (!isset($oidCache[$objectIdentifier.$classType])) {
- $oidCache[$objectIdentifier.$classType] = $acl->getObjectIdentity();
+ $oidCacheKey = $objectIdentifier.$classType;
+ if (!isset($oidCache[$oidCacheKey])) {
+ $oidCache[$oidCacheKey] = $acl->getObjectIdentity();
}
- $result->attach($oidCache[$objectIdentifier.$classType], $acl);
+ $result->attach($oidCache[$oidCacheKey], $acl);
// so, this hasn't been hydrated yet
} else {
// create object identity if we haven't done so yet
@@ -668,7 +670,7 @@ QUERY;
// let's see if we have already hydrated this
if (isset($acls[$parentId])) {
$aclParentAclProperty->setValue($acl, $acls[$parentId]);
- $processed += 1;
+ ++$processed;
continue;
}
diff --git a/Tests/Acl/Dbal/AclProviderBenchmarkTest.php b/Tests/Acl/Dbal/AclProviderBenchmarkTest.php
index c25a697..1a46d27 100644
--- a/Tests/Acl/Dbal/AclProviderBenchmarkTest.php
+++ b/Tests/Acl/Dbal/AclProviderBenchmarkTest.php
@@ -122,7 +122,7 @@ class AclProviderBenchmarkTest extends \PHPUnit_Framework_TestCase
if ($id === 1000 || ($id < 1500 && rand(0, 1))) {
$this->insertClassStmt->execute(array($id, $this->getRandomString(rand(20, 100), 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\\_')));
- $id += 1;
+ ++$id;
return $id-1;
} else {
@@ -148,7 +148,7 @@ class AclProviderBenchmarkTest extends \PHPUnit_Framework_TestCase
}
$this->generateAces($classId, $id);
- $id += 1;
+ ++$id;
return $id-1;
}
@@ -163,7 +163,7 @@ class AclProviderBenchmarkTest extends \PHPUnit_Framework_TestCase
$this->getRandomString(rand(5, 30)),
rand(0, 1),
));
- $id += 1;
+ ++$id;
return $id-1;
} else {
@@ -215,7 +215,7 @@ class AclProviderBenchmarkTest extends \PHPUnit_Framework_TestCase
rand(0, 1),
));
- $id += 1;
+ ++$id;
}
}
diff --git a/Tests/Core/Util/SecureRandomTest.php b/Tests/Core/Util/SecureRandomTest.php
index bd9fec5..a8cc660 100644
--- a/Tests/Core/Util/SecureRandomTest.php
+++ b/Tests/Core/Util/SecureRandomTest.php
@@ -41,7 +41,7 @@ class SecureRandomTest extends \PHPUnit_Framework_TestCase
for ($j = 1; $j <= 5000; $j++) {
$k = 4 * $j - 1;
- $c[8 * $b[$k - 3] + 4 * $b[$k - 2] + 2 * $b[$k - 1] + $b[$k]] += 1;
+ ++$c[8 * $b[$k - 3] + 4 * $b[$k - 2] + 2 * $b[$k - 1] + $b[$k]];
}
$f = 0;
@@ -73,14 +73,14 @@ class SecureRandomTest extends \PHPUnit_Framework_TestCase
$run = 6;
}
- $runs[$run] += 1;
+ ++$runs[$run];
};
$currentRun = 0;
$lastBit = null;
for ($i = 0; $i < 20000; $i++) {
if ($lastBit === $b[$i]) {
- $currentRun += 1;
+ ++$currentRun;
} else {
if ($currentRun > 0) {
$addRun($currentRun);
@@ -115,7 +115,7 @@ class SecureRandomTest extends \PHPUnit_Framework_TestCase
$lastBit = null;
for ($i = 0; $i < 20000; $i++) {
if ($lastBit === $b[$i]) {
- $currentRun += 1;
+ ++$currentRun;
} else {
if ($currentRun > $longestRun) {
$longestRun = $currentRun;
diff --git a/Tests/Http/Firewall/ExceptionListenerTest.php b/Tests/Http/Firewall/ExceptionListenerTest.php
index b1c7622..12f18a6 100644
--- a/Tests/Http/Firewall/ExceptionListenerTest.php
+++ b/Tests/Http/Firewall/ExceptionListenerTest.php
@@ -177,9 +177,9 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
private function createExceptionListener(SecurityContextInterface $context = null, AuthenticationTrustResolverInterface $trustResolver = null, HttpUtils $httpUtils = null, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null)
{
return new ExceptionListener(
- $context ? $context : $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'),
- $trustResolver ? $trustResolver : $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface'),
- $httpUtils ? $httpUtils : $this->getMock('Symfony\Component\Security\Http\HttpUtils'),
+ $context ?: $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'),
+ $trustResolver ?: $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface'),
+ $httpUtils ?: $this->getMock('Symfony\Component\Security\Http\HttpUtils'),
'key',
$authenticationEntryPoint,
$errorPage,