Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Jan 10, 2024
1 parent 414e64d commit 50f365b
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/Fixer/StringNotation/MultilineStringToHeredocFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,8 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
$inHeredoc = false;
$complexStringStartIndex = null;
foreach ($tokens as $index => $token) {
if ($inHeredoc) {
if ($token->isGivenKind(T_END_HEREDOC)) {
$inHeredoc = false;
}

continue;
}

if ($token->isGivenKind(T_START_HEREDOC)) {
$inHeredoc = true;
if ($token->isGivenKind([T_START_HEREDOC, T_END_HEREDOC])) {
$inHeredoc = $token->isGivenKind(T_START_HEREDOC) || !$token->isGivenKind(T_END_HEREDOC);

continue;
}
Expand Down Expand Up @@ -136,7 +128,8 @@ private function convertStringToHeredoc(Tokens $tokens, int $stringStartIndex, i
$closingMarker .= '_';
}

$heredocStartToken = new Token([T_START_HEREDOC, '<<<'.($isSingleQuoted ? '\'' : '').$closingMarker.($isSingleQuoted ? '\'' : '')."\n"]);
$quoting = $isSingleQuoted ? '\'' : '';
$heredocStartToken = new Token([T_START_HEREDOC, '<<<'.$quoting.$closingMarker.$quoting."\n"]);
$heredocEndToken = new Token([T_END_HEREDOC, $closingMarker]);

if (null !== $constantStringToken) {
Expand Down

0 comments on commit 50f365b

Please sign in to comment.