Skip to content

Commit

Permalink
CallToFunctionStamentWithoutSideEffectsRule - do not report PHPStan t…
Browse files Browse the repository at this point in the history
…esting functions
  • Loading branch information
ondrejmirtes committed Jun 6, 2021
1 parent 42c72f3 commit 6eaf6c2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ public function processNode(Node $node, Scope $scope): array
return [];
}

if (in_array($function->getName(), [
'PHPStan\\Testing\\assertType',
'PHPStan\\Testing\\assertNativeType',
'PHPStan\\Testing\\assertVariableCertainty',
], true)) {
return [];
}

return [
RuleErrorBuilder::message(sprintf(
'Call to function %s() on a separate line has no effect.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testRule(): void
$this->analyse([__DIR__ . '/data/function-call-statement-no-side-effects.php'], [
[
'Call to function sprintf() on a separate line has no effect.',
11,
13,
],
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace FunctionCallStatementNoSideEffects;

use PHPStan\TrinaryLogic;

class Foo
{

Expand All @@ -11,4 +13,11 @@ public function doFoo()
sprintf('%s', 'test');
}

public function doBar(string $s)
{
\PHPStan\Testing\assertType('string', $s);
\PHPStan\Testing\assertNativeType('string', $s);
\PHPStan\Testing\assertVariableCertainty(TrinaryLogic::createYes(), $s);
}

}

0 comments on commit 6eaf6c2

Please sign in to comment.