Skip to content

Commit 2913247

Browse files
committed
fix - problema formatting in php < 7.3
1 parent a356e4b commit 2913247

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

fmt.stub.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3538,7 +3538,7 @@ public function format($source) {
35383538
}
35393539

35403540
final class LeftAlignComment extends FormatterPass {
3541-
const NON_INDENTABLE_COMMENT = "/*\x2 COMMENT \x3*/";
3541+
const NON_INDENTABLE_COMMENT = "/*__PHPFMT_NON_INDENTABLE_COMMENT__*/";
35423542

35433543
public function candidate($source, $foundTokens) {
35443544
if (
@@ -3821,6 +3821,9 @@ public function format($source) {
38213821
case T_START_HEREDOC:
38223822
$this->appendCode($text);
38233823
$this->printUntil(T_END_HEREDOC);
3824+
if ($this->rightUsefulTokenIs(ST_SEMI_COLON)) {
3825+
$this->printUntil(ST_SEMI_COLON);
3826+
}
38243827
break;
38253828

38263829
case T_COMMENT:
@@ -4969,11 +4972,10 @@ public function format($source) {
49694972
break;
49704973
case T_START_HEREDOC:
49714974
$this->appendCode($text);
4972-
if (count($attributeStack)) {
4973-
$this->printUntil(T_END_HEREDOC);
4974-
} else {
4975-
$this->printUntil(T_END_HEREDOC);
4976-
}
4975+
$this->printUntil(T_END_HEREDOC);
4976+
if ($this->rightUsefulTokenIs(ST_SEMI_COLON)) {
4977+
$this->printUntil(ST_SEMI_COLON);
4978+
}
49774979
break;
49784980

49794981
case T_CALLABLE:

tests/Original/525-heredoc-or-die.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
//passes:AutoSemicolon
3+
//version:7.3
34
// Have a free MRE for both options. Run the formatter over this and both will break.
45
print_r(<<<SQL
56
SELECT *

tests/Original/525-heredoc-or-die.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
//passes:AutoSemicolon
3+
//version:7.3
34
// Have a free MRE for both options. Run the formatter over this and both will break.
45
print_r(<<<SQL
56
SELECT *

0 commit comments

Comments
 (0)