Skip to content

Commit f2809dd

Browse files
committed
[BE] New better NoopRule
1 parent ad15028 commit f2809dd

File tree

7 files changed

+6
-15
lines changed

7 files changed

+6
-15
lines changed

changelog-2.0.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ Bleeding edge (TODO move to other sections)
7070
* Rule for `call_user_func()` ([#2479](https://github.com/phpstan/phpstan-src/pull/2479)), thanks @staabm!
7171
* MagicConstantContextRule ([#2741](https://github.com/phpstan/phpstan-src/pull/2741)), #10099, thanks @staabm!
7272
* TooWideMethodReturnTypehintRule - always report for final methods (https://github.com/phpstan/phpstan-src/commit/c30e9a484c8245b8126cd63444607ca74d2af761)
73-
* NoopRule - report top-level `xor` because that's probably not what the user intended to do (https://github.com/phpstan/phpstan-src/commit/a1fffb3346e09f1e8e8d987d4282263295a55142), #10267
7473
* Report unused results of `and` and `or` (https://github.com/phpstan/phpstan-src/commit/1d8fff637d70a9e9ed3f11dee5d61b9f796cbf1a)
7574
* Report unused result of ternary (https://github.com/phpstan/phpstan-src/commit/9664f7a9d2223c07e750f0dfc949c3accfa6b65e)
7675
* Report unused results of `&&` and `||` (https://github.com/phpstan/phpstan-src/commit/cf2c8bbd9ebd2ebe300dbd310e136ad603d7def3)
@@ -83,7 +82,6 @@ Bleeding edge (TODO move to other sections)
8382
* [#3020](https://github.com/phpstan/phpstan-src/pull/3020), thanks @staabm!
8483
* [#3022](https://github.com/phpstan/phpstan-src/pull/3022), thanks @staabm!
8584
* [#3023](https://github.com/phpstan/phpstan-src/pull/3023), thanks @staabm!
86-
* BetterNoopRule - take advantage of impure points (https://github.com/phpstan/phpstan-src/commit/a6470521b65d7424f552633c1f3827704c6262c3), #10389
8785
* CallToConstructorStatementWithoutSideEffectsRule - report class with no constructor (https://github.com/phpstan/phpstan-src/commit/b116d25a6e4ba6c09f59af6569d9e6f6fd20aff4)
8886
* Check if required file exists ([#3294](https://github.com/phpstan/phpstan-src/pull/3294)), #3397, thanks @Bellangelo!
8987
* Enforce `@no-named-arguments` (https://github.com/phpstan/phpstan-src/commit/74ba8c23696948f2647d880df72f375346f41010), #5968
@@ -128,6 +126,7 @@ Improvements 🔧
128126
* Check mixed in binary operator ([#3231](https://github.com/phpstan/phpstan-src/pull/3231)), #7538, #10440, thanks @schlndh!
129127
* Check mixed in unary operator ([#3253](https://github.com/phpstan/phpstan-src/pull/3253)), thanks @schlndh!
130128
* Stub files validation - detect duplicate classes and functions (https://github.com/phpstan/phpstan-src/commit/ddf8d5c3859c2c75c20f525a0e2ca8b99032373a, https://github.com/phpstan/phpstan-src/commit/17e4b74335e5235d7cd6708eb687a774a0eeead4)
129+
* NoopRule - take advantage of impure points (https://github.com/phpstan/phpstan-src/commit/a6470521b65d7424f552633c1f3827704c6262c3), #10389
131130

132131
Bugfixes 🐛
133132
=====================

conf/bleedingEdge.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ parameters:
2222
nullContextForVoidReturningFunctions: true
2323
unescapeStrings: true
2424
alwaysCheckTooWideReturnTypeFinalMethods: true
25-
betterNoop: true
2625
alwaysTrueAlwaysReported: true
2726
disableUnreachableBranchesRules: true
2827
varTagType: true

conf/config.level4.neon

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ includes:
33

44
rules:
55
- PHPStan\Rules\Arrays\DeadForeachRule
6+
- PHPStan\Rules\DeadCode\NoopRule
67
- PHPStan\Rules\DeadCode\UnreachableStatementRule
78
- PHPStan\Rules\DeadCode\UnusedPrivateConstantRule
89
- PHPStan\Rules\DeadCode\UnusedPrivateMethodRule
@@ -26,8 +27,6 @@ conditionalTags:
2627
phpstan.collector: %featureToggles.notAnalysedTrait%
2728
PHPStan\Rules\Traits\NotAnalysedTraitRule:
2829
phpstan.rules.rule: %featureToggles.notAnalysedTrait%
29-
PHPStan\Rules\DeadCode\BetterNoopRule:
30-
phpstan.rules.rule: %featureToggles.betterNoop%
3130
PHPStan\Rules\DeadCode\CallToConstructorStatementWithoutImpurePointsRule:
3231
phpstan.rules.rule: %featureToggles.pure%
3332
PHPStan\Rules\DeadCode\PossiblyPureNewCollector:
@@ -200,9 +199,6 @@ services:
200199
tags:
201200
- phpstan.rules.rule
202201

203-
-
204-
class: PHPStan\Rules\DeadCode\BetterNoopRule
205-
206202
-
207203
class: PHPStan\Rules\Comparison\MatchExpressionRule
208204
arguments:

conf/config.neon

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,12 @@ parameters:
4343
nullContextForVoidReturningFunctions: false
4444
unescapeStrings: false
4545
alwaysCheckTooWideReturnTypeFinalMethods: false
46-
betterNoop: false
4746
alwaysTrueAlwaysReported: false
4847
disableUnreachableBranchesRules: false
4948
varTagType: false
5049
closureDefaultParameterTypeRule: false
5150
instanceofType: false
5251
paramOutVariance: false
53-
5452
strictStaticMethodTemplateTypeVariance: false
5553
propertyVariance: false
5654
stricterFunctionMap: false

conf/parametersSchema.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ parametersSchema:
4949
nullContextForVoidReturningFunctions: bool()
5050
unescapeStrings: bool()
5151
alwaysCheckTooWideReturnTypeFinalMethods: bool()
52-
betterNoop: bool()
5352
alwaysTrueAlwaysReported: bool()
5453
disableUnreachableBranchesRules: bool()
5554
varTagType: bool()

src/Rules/DeadCode/BetterNoopRule.php renamed to src/Rules/DeadCode/NoopRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/**
1616
* @implements Rule<NoopExpressionNode>
1717
*/
18-
final class BetterNoopRule implements Rule
18+
final class NoopRule implements Rule
1919
{
2020

2121
public function __construct(private ExprPrinter $exprPrinter)

tests/PHPStan/Rules/DeadCode/BetterNoopRuleTest.php renamed to tests/PHPStan/Rules/DeadCode/NoopRuleTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
use PHPStan\Testing\RuleTestCase;
99

1010
/**
11-
* @extends RuleTestCase<BetterNoopRule>
11+
* @extends RuleTestCase<NoopRule>
1212
*/
13-
class BetterNoopRuleTest extends RuleTestCase
13+
class NoopRuleTest extends RuleTestCase
1414
{
1515

1616
protected function getRule(): Rule
1717
{
18-
return new BetterNoopRule(new ExprPrinter(new Printer()));
18+
return new NoopRule(new ExprPrinter(new Printer()));
1919
}
2020

2121
public function testRule(): void

0 commit comments

Comments
 (0)