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

Commit c29b2f6

Browse files
committed
minor #14121 CS: Pre incrementation/decrementation should be used if possible (gharlan)
This PR was merged into the 2.3 branch. Discussion ---------- CS: Pre incrementation/decrementation should be used if possible | 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 Fixes provided by new fixer: PHP-CS-Fixer/PHP-CS-Fixer#1113 If this pr is merged I would change the level of the fixer to `symfony`. Commits ------- c5123d6 CS: Pre incrementation/decrementation should be used if possible
2 parents ffa3efd + 9278dfa commit c29b2f6

14 files changed

+37
-37
lines changed

Acl/Dbal/AclProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function findAcls(array $oids, array $sids = array())
104104
$currentBatch = array();
105105
$oidLookup = array();
106106

107-
for ($i = 0, $c = count($oids); $i < $c; $i++) {
107+
for ($i = 0, $c = count($oids); $i < $c; ++$i) {
108108
$oid = $oids[$i];
109109
$oidLookupKey = $oid->getIdentifier().$oid->getType();
110110
$oidLookup[$oidLookupKey] = $oid;
@@ -280,7 +280,7 @@ protected function getAncestorLookupSql(array $batch)
280280

281281
$types = array();
282282
$count = count($batch);
283-
for ($i = 0; $i < $count; $i++) {
283+
for ($i = 0; $i < $count; ++$i) {
284284
if (!isset($types[$batch[$i]->getType()])) {
285285
$types[$batch[$i]->getType()] = true;
286286

@@ -295,7 +295,7 @@ protected function getAncestorLookupSql(array $batch)
295295

296296
if (1 === count($types)) {
297297
$ids = array();
298-
for ($i = 0; $i < $count; $i++) {
298+
for ($i = 0; $i < $count; ++$i) {
299299
$ids[] = $this->connection->quote($batch[$i]->getIdentifier());
300300
}
301301

@@ -306,7 +306,7 @@ protected function getAncestorLookupSql(array $batch)
306306
);
307307
} else {
308308
$where = '(o.object_identifier = %s AND c.class_type = %s)';
309-
for ($i = 0; $i < $count; $i++) {
309+
for ($i = 0; $i < $count; ++$i) {
310310
$sql .= sprintf(
311311
$where,
312312
$this->connection->quote($batch[$i]->getIdentifier()),

Acl/Dbal/MutableAclProvider.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ private function updateNewFieldAceProperty($name, array $changes)
786786
$sids = new \SplObjectStorage();
787787
$classIds = new \SplObjectStorage();
788788
foreach ($changes[1] as $field => $new) {
789-
for ($i = 0, $c = count($new); $i < $c; $i++) {
789+
for ($i = 0, $c = count($new); $i < $c; ++$i) {
790790
$ace = $new[$i];
791791

792792
if (null === $ace->getId()) {
@@ -827,7 +827,7 @@ private function updateOldFieldAceProperty($name, array $changes)
827827
{
828828
$currentIds = array();
829829
foreach ($changes[1] as $field => $new) {
830-
for ($i = 0, $c = count($new); $i < $c; $i++) {
830+
for ($i = 0, $c = count($new); $i < $c; ++$i) {
831831
$ace = $new[$i];
832832

833833
if (null !== $ace->getId()) {
@@ -837,7 +837,7 @@ private function updateOldFieldAceProperty($name, array $changes)
837837
}
838838

839839
foreach ($changes[0] as $old) {
840-
for ($i = 0, $c = count($old); $i < $c; $i++) {
840+
for ($i = 0, $c = count($old); $i < $c; ++$i) {
841841
$ace = $old[$i];
842842

843843
if (!isset($currentIds[$ace->getId()])) {
@@ -860,7 +860,7 @@ private function updateNewAceProperty($name, array $changes)
860860

861861
$sids = new \SplObjectStorage();
862862
$classIds = new \SplObjectStorage();
863-
for ($i = 0, $c = count($new); $i < $c; $i++) {
863+
for ($i = 0, $c = count($new); $i < $c; ++$i) {
864864
$ace = $new[$i];
865865

866866
if (null === $ace->getId()) {
@@ -901,15 +901,15 @@ private function updateOldAceProperty($name, array $changes)
901901
list($old, $new) = $changes;
902902
$currentIds = array();
903903

904-
for ($i = 0, $c = count($new); $i < $c; $i++) {
904+
for ($i = 0, $c = count($new); $i < $c; ++$i) {
905905
$ace = $new[$i];
906906

907907
if (null !== $ace->getId()) {
908908
$currentIds[$ace->getId()] = true;
909909
}
910910
}
911911

912-
for ($i = 0, $c = count($old); $i < $c; $i++) {
912+
for ($i = 0, $c = count($old); $i < $c; ++$i) {
913913
$ace = $old[$i];
914914

915915
if (!isset($currentIds[$ace->getId()])) {

Acl/Domain/Acl.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ private function deleteAce($property, $index)
415415
$this->$property = array_values($this->$property);
416416
$this->onPropertyChanged($property, $oldValue, $this->$property);
417417

418-
for ($i = $index, $c = count($this->$property); $i < $c; $i++) {
418+
for ($i = $index, $c = count($this->$property); $i < $c; ++$i) {
419419
$this->onEntryPropertyChanged($aces[$i], 'aceOrder', $i + 1, $i);
420420
}
421421
}
@@ -441,7 +441,7 @@ private function deleteFieldAce($property, $index, $field)
441441
$aces[$field] = array_values($aces[$field]);
442442
$this->onPropertyChanged($property, $oldValue, $this->$property);
443443

444-
for ($i = $index, $c = count($aces[$field]); $i < $c; $i++) {
444+
for ($i = $index, $c = count($aces[$field]); $i < $c; ++$i) {
445445
$this->onEntryPropertyChanged($aces[$field][$i], 'aceOrder', $i + 1, $i);
446446
}
447447
}
@@ -486,7 +486,7 @@ private function insertAce($property, $index, $mask, SecurityIdentityInterface $
486486
array_slice($this->$property, $index)
487487
);
488488

489-
for ($i = $index, $c = count($this->$property) - 1; $i < $c; $i++) {
489+
for ($i = $index, $c = count($this->$property) - 1; $i < $c; ++$i) {
490490
$this->onEntryPropertyChanged($aces[$i + 1], 'aceOrder', $i, $i + 1);
491491
}
492492
}
@@ -544,7 +544,7 @@ private function insertFieldAce($property, $index, $field, $mask, SecurityIdenti
544544
array_slice($aces[$field], $index)
545545
);
546546

547-
for ($i = $index, $c = count($aces[$field]) - 1; $i < $c; $i++) {
547+
for ($i = $index, $c = count($aces[$field]) - 1; $i < $c; ++$i) {
548548
$this->onEntryPropertyChanged($aces[$field][$i + 1], 'aceOrder', $i, $i + 1);
549549
}
550550
}

Acl/Permission/MaskBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function getPattern()
128128
$length = strlen($pattern);
129129
$bitmask = str_pad(decbin($this->mask), $length, '0', STR_PAD_LEFT);
130130

131-
for ($i = $length - 1; $i >= 0; $i--) {
131+
for ($i = $length - 1; $i >= 0; --$i) {
132132
if ('1' === $bitmask[$i]) {
133133
try {
134134
$pattern[$i] = self::getCode(1 << ($length - $i - 1));

Core/Encoder/MessageDigestPasswordEncoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function encodePassword($raw, $salt)
5555
$digest = hash($this->algorithm, $salted, true);
5656

5757
// "stretch" hash
58-
for ($i = 1; $i < $this->iterations; $i++) {
58+
for ($i = 1; $i < $this->iterations; ++$i) {
5959
$digest = hash($this->algorithm, $digest.$salted, true);
6060
}
6161

Core/Encoder/Pbkdf2PasswordEncoder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ private function hashPbkdf2($algorithm, $password, $salt, $iterations, $length =
8787
$blocks = ceil($length / strlen(hash($algorithm, null, true)));
8888
$digest = '';
8989

90-
for ($i = 1; $i <= $blocks; $i++) {
90+
for ($i = 1; $i <= $blocks; ++$i) {
9191
$ib = $block = hash_hmac($algorithm, $salt.pack('N', $i), $password, true);
9292

9393
// Iterations
94-
for ($j = 1; $j < $iterations; $j++) {
94+
for ($j = 1; $j < $iterations; ++$j) {
9595
$ib ^= ($block = hash_hmac($algorithm, $block, $password, true));
9696
}
9797

Core/Util/StringUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static function equals($knownString, $userInput)
6060

6161
$result = 0;
6262

63-
for ($i = 0; $i < $knownLen; $i++) {
63+
for ($i = 0; $i < $knownLen; ++$i) {
6464
$result |= (ord($knownString[$i]) ^ ord($userInput[$i]));
6565
}
6666

Http/RememberMe/TokenBasedRememberMeServices.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private function compareHashes($hash1, $hash2)
8282
}
8383

8484
$result = 0;
85-
for ($i = 0; $i < $c; $i++) {
85+
for ($i = 0; $i < $c; ++$i) {
8686
$result |= ord($hash1[$i]) ^ ord($hash2[$i]);
8787
}
8888

Tests/Acl/Dbal/AclProviderBenchmarkTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function generateTestData()
9292
$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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
9393
$this->insertOidAncestorStmt = $this->con->prepare('INSERT INTO acl_object_identity_ancestors (object_identity_id, ancestor_id) VALUES (?, ?)');
9494

95-
for ($i = 0; $i < 40000; $i++) {
95+
for ($i = 0; $i < 40000; ++$i) {
9696
$this->generateAclHierarchy();
9797
}
9898
}
@@ -107,7 +107,7 @@ protected function generateAclHierarchy()
107107
protected function generateAclLevel($depth, $parentId, $ancestors)
108108
{
109109
$level = count($ancestors);
110-
for ($i = 0, $t = rand(1, 10); $i < $t; $i++) {
110+
for ($i = 0, $t = rand(1, 10); $i < $t; ++$i) {
111111
$id = $this->generateAcl($this->chooseClassId(), $parentId, $ancestors);
112112

113113
if ($level < $depth) {
@@ -178,7 +178,7 @@ protected function generateAces($classId, $objectId)
178178
$sids = array();
179179
$fieldOrder = array();
180180

181-
for ($i = 0; $i <= 30; $i++) {
181+
for ($i = 0; $i <= 30; ++$i) {
182182
$fieldName = rand(0, 1) ? null : $this->getRandomString(rand(10, 20));
183183

184184
do {
@@ -226,7 +226,7 @@ protected function generateMask()
226226

227227
while ($i <= 30) {
228228
$mask |= 1 << rand(0, 30);
229-
$i++;
229+
++$i;
230230
}
231231

232232
return $mask;

Tests/Acl/Dbal/AclProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function testFindAcl()
130130
$i = 0;
131131
foreach ($aces as $index => $ace) {
132132
$this->assertEquals($i, $index);
133-
$i++;
133+
++$i;
134134
}
135135

136136
$sid = $aces[0]->getSecurityIdentity();

0 commit comments

Comments
 (0)