psalm-plugin-phpunit
psalm-plugin-phpunit copied to clipboard
Suppress UnusedFunctionCall, UnusedMethodCall when test expects an exception
Consider this case:
<?php
use PHPUnit\Framework\TestCase;
final class JsonDecodeTest extends TestCase
{
public function testThrowsOnInvalidJson(): void
{
$this->expectException(\JsonException::class);
// UnusedFunctionCall is thrown here
json_decode('', flags: JSON_THROW_ON_ERROR);
}
}
I am not sure that this is doable or worth the effort, so feel free to close the issue. For now we just suppressed UnusedFunctionCall and UnusedMethodCall in psalm.xml for the whole tests directory.
It's doable (the plugin already suppresses MissingConstructor), but I'm wondering whether people would complain about false-negatives :thinking: