Browse Source

minor #1453 remove calling array_keys in foreach loops (keradus)

This PR was merged into the 1.11 branch.

Discussion
----------

remove calling array_keys in foreach loops

Commits
-------

01239e8 remove calling array_keys in foreach loops
Dariusz Ruminski 9 years ago
parent
commit
1c67c1d5b4

+ 1 - 1
Symfony/CS/Fixer/Contrib/Php4ConstructorFixer.php

@@ -158,7 +158,7 @@ class Php4ConstructorFixer extends AbstractFixer
     private function fixParent(Tokens $tokens, $classStart, $classEnd)
     {
         // check calls to the parent constructor
-        foreach (array_keys($tokens->findGivenKind(T_EXTENDS)) as $index) {
+        foreach ($tokens->findGivenKind(T_EXTENDS) as $index => $token) {
             $parentIndex = $tokens->getNextMeaningfulToken($index);
             $parentClass = $tokens[$parentIndex]->getContent();
 

+ 1 - 1
Symfony/CS/Fixer/Symfony/DoubleArrowMultilineWhitespacesFixer.php

@@ -29,7 +29,7 @@ class DoubleArrowMultilineWhitespacesFixer extends AbstractFixer
     {
         $tokens = Tokens::fromCode($content);
 
-        foreach (array_keys($tokens->findGivenKind(T_DOUBLE_ARROW)) as $index) {
+        foreach ($tokens->findGivenKind(T_DOUBLE_ARROW) as $index => $token) {
             $this->fixWhitespace($tokens[$index - 1]);
             // do not move anything about if there is a comment following the whitespace
             if (!$tokens[$index + 2]->isComment()) {

+ 1 - 1
Symfony/CS/Fixer/Symfony/EmptyReturnFixer.php

@@ -26,7 +26,7 @@ class EmptyReturnFixer extends AbstractFixer
     {
         $tokens = Tokens::fromCode($content);
 
-        foreach (array_keys($tokens->findGivenKind(T_RETURN)) as $index) {
+        foreach ($tokens->findGivenKind(T_RETURN) as $index => $token) {
             if ($this->needFixing($tokens, $index)) {
                 $this->clear($tokens, $index);
             }

+ 1 - 1
Symfony/CS/Fixer/Symfony/IncludeFixer.php

@@ -87,7 +87,7 @@ class IncludeFixer extends AbstractFixer
         $includies = array();
 
         foreach ($tokens->findGivenKind($includyTokenKinds) as $includyTokens) {
-            foreach (array_keys($includyTokens) as $index) {
+            foreach ($includyTokens as $index => $token) {
                 $includy = array(
                     'begin' => $index,
                     'braces' => null,

+ 1 - 1
Symfony/CS/Fixer/Symfony/NoEmptyLinesAfterPhpdocsFixer.php

@@ -39,7 +39,7 @@ class NoEmptyLinesAfterPhpdocsFixer extends AbstractFixer
 
         $tokens = Tokens::fromCode($content);
 
-        foreach (array_keys($tokens->findGivenKind(T_DOC_COMMENT)) as $index) {
+        foreach ($tokens->findGivenKind(T_DOC_COMMENT) as $index => $token) {
             // get the next non-whitespace token inc comments, provided
             // that there is whitespace between it and the current token
             $next = $tokens->getNextNonWhitespace($index);

+ 1 - 1
Symfony/CS/Fixer/Symfony/ObjectOperatorFixer.php

@@ -28,7 +28,7 @@ class ObjectOperatorFixer extends AbstractFixer
         // [Structure] there should not be space before or after T_OBJECT_OPERATOR
         $tokens = Tokens::fromCode($content);
 
-        foreach (array_keys($tokens->findGivenKind(T_OBJECT_OPERATOR)) as $index) {
+        foreach ($tokens->findGivenKind(T_OBJECT_OPERATOR) as $index => $token) {
             // clear whitespace before ->
             if ($tokens[$index - 1]->isWhitespace(array('whitespaces' => " \t")) && !$tokens[$index - 2]->isComment()) {
                 $tokens[$index - 1]->clear();

+ 1 - 1
Symfony/CS/Fixer/Symfony/PhpdocSeparationFixer.php

@@ -29,7 +29,7 @@ class PhpdocSeparationFixer extends AbstractFixer
     {
         $tokens = Tokens::fromCode($content);
 
-        foreach ($tokens->findGivenKind(T_DOC_COMMENT) as $token) {
+        foreach ($tokens->findGivenKind(T_DOC_COMMENT) as $index => $token) {
             $doc = new DocBlock($token->getContent());
             $this->fixDescription($doc);
             $this->fixAnnotations($doc);

+ 1 - 1
Symfony/CS/Fixer/Symfony/UnusedUseFixer.php

@@ -72,7 +72,7 @@ class UnusedUseFixer extends AbstractFixer
     {
         $usages = array();
 
-        foreach (array_keys($useDeclarations) as $shortName) {
+        foreach ($useDeclarations as $shortName => $useDeclaration) {
             $usages[$shortName] = (bool) preg_match('/(?<![\$\\\\])\b'.preg_quote($shortName).'\b/i', $content);
         }
 

+ 1 - 1
Symfony/CS/Tokenizer/Transformer/CurlyClose.php

@@ -26,7 +26,7 @@ class CurlyClose extends AbstractTransformer
      */
     public function process(Tokens $tokens)
     {
-        foreach (array_keys($tokens->findGivenKind(T_CURLY_OPEN)) as $index) {
+        foreach ($tokens->findGivenKind(T_CURLY_OPEN) as $index => $token) {
             $level = 1;
             $nestIndex = $index;
 

+ 1 - 1
Symfony/CS/Tokenizer/Transformer/DollarCloseCurlyBraces.php

@@ -26,7 +26,7 @@ class DollarCloseCurlyBraces extends AbstractTransformer
      */
     public function process(Tokens $tokens)
     {
-        foreach (array_keys($tokens->findGivenKind(T_DOLLAR_OPEN_CURLY_BRACES)) as $index) {
+        foreach ($tokens->findGivenKind(T_DOLLAR_OPEN_CURLY_BRACES) as $index => $token) {
             $nextIndex = $tokens->getNextTokenOfKind($index, array('}'));
             $tokens[$nextIndex]->override(array(CT_DOLLAR_CLOSE_CURLY_BRACES, '}', $tokens[$nextIndex]->getLine()));
         }

Some files were not shown because too many files changed in this diff