Skip to content

Commit

Permalink
[PHP 7.4] Improve foreach tokens on new node (#1179)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba authored Nov 7, 2021
1 parent 9614997 commit 3c6a68b
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,10 @@ private function shouldSkip(LNumber | DNumber $node, string $numericValueAsStrin
$startToken = $node->getAttribute(AttributeKey::START_TOKEN_POSITION);

$oldTokens = $this->file->getOldTokens();
$tokenValue = $oldTokens[$startToken][1] ?? null;

foreach ($oldTokens[$startToken] as $token) {
if (! is_string($token)) {
continue;
}

if (! str_contains($token, '_')) {
continue;
}

// already contains separator
if (str_contains($tokenValue, '_')) {
return true;
}

Expand Down

0 comments on commit 3c6a68b

Please sign in to comment.