diff --git a/composer.json b/composer.json index 01354f6..58dcba8 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "php": ">=7.2" }, "require-dev": { - "squizlabs/php_codesniffer": "^3.5", + "squizlabs/php_codesniffer": "^3.6", "pds/skeleton" : "^1.0" }, "suggest" : { diff --git a/composer.lock b/composer.lock index 1fabb29..860f217 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6da86f7f146521b08db7b045a8c44936", + "content-hash": "85cef8eb74107402a5ec048fba3b7e57", "packages": [], "packages-dev": [ { @@ -44,16 +44,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.7.1", + "version": "3.7.2", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619" + "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", - "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", + "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", "shasum": "" }, "require": { @@ -89,14 +89,15 @@ "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", "keywords": [ "phpcs", - "standards" + "standards", + "static analysis" ], "support": { "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2022-06-18T07:21:10+00:00" + "time": "2023-02-22T23:07:41+00:00" } ], "aliases": [], @@ -111,5 +112,5 @@ "platform-overrides": { "php": "7.2" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.0.0" } diff --git a/src/CognitiveComplexity/Analyzer.php b/src/CognitiveComplexity/Analyzer.php index 9b0510f..41ded1a 100644 --- a/src/CognitiveComplexity/Analyzer.php +++ b/src/CognitiveComplexity/Analyzer.php @@ -40,6 +40,7 @@ final class Analyzer T_WHILE => T_WHILE, T_DO => T_DO, T_CATCH => T_CATCH, + T_MATCH => T_MATCH, ]; /** @var int[]|string[] */ diff --git a/tests/AnalyzerTest.php b/tests/AnalyzerTest.php index 3fa13a3..d635386 100644 --- a/tests/AnalyzerTest.php +++ b/tests/AnalyzerTest.php @@ -57,6 +57,7 @@ public function provideTokensAndExpectedCognitiveComplexity(): Iterator yield [__DIR__ . '/Data/function8.php.inc', 7]; yield [__DIR__ . '/Data/function9.php.inc', 5]; yield [__DIR__ . '/Data/function10.php.inc', 19]; + yield [__DIR__ . '/Data/function11.php.inc', 1]; } /** diff --git a/tests/Data/function11.php.inc b/tests/Data/function11.php.inc new file mode 100644 index 0000000..87f8149 --- /dev/null +++ b/tests/Data/function11.php.inc @@ -0,0 +1,12 @@ + "one", + 2 => "a couple", + 3 => "a few", + default => "lots", + }; +} + +// Cognitive Complexity 1