Skip to content

Commit 68c0f66

Browse files
committed
fix
1 parent 5bcd322 commit 68c0f66

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

rules-tests/DowngradePhp73/Rector/String_/DowngradeFlexibleHeredocSyntaxRector/Fixture/fixture.php.inc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,19 @@ class Fixture
3737
SELECT *
3838
FROM `table`
3939
WHERE `column` = true;
40-
SQL;
40+
SQL
41+
;
4142
$this->setOnClick(<<<SQL
4243
SELECT *
4344
FROM `table`
4445
WHERE `column` = true;
45-
SQL);
46+
SQL
47+
);
4648
$this->setOnClick(<<<JAVASCRIPT
4749
document.getElementById('{$this->getHtmlId()}').value = '';
4850
document.getElementById('{$this->getHtmlId()}').onchange();
49-
JAVASCRIPT);
51+
JAVASCRIPT
52+
);
5053
}
5154
}
5255

rules-tests/DowngradePhp73/Rector/String_/DowngradeFlexibleHeredocSyntaxRector/Fixture/line_ends_with_newline_or_semicolon.php.inc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ EOS
4646

4747
$needsDowngrade1 = sprintf(<<<EOS
4848
test %s
49-
EOS, 'more');
49+
EOS
50+
, 'more');
5051

5152
$needsDowngrade2 = <<<EOS
5253
test
53-
EOS; $z = '';
54+
EOS
55+
; $z = '';
5456
}
5557
}
5658

rules/DowngradePhp73/Rector/String_/DowngradeFlexibleHeredocSyntaxRector.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ public function refactor(Node $node): ?Node
8383
$node->setAttribute(AttributeKey::DOC_INDENTATION, '__REMOVED__');
8484
$node->setAttribute(AttributeKey::ORIGINAL_NODE, null);
8585

86+
$tokens = $this->file->getOldTokens();
87+
if (isset($tokens[$node->getEndTokenPos()], $tokens[$node->getEndTokenPos() + 1])) {
88+
$tokens[$node->getEndTokenPos() + 1]->text = "\n" . $tokens[$node->getEndTokenPos() + 1]->text;
89+
}
90+
8691
return $node;
8792
}
8893
}

0 commit comments

Comments
 (0)