Skip to content

Commit c56aa8a

Browse files
authored
Merge pull request #28 from PcComponentes/bugfix/match-function
fix: Skip match function
2 parents c126410 + 6b89cbf commit c56aa8a

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

src/Sniffs/PHP/LineBreakBeforeOutflowSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ final class LineBreakBeforeOutflowSniff implements Sniff
2424
private const LINE_BREAKS_EXCEPTIONS = [
2525
T_OPEN_CURLY_BRACKET => 1,
2626
T_COLON => 1,
27+
T_MATCH_ARROW => 0,
2728
];
2829

2930
/**
@@ -92,8 +93,7 @@ private function getLineBreaksRequired(string $code): int
9293
{
9394
return true === array_key_exists($code, self::LINE_BREAKS_EXCEPTIONS)
9495
? self::LINE_BREAKS_EXCEPTIONS[$code]
95-
: self::DEFAULT_LINE_BREAKS
96-
;
96+
: self::DEFAULT_LINE_BREAKS;
9797
}
9898

9999
private function numberOfLineBreaks(array $tokens, int $start, int $finish): int

tests/Sniffs/ControlStructures/data/lineBreakBetweenFunctionsErrors.fixed.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ function ($value) {
3434
match ('hello') {
3535
'hello' => 'bye',
3636
'bye' => 'hello',
37-
default => null,
37+
default => throw new \Exception('hello'),
3838
};

tests/Sniffs/ControlStructures/data/lineBreakBetweenFunctionsErrors.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ function ($value) {
3434
match ('hello') {
3535
'hello' => 'bye',
3636
'bye' => 'hello',
37-
default => null,
37+
default => throw new \Exception('hello'),
3838
};

tests/Sniffs/PHP/data/lineBreakBeforeOutflowErrors.fixed.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,9 @@
6060

6161
return 'default';
6262
}
63+
64+
match ('hello') {
65+
'hello' => 'bye',
66+
'bye' => 'hello',
67+
default => throw new \Exception('hello'),
68+
};

tests/Sniffs/PHP/data/lineBreakBeforeOutflowErrors.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,9 @@
6060
\strval($item);
6161
return 'default';
6262
}
63+
64+
match ('hello') {
65+
'hello' => 'bye',
66+
'bye' => 'hello',
67+
default => throw new \Exception('hello'),
68+
};

0 commit comments

Comments
 (0)