Skip to content

Commit

Permalink
Tokens - little DRY, use Token::equalsAny
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Sep 9, 2014
1 parent 32a4806 commit 71216d7
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions Symfony/CS/Tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -646,12 +646,10 @@ public function getTokenOfKindSibling($index, $direction, array $tokens = array(

$token = $this[$index];

foreach ($tokens as $tokenKind) {
if ($token->equals($tokenKind)) {
$foundIndex = $index;
if ($token->equalsAny($tokens)) {
$foundIndex = $index;

return $token;
}
return $token;
}
}
}
Expand All @@ -677,10 +675,8 @@ public function getTokenNotOfKindSibling($index, $direction, array $tokens = arr

$token = $this[$index];

foreach ($tokens as $tokenKind) {
if ($token->equals($tokenKind)) {
continue 2;
}
if ($token->equalsAny($tokens)) {
continue;
}

$foundIndex = $index;
Expand Down

0 comments on commit 71216d7

Please sign in to comment.