Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress UnusedFunctionCall, UnusedMethodCall when test expects an exception #108

Open
vudaltsov opened this issue Mar 31, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@vudaltsov
Copy link

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.

@weirdan weirdan added the enhancement New feature or request label Mar 31, 2021
@weirdan
Copy link
Member

weirdan commented Mar 31, 2021

It's doable (the plugin already suppresses MissingConstructor), but I'm wondering whether people would complain about false-negatives 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants