5
5
use PHPStan \Rules \Rule ;
6
6
use PHPStan \Rules \RuleLevelHelper ;
7
7
use PHPStan \Testing \RuleTestCase ;
8
+ use PHPUnit \Framework \Attributes \RequiresPhp ;
8
9
use function array_merge ;
9
10
use const PHP_VERSION_ID ;
10
11
@@ -19,6 +20,7 @@ protected function getRule(): Rule
19
20
return new CallToMethodStatementWithoutSideEffectsRule (new RuleLevelHelper (self ::createReflectionProvider (), true , false , true , false , false , false , true ));
20
21
}
21
22
23
+ #[RequiresPhp('>= 8.0 ' )]
22
24
public function testRule (): void
23
25
{
24
26
$ this ->analyse ([__DIR__ . '/data/method-call-statement-no-side-effects.php ' ], [
@@ -41,6 +43,33 @@ public function testRule(): void
41
43
]);
42
44
}
43
45
46
+ #[RequiresPhp('< 8 ' )]
47
+ public function testRulePhp7 (): void
48
+ {
49
+ $ this ->analyse ([__DIR__ . '/data/method-call-statement-no-side-effects.php ' ], [
50
+ [
51
+ 'Call to method DateTimeImmutable::modify() on a separate line has no effect. ' ,
52
+ 15 ,
53
+ ],
54
+ [
55
+ 'Call to static method DateTimeImmutable::createFromFormat() on a separate line has no effect. ' ,
56
+ 16 ,
57
+ ],
58
+ [
59
+ 'Call to method Exception::getCode() on a separate line has no effect. ' ,
60
+ 21 ,
61
+ ],
62
+ [
63
+ 'Call to method MethodCallStatementNoSideEffects\Bar::doPure() on a separate line has no effect. ' ,
64
+ 63 ,
65
+ ],
66
+ [
67
+ 'Call to method MethodCallStatementNoSideEffects\Bar::doPureWithThrowsVoid() on a separate line has no effect. ' ,
68
+ 64 ,
69
+ ],
70
+ ]);
71
+ }
72
+
44
73
public function testNullsafe (): void
45
74
{
46
75
$ this ->analyse ([__DIR__ . '/data/nullsafe-method-call-statement-no-side-effects.php ' ], [
0 commit comments