Skip to content

Commit bb34f2f

Browse files
committed
fix - invalid align inside match - #87
1 parent 00e644f commit bb34f2f

File tree

4 files changed

+108
-2
lines changed

4 files changed

+108
-2
lines changed

fmt.stub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7247,6 +7247,7 @@ public function format($source) {
72477247

72487248
case ST_PARENTHESES_OPEN:
72497249
case ST_BRACKET_OPEN:
7250+
case ST_CURLY_OPEN:
72507251
++$levelCounter;
72517252
if (!isset($levelEntranceCounter[$levelCounter])) {
72527253
$levelEntranceCounter[$levelCounter] = 0;
@@ -7264,6 +7265,7 @@ public function format($source) {
72647265

72657266
case ST_PARENTHESES_CLOSE:
72667267
case ST_BRACKET_CLOSE:
7268+
case ST_CURLY_CLOSE:
72677269
--$levelCounter;
72687270
$this->appendCode($text);
72697271
break;

tests/Original/433-missing-space.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ enum Status: int {
99
public function getStr(): string {
1010
return match ($this) {
1111
self::public => 'a',
12-
self::foo => 'b',
13-
default => null,
12+
self::foo => 'b',
13+
default => null,
1414
};
1515
}
1616
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
//passes: AlignDoubleArrow
3+
4+
class TestManyTraits
5+
{
6+
use T1, T2, T3, T3;
7+
8+
private function foo($reason)
9+
{
10+
return match ($reason) {
11+
1 => 'ko_not_found',
12+
2 => 'ko_rejected_time',
13+
default => null
14+
};
15+
}
16+
}
17+
18+
class TestSomeTraits
19+
{
20+
use T1, T2;
21+
22+
private function foo($reason)
23+
{
24+
return match ($reason) {
25+
1 => 'ko_not_found',
26+
2 => 'ko_rejected_time',
27+
default => null
28+
};
29+
}
30+
}
31+
32+
class TestOneTrait
33+
{
34+
use T1;
35+
36+
private function foo($reason)
37+
{
38+
return match ($reason) {
39+
1 => 'ko_not_found',
40+
2 => 'ko_rejected_time',
41+
default => null
42+
};
43+
}
44+
}
45+
46+
class TestZeroTrait
47+
{
48+
private function foo($reason)
49+
{
50+
return match ($reason) {
51+
1 => 'ko_not_found',
52+
2 => 'ko_rejected_time',
53+
default => null
54+
};
55+
}
56+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
//passes: AlignDoubleArrow
3+
4+
class TestManyTraits {
5+
use T1, T2, T3, T3;
6+
7+
private function foo($reason) {
8+
return match ($reason) {
9+
1 => 'ko_not_found',
10+
2 => 'ko_rejected_time',
11+
default => null
12+
};
13+
}
14+
}
15+
16+
class TestSomeTraits {
17+
use T1, T2;
18+
19+
private function foo($reason) {
20+
return match ($reason) {
21+
1 => 'ko_not_found',
22+
2 => 'ko_rejected_time',
23+
default => null
24+
};
25+
}
26+
}
27+
28+
class TestOneTrait {
29+
use T1;
30+
31+
private function foo($reason) {
32+
return match ($reason) {
33+
1 => 'ko_not_found',
34+
2 => 'ko_rejected_time',
35+
default => null
36+
};
37+
}
38+
}
39+
40+
class TestZeroTrait {
41+
private function foo($reason) {
42+
return match ($reason) {
43+
1 => 'ko_not_found',
44+
2 => 'ko_rejected_time',
45+
default => null
46+
};
47+
}
48+
}

0 commit comments

Comments
 (0)