Skip to content

Commit 52b7dc7

Browse files
committed
apply rector
1 parent c91a146 commit 52b7dc7

File tree

7 files changed

+17
-14
lines changed

7 files changed

+17
-14
lines changed

src/AstCognitiveComplexityAnalyzer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
final class AstCognitiveComplexityAnalyzer
2020
{
2121
public function __construct(
22-
private ComplexityNodeTraverserFactory $complexityNodeTraverserFactory,
23-
private CognitiveComplexityDataCollector $cognitiveComplexityDataCollector,
24-
private NestingNodeVisitor $nestingNodeVisitor
22+
private readonly ComplexityNodeTraverserFactory $complexityNodeTraverserFactory,
23+
private readonly CognitiveComplexityDataCollector $cognitiveComplexityDataCollector,
24+
private readonly NestingNodeVisitor $nestingNodeVisitor
2525
) {
2626
}
2727

src/Exception/ShouldNotHappenException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace TomasVotruba\CognitiveComplexity\Exception;
66

7-
class ShouldNotHappenException extends \Exception
7+
use Exception;
8+
9+
final class ShouldNotHappenException extends Exception
810
{
911
}

src/NodeTraverser/ComplexityNodeTraverserFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
final class ComplexityNodeTraverserFactory
1212
{
1313
public function __construct(
14-
private NestingNodeVisitor $nestingNodeVisitor,
15-
private ComplexityNodeVisitor $complexityNodeVisitor
14+
private readonly NestingNodeVisitor $nestingNodeVisitor,
15+
private readonly ComplexityNodeVisitor $complexityNodeVisitor
1616
) {
1717
}
1818

src/NodeVisitor/ComplexityNodeVisitor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
final class ComplexityNodeVisitor extends NodeVisitorAbstract
1313
{
1414
public function __construct(
15-
private CognitiveComplexityDataCollector $cognitiveComplexityDataCollector,
16-
private ComplexityAffectingNodeFinder $complexityAffectingNodeFinder
15+
private readonly CognitiveComplexityDataCollector $cognitiveComplexityDataCollector,
16+
private readonly ComplexityAffectingNodeFinder $complexityAffectingNodeFinder
1717
) {
1818
}
1919

src/NodeVisitor/NestingNodeVisitor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ final class NestingNodeVisitor extends NodeVisitorAbstract
3838
private int $previousNestingLevel = 0;
3939

4040
public function __construct(
41-
private CognitiveComplexityDataCollector $cognitiveComplexityDataCollector,
42-
private ComplexityAffectingNodeFinder $complexityAffectingNodeFinder,
41+
private readonly CognitiveComplexityDataCollector $cognitiveComplexityDataCollector,
42+
private readonly ComplexityAffectingNodeFinder $complexityAffectingNodeFinder,
4343
) {
4444
}
4545

src/Rules/ClassLikeCognitiveComplexityRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class ClassLikeCognitiveComplexityRule implements Rule
2323
public const ERROR_MESSAGE = 'Class cognitive complexity is %d, keep it under %d';
2424

2525
public function __construct(
26-
private AstCognitiveComplexityAnalyzer $astCognitiveComplexityAnalyzer,
26+
private readonly AstCognitiveComplexityAnalyzer $astCognitiveComplexityAnalyzer,
2727
private readonly Configuration $configuration
2828
) {
2929
}

src/Rules/FunctionLikeCognitiveComplexityRule.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPStan\Rules\Rule;
1515
use TomasVotruba\CognitiveComplexity\AstCognitiveComplexityAnalyzer;
1616
use TomasVotruba\CognitiveComplexity\Configuration;
17+
use TomasVotruba\CognitiveComplexity\Exception\ShouldNotHappenException;
1718

1819
/**
1920
* Based on https://www.sonarsource.com/docs/CognitiveComplexity.pdf
@@ -35,8 +36,8 @@ final class FunctionLikeCognitiveComplexityRule implements Rule
3536
public const ERROR_MESSAGE = 'Cognitive complexity for "%s" is %d, keep it under %d';
3637

3738
public function __construct(
38-
private AstCognitiveComplexityAnalyzer $astCognitiveComplexityAnalyzer,
39-
private Configuration $configuration,
39+
private readonly AstCognitiveComplexityAnalyzer $astCognitiveComplexityAnalyzer,
40+
private readonly Configuration $configuration,
4041
) {
4142
}
4243

@@ -100,6 +101,6 @@ private function resolveFunctionName(FunctionLike $functionLike, Scope $scope):
100101
return 'arrow function';
101102
}
102103

103-
throw new \TomasVotruba\CognitiveComplexity\Exception\ShouldNotHappenException();
104+
throw new ShouldNotHappenException();
104105
}
105106
}

0 commit comments

Comments
 (0)