Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit 9c25665

Browse files
committed
minor #13862 [2.3] [Config] [Console] [DependencyInjection] [DomCrawler] [Form] [HttpKernel] [PropertyAccess] [Security] [Translation] [Yaml] static code analysis, code cleanup (kalessil)
This PR was squashed before being merged into the 2.3 branch (closes #13862). Discussion ---------- [2.3] [Config] [Console] [DependencyInjection] [DomCrawler] [Form] [HttpKernel] [PropertyAccess] [Security] [Translation] [Yaml] static code analysis, code cleanup | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Split <a href="https://github.com/symfony/symfony/pull/13813">PR 13813</a>: part 1 - targeting v2.3 Following is included (no functional changes, found with <a href="https://plugins.jetbrains.com/plugin/7622?pr=phpStorm">Php Inspections (EA Extended)</a>): - Fixed couple of concatenation as array index warnings - Unset calls can be merged inspection fixes - array_search in in_array context inspection fixes - Is null usage inspection fixes - Prefixed increment/decrement inspection fixes - Elvis operator can be used inspection fixes - Alias functions usage inspection fixes - Ternary operator simplification inspection fixes - _ _ DIR _ _ equivalent inspection fixes Commits ------- f13b5f7 [2.3] [Config] [Console] [DependencyInjection] [DomCrawler] [Form] [HttpKernel] [PropertyAccess] [Security] [Translation] [Yaml] static code analysis, code cleanup
2 parents 89ef687 + 05fec30 commit 9c25665

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

Acl/Dbal/AclProvider.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ public function findAcls(array $oids, array $sids = array())
173173
}
174174

175175
// Is it time to load the current batch?
176-
if ((self::MAX_BATCH_SIZE === count($currentBatch) || ($i + 1) === $c) && count($currentBatch) > 0) {
176+
$currentBatchesCount = count($currentBatch);
177+
if ($currentBatchesCount > 0 && (self::MAX_BATCH_SIZE === $currentBatchesCount || ($i + 1) === $c)) {
177178
try {
178179
$loadedBatch = $this->lookupObjectIdentities($currentBatch, $sids, $oidLookup);
179180
} catch (AclNotFoundException $aclNotFoundexception) {
@@ -557,10 +558,11 @@ private function hydrateObjectIdentities(Statement $stmt, array $oidLookup, arra
557558
// attach ACL to the result set; even though we do not enforce that every
558559
// object identity has only one instance, we must make sure to maintain
559560
// referential equality with the oids passed to findAcls()
560-
if (!isset($oidCache[$objectIdentifier.$classType])) {
561-
$oidCache[$objectIdentifier.$classType] = $acl->getObjectIdentity();
561+
$oidCacheKey = $objectIdentifier.$classType;
562+
if (!isset($oidCache[$oidCacheKey])) {
563+
$oidCache[$oidCacheKey] = $acl->getObjectIdentity();
562564
}
563-
$result->attach($oidCache[$objectIdentifier.$classType], $acl);
565+
$result->attach($oidCache[$oidCacheKey], $acl);
564566
// so, this hasn't been hydrated yet
565567
} else {
566568
// create object identity if we haven't done so yet
@@ -668,7 +670,7 @@ private function hydrateObjectIdentities(Statement $stmt, array $oidLookup, arra
668670
// let's see if we have already hydrated this
669671
if (isset($acls[$parentId])) {
670672
$aclParentAclProperty->setValue($acl, $acls[$parentId]);
671-
$processed += 1;
673+
++$processed;
672674

673675
continue;
674676
}

Tests/Acl/Dbal/AclProviderBenchmarkTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ protected function chooseClassId()
122122

123123
if ($id === 1000 || ($id < 1500 && rand(0, 1))) {
124124
$this->insertClassStmt->execute(array($id, $this->getRandomString(rand(20, 100), 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\\_')));
125-
$id += 1;
125+
++$id;
126126

127127
return $id-1;
128128
} else {
@@ -148,7 +148,7 @@ protected function generateAcl($classId, $parentId, $ancestors)
148148
}
149149

150150
$this->generateAces($classId, $id);
151-
$id += 1;
151+
++$id;
152152

153153
return $id-1;
154154
}
@@ -163,7 +163,7 @@ protected function chooseSid()
163163
$this->getRandomString(rand(5, 30)),
164164
rand(0, 1),
165165
));
166-
$id += 1;
166+
++$id;
167167

168168
return $id-1;
169169
} else {
@@ -215,7 +215,7 @@ protected function generateAces($classId, $objectId)
215215
rand(0, 1),
216216
));
217217

218-
$id += 1;
218+
++$id;
219219
}
220220
}
221221

Tests/Core/Util/SecureRandomTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testPoker($secureRandom)
4141

4242
for ($j = 1; $j <= 5000; $j++) {
4343
$k = 4 * $j - 1;
44-
$c[8 * $b[$k - 3] + 4 * $b[$k - 2] + 2 * $b[$k - 1] + $b[$k]] += 1;
44+
++$c[8 * $b[$k - 3] + 4 * $b[$k - 2] + 2 * $b[$k - 1] + $b[$k]];
4545
}
4646

4747
$f = 0;
@@ -73,14 +73,14 @@ public function testRun($secureRandom)
7373
$run = 6;
7474
}
7575

76-
$runs[$run] += 1;
76+
++$runs[$run];
7777
};
7878

7979
$currentRun = 0;
8080
$lastBit = null;
8181
for ($i = 0; $i < 20000; $i++) {
8282
if ($lastBit === $b[$i]) {
83-
$currentRun += 1;
83+
++$currentRun;
8484
} else {
8585
if ($currentRun > 0) {
8686
$addRun($currentRun);
@@ -115,7 +115,7 @@ public function testLongRun($secureRandom)
115115
$lastBit = null;
116116
for ($i = 0; $i < 20000; $i++) {
117117
if ($lastBit === $b[$i]) {
118-
$currentRun += 1;
118+
++$currentRun;
119119
} else {
120120
if ($currentRun > $longestRun) {
121121
$longestRun = $currentRun;

Tests/Http/Firewall/ExceptionListenerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ private function createEvent(\Exception $exception, $kernel = null)
177177
private function createExceptionListener(SecurityContextInterface $context = null, AuthenticationTrustResolverInterface $trustResolver = null, HttpUtils $httpUtils = null, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null)
178178
{
179179
return new ExceptionListener(
180-
$context ? $context : $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'),
181-
$trustResolver ? $trustResolver : $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface'),
182-
$httpUtils ? $httpUtils : $this->getMock('Symfony\Component\Security\Http\HttpUtils'),
180+
$context ?: $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'),
181+
$trustResolver ?: $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface'),
182+
$httpUtils ?: $this->getMock('Symfony\Component\Security\Http\HttpUtils'),
183183
'key',
184184
$authenticationEntryPoint,
185185
$errorPage,

0 commit comments

Comments
 (0)