Skip to content

Commit 620a161

Browse files
epic-64William Raendchen
and
William Raendchen
authored
add T_MATCH to increments (Rarst#8)
Co-authored-by: William Raendchen <william.raendchen@easybell.de>
1 parent f9b257d commit 620a161

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"php": ">=7.2"
2323
},
2424
"require-dev": {
25-
"squizlabs/php_codesniffer": "^3.5",
25+
"squizlabs/php_codesniffer": "^3.6",
2626
"pds/skeleton" : "^1.0"
2727
},
2828
"suggest" : {

composer.lock

Lines changed: 9 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/CognitiveComplexity/Analyzer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ final class Analyzer
4040
T_WHILE => T_WHILE,
4141
T_DO => T_DO,
4242
T_CATCH => T_CATCH,
43+
T_MATCH => T_MATCH,
4344
];
4445

4546
/** @var int[]|string[] */

tests/AnalyzerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public function provideTokensAndExpectedCognitiveComplexity(): Iterator
5757
yield [__DIR__ . '/Data/function8.php.inc', 7];
5858
yield [__DIR__ . '/Data/function9.php.inc', 5];
5959
yield [__DIR__ . '/Data/function10.php.inc', 19];
60+
yield [__DIR__ . '/Data/function11.php.inc', 1];
6061
}
6162

6263
/**

tests/Data/function11.php.inc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
function getWords($number) {
4+
return match ($number) { // +1
5+
1 => "one",
6+
2 => "a couple",
7+
3 => "a few",
8+
default => "lots",
9+
};
10+
}
11+
12+
// Cognitive Complexity 1

0 commit comments

Comments
 (0)