55use PHPStan \Rules \Rule ;
66use PHPStan \Rules \RuleLevelHelper ;
77use PHPStan \Testing \RuleTestCase ;
8+ use PHPUnit \Framework \Attributes \RequiresPhp ;
89use function array_merge ;
910use const PHP_VERSION_ID ;
1011
@@ -19,6 +20,7 @@ protected function getRule(): Rule
1920 return new CallToMethodStatementWithoutSideEffectsRule (new RuleLevelHelper (self ::createReflectionProvider (), true , false , true , false , false , false , true ));
2021 }
2122
23+ #[RequiresPhp('>= 8.0 ' )]
2224 public function testRule (): void
2325 {
2426 $ this ->analyse ([__DIR__ . '/data/method-call-statement-no-side-effects.php ' ], [
@@ -41,6 +43,33 @@ public function testRule(): void
4143 ]);
4244 }
4345
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+
4473 public function testNullsafe (): void
4574 {
4675 $ this ->analyse ([__DIR__ . '/data/nullsafe-method-call-statement-no-side-effects.php ' ], [
0 commit comments