mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
prevent Psalm from considering throwing methods as unused just because they're immutable
This commit is contained in:
parent
6d21288d31
commit
1c1e352e5f
@ -112,6 +112,7 @@ class MethodCallPurityAnalyzer
|
||||
&& !$method_storage->assertions
|
||||
&& !$method_storage->if_true_assertions
|
||||
&& !$method_storage->if_false_assertions
|
||||
&& !$method_storage->throws
|
||||
) {
|
||||
if (IssueBuffer::accepts(
|
||||
new \Psalm\Issue\UnusedMethodCall(
|
||||
|
@ -1162,6 +1162,28 @@ class UnusedCodeTest extends TestCase
|
||||
$a = new A();
|
||||
echo $a->getVal(null);',
|
||||
],
|
||||
,
|
||||
'NotUnusedWhenThrows' => [
|
||||
'<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/** @psalm-immutable */
|
||||
final class UserList
|
||||
{
|
||||
/**
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function validate(): void
|
||||
{
|
||||
// Some validation happens here
|
||||
throw new \InvalidArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
$a = new UserList();
|
||||
$a->validate();
|
||||
',
|
||||
],
|
||||
'__halt_compiler_no_usage_check' => [
|
||||
'<?php
|
||||
exit(0);
|
||||
|
Loading…
Reference in New Issue
Block a user