Skip to content

Commit bb32aca

Browse files
authored
Bump dev dependencies, bump to PHP 8.3 (#11)
* add few phpstan extensions * Bump to PHP 8.3 * kiss ci
1 parent d73a34a commit bb32aca

19 files changed

+66
-121
lines changed

.github/workflows/code_analysis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040

4141
- uses: shivammathur/setup-php@v2
4242
with:
43-
php-version: 8.2
43+
php-version: 8.3
4444
coverage: none
4545

4646
# composer install cache - https://github.com/ramsey/composer-install

.github/workflows/downgraded_release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
-
1717
uses: "shivammathur/setup-php@v2"
1818
with:
19-
php-version: 8.2
19+
php-version: 8.3
2020
coverage: none
2121

2222
- uses: "ramsey/composer-install@v2"

.github/workflows/rector.yaml

Lines changed: 0 additions & 47 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ How to keep **cognitive complexity on 1**? Read [Keep Cognitive Complexity Low w
3737
composer require tomasvotruba/cognitive-complexity --dev
3838
```
3939

40-
The package is available on PHP 7.4-8.1 versions in tagged releases.
40+
The package is available on PHP 7.4+.
4141

4242
<br>
4343

@@ -47,7 +47,7 @@ With [PHPStan extension installer](https://github.com/phpstan/extension-installe
4747

4848
Enable each item on their own with simple configuration:
4949

50-
```neon
50+
```yaml
5151
# phpstan.neon
5252
parameters:
5353
cognitive_complexity:
@@ -68,7 +68,7 @@ That's why there is a rule to detect these dependency trees. It checks:
6868
6969
Final number is compared and used as a final complexity:
7070
71-
```neon
71+
```yaml
7272
# phpstan.neon
7373
parameters:
7474
cognitive_complexity:

composer.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@
44
"description": "PHPStan rules to measure cognitive complexity of your classes and methods",
55
"license": "MIT",
66
"require": {
7-
"php": "^8.2",
7+
"php": "^8.3",
88
"phpstan/phpstan": "^2.0",
9-
"nikic/php-parser": "^5"
9+
"nikic/php-parser": "^5.3"
1010
},
1111
"require-dev": {
12-
"phpstan/extension-installer": "^1.3",
13-
"phpunit/phpunit": "^10.3",
14-
"symplify/easy-coding-standard": "^12.0",
15-
"rector/rector": "^2",
16-
"tracy/tracy": "^2.9",
17-
"php-parallel-lint/php-parallel-lint": "^1.3"
12+
"phpstan/extension-installer": "^1.4",
13+
"phpstan/phpstan-deprecation-rules": "^2.0",
14+
"phpunit/phpunit": "^11.5",
15+
"symplify/easy-coding-standard": "^12.5",
16+
"rector/rector": "^2.0",
17+
"tracy/tracy": "^2.10",
18+
"php-parallel-lint/php-parallel-lint": "^1.4",
19+
"tomasvotruba/type-coverage": "^2.0",
20+
"tomasvotruba/unused-public": "^2.0"
1821
},
1922
"autoload": {
2023
"psr-4": {

ecs.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,7 @@
33
declare(strict_types=1);
44

55
use Symplify\EasyCodingStandard\Config\ECSConfig;
6-
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
76

8-
return static function (ECSConfig $ecsConfig): void {
9-
$ecsConfig->paths([__DIR__ . '/src', __DIR__ . '/tests']);
10-
11-
$ecsConfig->sets([
12-
SetList::COMMON,
13-
SetList::PSR_12,
14-
SetList::CLEAN_CODE,
15-
SetList::SYMPLIFY,
16-
]);
17-
};
7+
return ECSConfig::configure()
8+
->withPaths([__DIR__ . '/src', __DIR__ . '/tests'])
9+
->withPreparedSets(common: true, psr12: true, cleanCode: true, symplify: true);

phpstan.neon

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ parameters:
77
class: 50
88
function: 8
99

10+
unused_public:
11+
methods: true
12+
properties: true
13+
constants: true
14+
1015
level: 8
1116

1217
paths:
@@ -22,3 +27,6 @@ parameters:
2227

2328
# skip as always string
2429
- '#Parameter \#1 \$currentWorkingDirectory of class PHPStan\\DependencyInjection\\ContainerFactory constructor expects string, string\|false given#'
30+
31+
# used in tests
32+
- '#Public constant "TomasVotruba\\CognitiveComplexity\\Rules\\(.*?)::ERROR_MESSAGE" is never used#'

rector.php

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,13 @@
33
declare(strict_types=1);
44

55
use Rector\Config\RectorConfig;
6-
use Rector\Set\ValueObject\LevelSetList;
7-
use Rector\Set\ValueObject\SetList;
86

9-
return static function (RectorConfig $rectorConfig): void {
10-
$rectorConfig->paths([
11-
__DIR__ . '/src',
12-
__DIR__ . '/tests',
13-
]);
14-
15-
$rectorConfig->importNames();
16-
17-
$rectorConfig->sets([
18-
\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_100,
19-
LevelSetList::UP_TO_PHP_82,
20-
SetList::TYPE_DECLARATION,
21-
SetList::PRIVATIZATION,
22-
SetList::NAMING,
23-
SetList::DEAD_CODE,
24-
SetList::CODE_QUALITY,
25-
SetList::CODING_STYLE,
26-
]);
27-
28-
$rectorConfig->skip([
7+
return RectorConfig::configure()
8+
->withPaths([__DIR__ . '/src', __DIR__ . '/tests'])
9+
->withImportNames()
10+
->withPhpSets()
11+
->withPreparedSets(typeDeclarations: true, privatization: true, naming: true, deadCode: true, codeQuality: true, codingStyle: true)
12+
->withSkip([
2913
'*/Fixture/*',
3014
'*/Source/*',
3115
]);
32-
};

src/ClassReflectionParser.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ public function parse(ClassReflection $classReflection): ?Class_
3939
return null;
4040
}
4141

42-
$foundClass = $this->nodeFinder->findFirstInstanceOf($stmts, Class_::class);
43-
if (! $foundClass instanceof Class_) {
44-
return null;
45-
}
46-
47-
return $foundClass;
42+
return $this->nodeFinder->findFirstInstanceOf($stmts, Class_::class);
4843
}
4944
}

src/Enum/RuleIdentifier.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace TomasVotruba\CognitiveComplexity\Enum;
6+
7+
final class RuleIdentifier
8+
{
9+
public const string DEPENDENCY_TREE = 'complexity.dependencyTree';
10+
11+
public const string FUNCTION_COMPLEXITY = 'complexity.functionLike';
12+
13+
public const string CLASS_LIKE_COMPLEXITY = 'complexity.classLike';
14+
}

0 commit comments

Comments
 (0)