Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleLevelHelper;
use PHPStan\Testing\RuleTestCase;
use PHPUnit\Framework\Attributes\RequiresPhp;
use function array_merge;
use const PHP_VERSION_ID;

Expand All @@ -19,7 +20,31 @@ protected function getRule(): Rule
return new CallToMethodStatementWithoutSideEffectsRule(new RuleLevelHelper(self::createReflectionProvider(), true, false, true, false, false, false, true));
}

#[RequiresPhp('>= 8.0')]
public function testRule(): void
{
$this->analyse([__DIR__ . '/data/method-call-statement-no-side-effects.php'], [
[
'Call to method DateTimeImmutable::modify() on a separate line has no effect.',
15,
],
[
'Call to method Exception::getCode() on a separate line has no effect.',
21,
],
[
'Call to method MethodCallStatementNoSideEffects\Bar::doPure() on a separate line has no effect.',
63,
],
[
'Call to method MethodCallStatementNoSideEffects\Bar::doPureWithThrowsVoid() on a separate line has no effect.',
64,
],
]);
}

#[RequiresPhp('< 8')]
public function testRulePhp7(): void
{
$this->analyse([__DIR__ . '/data/method-call-statement-no-side-effects.php'], [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleLevelHelper;
use PHPStan\Testing\RuleTestCase;
use PHPUnit\Framework\Attributes\RequiresPhp;

/**
* @extends RuleTestCase<CallToStaticMethodStatementWithoutSideEffectsRule>
Expand All @@ -21,7 +22,19 @@ protected function getRule(): Rule
);
}

#[RequiresPhp('>= 8.0')]
public function testRule(): void
{
$this->analyse([__DIR__ . '/data/static-method-call-statement-no-side-effects.php'], [
[
'Call to method DateTime::format() on a separate line has no effect.',
23,
],
]);
}

#[RequiresPhp('< 8')]
public function testRulePhp7(): void
{
$this->analyse([__DIR__ . '/data/static-method-call-statement-no-side-effects.php'], [
[
Expand Down
Loading