Skip to content

Commit e246ed9

Browse files
committed
More #[RegisteredRule]
1 parent db6196d commit e246ed9

32 files changed

+162
-247
lines changed

conf/config.level3.neon

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -7,63 +7,3 @@ autowiredAttributeServices:
77

88
parameters:
99
checkPhpDocMethodSignatures: true
10-
11-
services:
12-
-
13-
class: PHPStan\Rules\Arrays\InvalidKeyInArrayDimFetchRule
14-
arguments:
15-
reportMaybes: %reportMaybes%
16-
tags:
17-
- phpstan.rules.rule
18-
19-
-
20-
class: PHPStan\Rules\Arrays\InvalidKeyInArrayItemRule
21-
arguments:
22-
reportMaybes: %reportMaybes%
23-
tags:
24-
- phpstan.rules.rule
25-
26-
-
27-
class: PHPStan\Rules\Arrays\NonexistentOffsetInArrayDimFetchRule
28-
arguments:
29-
reportMaybes: %reportMaybes%
30-
tags:
31-
- phpstan.rules.rule
32-
33-
-
34-
class: PHPStan\Rules\Exceptions\ThrowsVoidFunctionWithExplicitThrowPointRule
35-
arguments:
36-
exceptionTypeResolver: @exceptionTypeResolver
37-
missingCheckedExceptionInThrows: %exceptions.check.missingCheckedExceptionInThrows%
38-
tags:
39-
- phpstan.rules.rule
40-
41-
-
42-
class: PHPStan\Rules\Exceptions\ThrowsVoidMethodWithExplicitThrowPointRule
43-
arguments:
44-
exceptionTypeResolver: @exceptionTypeResolver
45-
missingCheckedExceptionInThrows: %exceptions.check.missingCheckedExceptionInThrows%
46-
tags:
47-
- phpstan.rules.rule
48-
49-
-
50-
class: PHPStan\Rules\Exceptions\ThrowsVoidPropertyHookWithExplicitThrowPointRule
51-
arguments:
52-
exceptionTypeResolver: @exceptionTypeResolver
53-
missingCheckedExceptionInThrows: %exceptions.check.missingCheckedExceptionInThrows%
54-
tags:
55-
- phpstan.rules.rule
56-
57-
-
58-
class: PHPStan\Rules\Generators\YieldFromTypeRule
59-
arguments:
60-
reportMaybes: %reportMaybes%
61-
tags:
62-
- phpstan.rules.rule
63-
64-
-
65-
class: PHPStan\Rules\Generators\YieldInGeneratorRule
66-
arguments:
67-
reportMaybes: %reportMaybes%
68-
tags:
69-
- phpstan.rules.rule

conf/config.level4.neon

Lines changed: 0 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,6 @@ parameters:
1717
checkAdvancedIsset: true
1818

1919
services:
20-
-
21-
class: PHPStan\Rules\Classes\ImpossibleInstanceOfRule
22-
arguments:
23-
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
24-
reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition%
25-
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%
26-
tags:
27-
- phpstan.rules.rule
28-
29-
-
30-
class: PHPStan\Rules\Comparison\BooleanAndConstantConditionRule
31-
arguments:
32-
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
33-
reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition%
34-
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%
35-
tags:
36-
- phpstan.rules.rule
37-
38-
-
39-
class: PHPStan\Rules\Comparison\BooleanOrConstantConditionRule
40-
arguments:
41-
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
42-
reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition%
43-
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%
44-
tags:
45-
- phpstan.rules.rule
46-
47-
-
48-
class: PHPStan\Rules\Comparison\BooleanNotConstantConditionRule
49-
arguments:
50-
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
51-
reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition%
52-
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%
53-
tags:
54-
- phpstan.rules.rule
55-
5620
-
5721
class: PHPStan\Rules\DeadCode\ConstructorWithoutImpurePointsCollector
5822
tags:
@@ -88,134 +52,6 @@ services:
8852
tags:
8953
- phpstan.collector
9054

91-
-
92-
class: PHPStan\Rules\DeadCode\UnusedPrivatePropertyRule
93-
arguments:
94-
alwaysWrittenTags: %propertyAlwaysWrittenTags%
95-
alwaysReadTags: %propertyAlwaysReadTags%
96-
checkUninitializedProperties: %checkUninitializedProperties%
97-
tags:
98-
- phpstan.rules.rule
99-
100-
-
101-
class: PHPStan\Rules\Comparison\DoWhileLoopConstantConditionRule
102-
arguments:
103-
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
104-
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%
105-
tags:
106-
- phpstan.rules.rule
107-
108-
-
109-
class: PHPStan\Rules\Comparison\ElseIfConstantConditionRule
110-
arguments:
111-
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
112-
reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition%
113-
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%
114-
tags:
115-
- phpstan.rules.rule
116-
117-
-
118-
class: PHPStan\Rules\Comparison\IfConstantConditionRule
119-
arguments:
120-
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
121-
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%
122-
tags:
123-
- phpstan.rules.rule
124-
125-
-
126-
class: PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRule
127-
arguments:
128-
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
129-
reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition%
130-
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%
131-
tags:
132-
- phpstan.rules.rule
133-
134-
-
135-
class: PHPStan\Rules\Comparison\ImpossibleCheckTypeMethodCallRule
136-
arguments:
137-
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
138-
reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition%
139-
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%
140-
tags:
141-
- phpstan.rules.rule
142-
143-
-
144-
class: PHPStan\Rules\Comparison\ImpossibleCheckTypeStaticMethodCallRule
145-
arguments:
146-
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
147-
reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition%
148-
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%
149-
tags:
150-
- phpstan.rules.rule
151-
152-
-
153-
class: PHPStan\Rules\Comparison\LogicalXorConstantConditionRule
154-
arguments:
155-
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
156-
reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition%
157-
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%
158-
tags:
159-
- phpstan.rules.rule
160-
161-
-
162-
class: PHPStan\Rules\Comparison\MatchExpressionRule
163-
arguments:
164-
reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition%
165-
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
166-
tags:
167-
- phpstan.rules.rule
168-
169-
-
170-
class: PHPStan\Rules\Comparison\NumberComparisonOperatorsConstantConditionRule
171-
arguments:
172-
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
173-
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%
174-
tags:
175-
- phpstan.rules.rule
176-
177-
-
178-
class: PHPStan\Rules\Comparison\StrictComparisonOfDifferentTypesRule
179-
arguments:
180-
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
181-
reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition%
182-
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%
183-
tags:
184-
- phpstan.rules.rule
185-
186-
-
187-
class: PHPStan\Rules\Comparison\ConstantLooseComparisonRule
188-
arguments:
189-
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
190-
reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition%
191-
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%
192-
tags:
193-
- phpstan.rules.rule
194-
195-
-
196-
class: PHPStan\Rules\Comparison\TernaryOperatorConstantConditionRule
197-
arguments:
198-
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
199-
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%
200-
tags:
201-
- phpstan.rules.rule
202-
203-
-
204-
class: PHPStan\Rules\Comparison\WhileLoopAlwaysFalseConditionRule
205-
arguments:
206-
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
207-
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%
208-
tags:
209-
- phpstan.rules.rule
210-
211-
-
212-
class: PHPStan\Rules\Comparison\WhileLoopAlwaysTrueConditionRule
213-
arguments:
214-
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
215-
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%
216-
tags:
217-
- phpstan.rules.rule
218-
21955
-
22056
class: PHPStan\Rules\Exceptions\TooWideFunctionThrowTypeRule
22157

@@ -225,18 +61,6 @@ services:
22561
-
22662
class: PHPStan\Rules\Exceptions\TooWidePropertyHookThrowTypeRule
22763

228-
-
229-
class: PHPStan\Rules\TooWideTypehints\TooWideMethodReturnTypehintRule
230-
arguments:
231-
checkProtectedAndPublicMethods: %checkTooWideReturnTypesInProtectedAndPublicMethods%
232-
tags:
233-
- phpstan.rules.rule
234-
235-
-
236-
class: PHPStan\Rules\Properties\NullsafePropertyFetchRule
237-
tags:
238-
- phpstan.rules.rule
239-
24064
-
24165
class: PHPStan\Rules\Traits\TraitDeclarationCollector
24266
tags:
@@ -246,11 +70,3 @@ services:
24670
class: PHPStan\Rules\Traits\TraitUseCollector
24771
tags:
24872
- phpstan.collector
249-
250-
-
251-
class: PHPStan\Rules\Exceptions\CatchWithUnthrownExceptionRule
252-
arguments:
253-
exceptionTypeResolver: @exceptionTypeResolver
254-
reportUncheckedExceptionDeadCatch: %exceptions.reportUncheckedExceptionDeadCatch%
255-
tags:
256-
- phpstan.rules.rule

src/Rules/Arrays/InvalidKeyInArrayDimFetchRule.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use PhpParser\Node;
66
use PHPStan\Analyser\Scope;
7+
use PHPStan\DependencyInjection\AutowiredParameter;
8+
use PHPStan\DependencyInjection\RegisteredRule;
79
use PHPStan\Rules\Rule;
810
use PHPStan\Rules\RuleErrorBuilder;
911
use PHPStan\Rules\RuleLevelHelper;
@@ -16,11 +18,13 @@
1618
/**
1719
* @implements Rule<Node\Expr\ArrayDimFetch>
1820
*/
21+
#[RegisteredRule(level: 3)]
1922
final class InvalidKeyInArrayDimFetchRule implements Rule
2023
{
2124

2225
public function __construct(
2326
private RuleLevelHelper $ruleLevelHelper,
27+
#[AutowiredParameter]
2428
private bool $reportMaybes,
2529
)
2630
{

src/Rules/Arrays/InvalidKeyInArrayItemRule.php

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

55
use PhpParser\Node;
66
use PHPStan\Analyser\Scope;
7+
use PHPStan\DependencyInjection\AutowiredParameter;
8+
use PHPStan\DependencyInjection\RegisteredRule;
79
use PHPStan\Rules\Rule;
810
use PHPStan\Rules\RuleErrorBuilder;
911
use PHPStan\Type\MixedType;
@@ -13,10 +15,14 @@
1315
/**
1416
* @implements Rule<Node\ArrayItem>
1517
*/
18+
#[RegisteredRule(level: 3)]
1619
final class InvalidKeyInArrayItemRule implements Rule
1720
{
1821

19-
public function __construct(private bool $reportMaybes)
22+
public function __construct(
23+
#[AutowiredParameter]
24+
private bool $reportMaybes,
25+
)
2026
{
2127
}
2228

src/Rules/Arrays/NonexistentOffsetInArrayDimFetchRule.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use PhpParser\Node;
66
use PHPStan\Analyser\NullsafeOperatorHelper;
77
use PHPStan\Analyser\Scope;
8+
use PHPStan\DependencyInjection\AutowiredParameter;
9+
use PHPStan\DependencyInjection\RegisteredRule;
810
use PHPStan\Internal\SprintfHelper;
911
use PHPStan\Rules\Rule;
1012
use PHPStan\Rules\RuleErrorBuilder;
@@ -20,12 +22,14 @@
2022
/**
2123
* @implements Rule<Node\Expr\ArrayDimFetch>
2224
*/
25+
#[RegisteredRule(level: 3)]
2326
final class NonexistentOffsetInArrayDimFetchRule implements Rule
2427
{
2528

2629
public function __construct(
2730
private RuleLevelHelper $ruleLevelHelper,
2831
private NonexistentOffsetInArrayDimFetchCheck $nonexistentOffsetInArrayDimFetchCheck,
32+
#[AutowiredParameter]
2933
private bool $reportMaybes,
3034
)
3135
{

src/Rules/Classes/ImpossibleInstanceOfRule.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use PhpParser\Node;
66
use PHPStan\Analyser\Scope;
7+
use PHPStan\DependencyInjection\AutowiredParameter;
8+
use PHPStan\DependencyInjection\RegisteredRule;
79
use PHPStan\Parser\LastConditionVisitor;
810
use PHPStan\Rules\Rule;
911
use PHPStan\Rules\RuleErrorBuilder;
@@ -18,12 +20,16 @@
1820
/**
1921
* @implements Rule<Node\Expr\Instanceof_>
2022
*/
23+
#[RegisteredRule(level: 4)]
2124
final class ImpossibleInstanceOfRule implements Rule
2225
{
2326

2427
public function __construct(
28+
#[AutowiredParameter]
2529
private bool $treatPhpDocTypesAsCertain,
30+
#[AutowiredParameter]
2631
private bool $reportAlwaysTrueInLastCondition,
32+
#[AutowiredParameter(ref: '%tips.treatPhpDocTypesAsCertain%')]
2733
private bool $treatPhpDocTypesAsCertainTip,
2834
)
2935
{

src/Rules/Comparison/BooleanAndConstantConditionRule.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use PhpParser\Node;
66
use PHPStan\Analyser\Scope;
7+
use PHPStan\DependencyInjection\AutowiredParameter;
8+
use PHPStan\DependencyInjection\RegisteredRule;
79
use PHPStan\Node\BooleanAndNode;
810
use PHPStan\Parser\LastConditionVisitor;
911
use PHPStan\Rules\Rule;
@@ -15,13 +17,17 @@
1517
/**
1618
* @implements Rule<BooleanAndNode>
1719
*/
20+
#[RegisteredRule(level: 4)]
1821
final class BooleanAndConstantConditionRule implements Rule
1922
{
2023

2124
public function __construct(
2225
private ConstantConditionRuleHelper $helper,
26+
#[AutowiredParameter]
2327
private bool $treatPhpDocTypesAsCertain,
28+
#[AutowiredParameter]
2429
private bool $reportAlwaysTrueInLastCondition,
30+
#[AutowiredParameter(ref: '%tips.treatPhpDocTypesAsCertain%')]
2531
private bool $treatPhpDocTypesAsCertainTip,
2632
)
2733
{

0 commit comments

Comments
 (0)