Skip to content

Commit eb064ba

Browse files
committed
1 parent 05388ea commit eb064ba

5 files changed

Lines changed: 78 additions & 1 deletion

File tree

fmt.stub.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9113,7 +9113,10 @@ public function format($source)
91139113
}
91149114
} else
91159115
if ($this->rightUsefulTokenIs(T_VARIABLE) && $this->rightTokenIs([T_COMMENT, T_DOC_COMMENT])) {
9116-
$this->appendCode(ST_SEMI_COLON);
9116+
// Don't add semicolon after control structure parentheses
9117+
if (! in_array($lastParen, [T_IF, T_WHILE, T_FOR, T_FOREACH, T_ELSEIF, T_SWITCH])) {
9118+
$this->appendCode(ST_SEMI_COLON);
9119+
}
91179120
}
91189121
break;
91199122

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
//passes:AutoSemicolon
3+
// Issue 195: semicolon incorrectly added after if with inline comment
4+
if ($i) // comment
5+
$i = 0;
6+
7+
if ($x) /* block comment */
8+
$x = 1;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
//passes:AutoSemicolon
3+
// Issue 195: semicolon incorrectly added after if with inline comment
4+
if ($i) // comment
5+
{
6+
$i = 0;
7+
}
8+
9+
if ($x) /* block comment */
10+
{
11+
$x = 1;
12+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
// Issue 195: semicolon incorrectly added after if with inline comment
3+
if ($i) // comment
4+
$i = 0;
5+
6+
if ($x) /* block comment */
7+
$x = 1;
8+
9+
if ($a) // comment 1
10+
if ($b) // comment 2
11+
$b = 2;
12+
13+
while ($w) // comment
14+
$w = false;
15+
16+
for ($f = 0; $f < 10; $f++) // comment
17+
$f = $f;
18+
19+
foreach ($arr as $item) // comment
20+
$item = $item;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
// Issue 195: semicolon incorrectly added after if with inline comment
3+
if ($i) // comment
4+
{
5+
$i = 0;
6+
}
7+
8+
if ($x) /* block comment */
9+
{
10+
$x = 1;
11+
}
12+
13+
if ($a) // comment 1
14+
{
15+
if ($b) // comment 2
16+
{
17+
$b = 2;
18+
}
19+
}
20+
21+
while ($w) // comment
22+
{
23+
$w = false;
24+
}
25+
26+
for ($f = 0; $f < 10; $f++) // comment
27+
{
28+
$f = $f;
29+
}
30+
31+
foreach ($arr as $item) // comment
32+
{
33+
$item = $item;
34+
}

0 commit comments

Comments
 (0)