4
4
5
5
use PHPStan \Rules \Rule ;
6
6
use PHPStan \Testing \RuleTestCase ;
7
- use PHPUnit \Framework \Attributes \DataProvider ;
8
7
use PHPUnit \Framework \Attributes \RequiresPhp ;
9
8
10
9
/**
@@ -15,8 +14,6 @@ class MatchExpressionRuleTest extends RuleTestCase
15
14
16
15
private bool $ treatPhpDocTypesAsCertain = true ;
17
16
18
- private bool $ reportAlwaysTrueInLastCondition = false ;
19
-
20
17
protected function getRule (): Rule
21
18
{
22
19
return new MatchExpressionRule (
@@ -29,7 +26,6 @@ protected function getRule(): Rule
29
26
),
30
27
$ this ->treatPhpDocTypesAsCertain ,
31
28
),
32
- $ this ->reportAlwaysTrueInLastCondition ,
33
29
$ this ->treatPhpDocTypesAsCertain ,
34
30
);
35
31
}
@@ -280,21 +276,11 @@ public function testLastArmAlwaysTrue(): void
280
276
]);
281
277
}
282
278
283
- public static function dataReportAlwaysTrueInLastCondition (): iterable
279
+ #[RequiresPhp('>= 8.1 ' )]
280
+ public function testLastCondition (): void
284
281
{
285
- yield [false , [
286
- [
287
- 'Match arm comparison between $this(MatchAlwaysTrueLastArm\Foo)&MatchAlwaysTrueLastArm\Foo::BAR and MatchAlwaysTrueLastArm\Foo::BAR is always true. ' ,
288
- 23 ,
289
- 'Remove remaining cases below this one and this error will disappear too. ' ,
290
- ],
291
- [
292
- 'Match arm comparison between $this(MatchAlwaysTrueLastArm\Foo)&MatchAlwaysTrueLastArm\Foo::BAR and MatchAlwaysTrueLastArm\Foo::BAR is always true. ' ,
293
- 49 ,
294
- 'Remove remaining cases below this one and this error will disappear too. ' ,
295
- ],
296
- ]];
297
- yield [true , [
282
+ $ this ->treatPhpDocTypesAsCertain = true ;
283
+ $ this ->analyse ([__DIR__ . '/data/match-always-true-last-arm.php ' ], [
298
284
[
299
285
'Match arm comparison between $this(MatchAlwaysTrueLastArm\Foo)&MatchAlwaysTrueLastArm\Foo::BAR and MatchAlwaysTrueLastArm\Foo::BAR is always true. ' ,
300
286
23 ,
@@ -305,23 +291,7 @@ public static function dataReportAlwaysTrueInLastCondition(): iterable
305
291
49 ,
306
292
'Remove remaining cases below this one and this error will disappear too. ' ,
307
293
],
308
- [
309
- 'Match arm comparison between false and false is always true. ' ,
310
- 58 ,
311
- ],
312
- ]];
313
- }
314
-
315
- /**
316
- * @param list<array{0: string, 1: int, 2?: string}> $expectedErrors
317
- */
318
- #[RequiresPhp('>= 8.1 ' )]
319
- #[DataProvider('dataReportAlwaysTrueInLastCondition ' )]
320
- public function testReportAlwaysTrueInLastCondition (bool $ reportAlwaysTrueInLastCondition , array $ expectedErrors ): void
321
- {
322
- $ this ->treatPhpDocTypesAsCertain = true ;
323
- $ this ->reportAlwaysTrueInLastCondition = $ reportAlwaysTrueInLastCondition ;
324
- $ this ->analyse ([__DIR__ . '/data/match-always-true-last-arm.php ' ], $ expectedErrors );
294
+ ]);
325
295
}
326
296
327
297
#[RequiresPhp('>= 8.0 ' )]
0 commit comments