Skip to content

Commit 3e856e3

Browse files
committed
fix
1 parent 48eb91b commit 3e856e3

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

tests/PHPStan/Rules/Methods/CallToMethodStatementWithoutSideEffectsRuleTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PHPStan\Rules\Rule;
66
use PHPStan\Rules\RuleLevelHelper;
77
use PHPStan\Testing\RuleTestCase;
8+
use PHPUnit\Framework\Attributes\RequiresPhp;
89
use function array_merge;
910
use 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'], [

tests/PHPStan/Rules/Methods/CallToStaticMethodStatementWithoutSideEffectsRuleTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PHPStan\Rules\Rule;
66
use PHPStan\Rules\RuleLevelHelper;
77
use PHPStan\Testing\RuleTestCase;
8+
use PHPUnit\Framework\Attributes\RequiresPhp;
89

910
/**
1011
* @extends RuleTestCase<CallToStaticMethodStatementWithoutSideEffectsRule>
@@ -21,6 +22,7 @@ protected function getRule(): Rule
2122
);
2223
}
2324

25+
#[RequiresPhp('>= 8.0')]
2426
public function testRule(): void
2527
{
2628
$this->analyse([__DIR__ . '/data/static-method-call-statement-no-side-effects.php'], [
@@ -31,6 +33,21 @@ public function testRule(): void
3133
]);
3234
}
3335

36+
#[RequiresPhp('< 8')]
37+
public function testRulePhp7(): void
38+
{
39+
$this->analyse([__DIR__ . '/data/static-method-call-statement-no-side-effects.php'], [
40+
[
41+
'Call to static method DateTimeImmutable::createFromFormat() on a separate line has no effect.',
42+
12,
43+
],
44+
[
45+
'Call to method DateTime::format() on a separate line has no effect.',
46+
23,
47+
],
48+
]);
49+
}
50+
3451
public function testPhpDoc(): void
3552
{
3653
$this->analyse([__DIR__ . '/data/static-method-call-statement-no-side-effects-phpdoc.php'], [

0 commit comments

Comments
 (0)