summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2015-05-15 15:28:34 +0200
committerFabien Potencier <fabien.potencier@gmail.com>2015-05-15 15:28:34 +0200
commitc29b2f6d4618d6366d6e5fb3770169c7e1773bf3 (patch)
tree0590e954cc2ecc984a70105855fb319701239122
parentffa3efde95d20fb8840f47c26de3bbc6425e1277 (diff)
parent9278dfa5dd6dfbcda01e947459b34fdd0e2e68bb (diff)
downloadsymfony-security-c29b2f6d4618d6366d6e5fb3770169c7e1773bf3.zip
symfony-security-c29b2f6d4618d6366d6e5fb3770169c7e1773bf3.tar.gz
symfony-security-c29b2f6d4618d6366d6e5fb3770169c7e1773bf3.tar.bz2
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: https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/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
-rw-r--r--Acl/Dbal/AclProvider.php8
-rw-r--r--Acl/Dbal/MutableAclProvider.php12
-rw-r--r--Acl/Domain/Acl.php8
-rw-r--r--Acl/Permission/MaskBuilder.php2
-rw-r--r--Core/Encoder/MessageDigestPasswordEncoder.php2
-rw-r--r--Core/Encoder/Pbkdf2PasswordEncoder.php4
-rw-r--r--Core/Util/StringUtils.php2
-rw-r--r--Http/RememberMe/TokenBasedRememberMeServices.php2
-rw-r--r--Tests/Acl/Dbal/AclProviderBenchmarkTest.php8
-rw-r--r--Tests/Acl/Dbal/AclProviderTest.php2
-rw-r--r--Tests/Acl/Domain/DoctrineAclCacheTest.php2
-rw-r--r--Tests/Core/Authorization/AccessDecisionManagerTest.php6
-rw-r--r--Tests/Core/Encoder/BCryptPasswordEncoderTest.php2
-rw-r--r--Tests/Core/Util/SecureRandomTest.php14
14 files changed, 37 insertions, 37 deletions
diff --git a/Acl/Dbal/AclProvider.php b/Acl/Dbal/AclProvider.php
index 750a304..7c512ad 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;
@@ -280,7 +280,7 @@ SELECTCLAUSE;
$types = array();
$count = count($batch);
- for ($i = 0; $i < $count; $i++) {
+ for ($i = 0; $i < $count; ++$i) {
if (!isset($types[$batch[$i]->getType()])) {
$types[$batch[$i]->getType()] = true;
@@ -295,7 +295,7 @@ SELECTCLAUSE;
if (1 === count($types)) {
$ids = array();
- for ($i = 0; $i < $count; $i++) {
+ for ($i = 0; $i < $count; ++$i) {
$ids[] = $this->connection->quote($batch[$i]->getIdentifier());
}
@@ -306,7 +306,7 @@ SELECTCLAUSE;
);
} else {
$where = '(o.object_identifier = %s AND c.class_type = %s)';
- for ($i = 0; $i < $count; $i++) {
+ for ($i = 0; $i < $count; ++$i) {
$sql .= sprintf(
$where,
$this->connection->quote($batch[$i]->getIdentifier()),
diff --git a/Acl/Dbal/MutableAclProvider.php b/Acl/Dbal/MutableAclProvider.php
index 74f52ce..30772b4 100644
--- a/Acl/Dbal/MutableAclProvider.php
+++ b/Acl/Dbal/MutableAclProvider.php
@@ -786,7 +786,7 @@ QUERY;
$sids = new \SplObjectStorage();
$classIds = new \SplObjectStorage();
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()) {
@@ -827,7 +827,7 @@ QUERY;
{
$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()) {
@@ -837,7 +837,7 @@ QUERY;
}
foreach ($changes[0] as $old) {
- for ($i = 0, $c = count($old); $i < $c; $i++) {
+ for ($i = 0, $c = count($old); $i < $c; ++$i) {
$ace = $old[$i];
if (!isset($currentIds[$ace->getId()])) {
@@ -860,7 +860,7 @@ QUERY;
$sids = new \SplObjectStorage();
$classIds = new \SplObjectStorage();
- 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()) {
@@ -901,7 +901,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()) {
@@ -909,7 +909,7 @@ QUERY;
}
}
- for ($i = 0, $c = count($old); $i < $c; $i++) {
+ for ($i = 0, $c = count($old); $i < $c; ++$i) {
$ace = $old[$i];
if (!isset($currentIds[$ace->getId()])) {
diff --git a/Acl/Domain/Acl.php b/Acl/Domain/Acl.php
index 63a58c7..365fc37 100644
--- a/Acl/Domain/Acl.php
+++ b/Acl/Domain/Acl.php
@@ -415,7 +415,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);
}
}
@@ -441,7 +441,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);
}
}
@@ -486,7 +486,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);
}
}
@@ -544,7 +544,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);
}
}
diff --git a/Acl/Permission/MaskBuilder.php b/Acl/Permission/MaskBuilder.php
index c45e2f9..45d89aa 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/Core/Encoder/MessageDigestPasswordEncoder.php b/Core/Encoder/MessageDigestPasswordEncoder.php
index 03de228..1706fc8 100644
--- a/Core/Encoder/MessageDigestPasswordEncoder.php
+++ b/Core/Encoder/MessageDigestPasswordEncoder.php
@@ -55,7 +55,7 @@ class MessageDigestPasswordEncoder extends BasePasswordEncoder
$digest = hash($this->algorithm, $salted, true);
// "stretch" hash
- for ($i = 1; $i < $this->iterations; $i++) {
+ for ($i = 1; $i < $this->iterations; ++$i) {
$digest = hash($this->algorithm, $digest.$salted, true);
}
diff --git a/Core/Encoder/Pbkdf2PasswordEncoder.php b/Core/Encoder/Pbkdf2PasswordEncoder.php
index dac1cad..6f24c4f 100644
--- a/Core/Encoder/Pbkdf2PasswordEncoder.php
+++ b/Core/Encoder/Pbkdf2PasswordEncoder.php
@@ -87,11 +87,11 @@ class Pbkdf2PasswordEncoder extends BasePasswordEncoder
$blocks = ceil($length / strlen(hash($algorithm, null, true)));
$digest = '';
- for ($i = 1; $i <= $blocks; $i++) {
+ for ($i = 1; $i <= $blocks; ++$i) {
$ib = $block = hash_hmac($algorithm, $salt.pack('N', $i), $password, true);
// Iterations
- for ($j = 1; $j < $iterations; $j++) {
+ for ($j = 1; $j < $iterations; ++$j) {
$ib ^= ($block = hash_hmac($algorithm, $block, $password, true));
}
diff --git a/Core/Util/StringUtils.php b/Core/Util/StringUtils.php
index e68347f..343585c 100644
--- a/Core/Util/StringUtils.php
+++ b/Core/Util/StringUtils.php
@@ -60,7 +60,7 @@ class StringUtils
$result = 0;
- for ($i = 0; $i < $knownLen; $i++) {
+ for ($i = 0; $i < $knownLen; ++$i) {
$result |= (ord($knownString[$i]) ^ ord($userInput[$i]));
}
diff --git a/Http/RememberMe/TokenBasedRememberMeServices.php b/Http/RememberMe/TokenBasedRememberMeServices.php
index 8283a7c..3d2cf12 100644
--- a/Http/RememberMe/TokenBasedRememberMeServices.php
+++ b/Http/RememberMe/TokenBasedRememberMeServices.php
@@ -82,7 +82,7 @@ class TokenBasedRememberMeServices extends AbstractRememberMeServices
}
$result = 0;
- for ($i = 0; $i < $c; $i++) {
+ for ($i = 0; $i < $c; ++$i) {
$result |= ord($hash1[$i]) ^ ord($hash2[$i]);
}
diff --git a/Tests/Acl/Dbal/AclProviderBenchmarkTest.php b/Tests/Acl/Dbal/AclProviderBenchmarkTest.php
index 2657001..0c35475 100644
--- a/Tests/Acl/Dbal/AclProviderBenchmarkTest.php
+++ b/Tests/Acl/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) {
@@ -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 {
@@ -226,7 +226,7 @@ class AclProviderBenchmarkTest extends \PHPUnit_Framework_TestCase
while ($i <= 30) {
$mask |= 1 << rand(0, 30);
- $i++;
+ ++$i;
}
return $mask;
diff --git a/Tests/Acl/Dbal/AclProviderTest.php b/Tests/Acl/Dbal/AclProviderTest.php
index d701e22..ecd53db 100644
--- a/Tests/Acl/Dbal/AclProviderTest.php
+++ b/Tests/Acl/Dbal/AclProviderTest.php
@@ -130,7 +130,7 @@ class AclProviderTest extends \PHPUnit_Framework_TestCase
$i = 0;
foreach ($aces as $index => $ace) {
$this->assertEquals($i, $index);
- $i++;
+ ++$i;
}
$sid = $aces[0]->getSecurityIdentity();
diff --git a/Tests/Acl/Domain/DoctrineAclCacheTest.php b/Tests/Acl/Domain/DoctrineAclCacheTest.php
index 93c87c1..54f932d 100644
--- a/Tests/Acl/Domain/DoctrineAclCacheTest.php
+++ b/Tests/Acl/Domain/DoctrineAclCacheTest.php
@@ -72,7 +72,7 @@ class DoctrineAclCacheTest extends \PHPUnit_Framework_TestCase
$acl->insertClassFieldAce('foo', $sid, 1);
$acl->insertObjectAce($sid, 1);
$acl->insertObjectFieldAce('foo', $sid, 1);
- $id++;
+ ++$id;
if ($depth > 0) {
$acl->setParentAcl($this->getAcl($depth - 1));
diff --git a/Tests/Core/Authorization/AccessDecisionManagerTest.php b/Tests/Core/Authorization/AccessDecisionManagerTest.php
index cbb39c4..b416e95 100644
--- a/Tests/Core/Authorization/AccessDecisionManagerTest.php
+++ b/Tests/Core/Authorization/AccessDecisionManagerTest.php
@@ -145,13 +145,13 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
protected function getVoters($grants, $denies, $abstains)
{
$voters = array();
- for ($i = 0; $i < $grants; $i++) {
+ for ($i = 0; $i < $grants; ++$i) {
$voters[] = $this->getVoter(VoterInterface::ACCESS_GRANTED);
}
- for ($i = 0; $i < $denies; $i++) {
+ for ($i = 0; $i < $denies; ++$i) {
$voters[] = $this->getVoter(VoterInterface::ACCESS_DENIED);
}
- for ($i = 0; $i < $abstains; $i++) {
+ for ($i = 0; $i < $abstains; ++$i) {
$voters[] = $this->getVoter(VoterInterface::ACCESS_ABSTAIN);
}
diff --git a/Tests/Core/Encoder/BCryptPasswordEncoderTest.php b/Tests/Core/Encoder/BCryptPasswordEncoderTest.php
index 61e2afe..3f8ba86 100644
--- a/Tests/Core/Encoder/BCryptPasswordEncoderTest.php
+++ b/Tests/Core/Encoder/BCryptPasswordEncoderTest.php
@@ -40,7 +40,7 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase
public function testCostInRange()
{
- for ($cost = 4; $cost <= 31; $cost++) {
+ for ($cost = 4; $cost <= 31; ++$cost) {
new BCryptPasswordEncoder($cost);
}
}
diff --git a/Tests/Core/Util/SecureRandomTest.php b/Tests/Core/Util/SecureRandomTest.php
index 316b049..9fd1c16 100644
--- a/Tests/Core/Util/SecureRandomTest.php
+++ b/Tests/Core/Util/SecureRandomTest.php
@@ -35,17 +35,17 @@ class SecureRandomTest extends \PHPUnit_Framework_TestCase
{
$b = $this->getBitSequence($secureRandom, 20000);
$c = array();
- for ($i = 0; $i <= 15; $i++) {
+ for ($i = 0; $i <= 15; ++$i) {
$c[$i] = 0;
}
- for ($j = 1; $j <= 5000; $j++) {
+ 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]];
}
$f = 0;
- for ($i = 0; $i <= 15; $i++) {
+ for ($i = 0; $i <= 15; ++$i) {
$f += $c[$i] * $c[$i];
}
@@ -64,7 +64,7 @@ class SecureRandomTest extends \PHPUnit_Framework_TestCase
$b = $this->getBitSequence($secureRandom, 20000);
$runs = array();
- for ($i = 1; $i <= 6; $i++) {
+ for ($i = 1; $i <= 6; ++$i) {
$runs[$i] = 0;
}
@@ -78,7 +78,7 @@ class SecureRandomTest extends \PHPUnit_Framework_TestCase
$currentRun = 0;
$lastBit = null;
- for ($i = 0; $i < 20000; $i++) {
+ for ($i = 0; $i < 20000; ++$i) {
if ($lastBit === $b[$i]) {
++$currentRun;
} else {
@@ -113,7 +113,7 @@ class SecureRandomTest extends \PHPUnit_Framework_TestCase
$longestRun = $currentRun = 0;
$lastBit = null;
- for ($i = 0; $i < 20000; $i++) {
+ for ($i = 0; $i < 20000; ++$i) {
if ($lastBit === $b[$i]) {
++$currentRun;
} else {
@@ -142,7 +142,7 @@ class SecureRandomTest extends \PHPUnit_Framework_TestCase
$b = $this->getBitSequence($secureRandom, 20000);
$Z = 0;
- for ($i = 0; $i < 5000; $i++) {
+ for ($i = 0; $i < 5000; ++$i) {
$Z += $b[$i] === $b[$i + $shift] ? 1 : 0;
}