Skip to content

Suppress UnusedFunctionCall, UnusedMethodCall when test expects an exception #108

@vudaltsov

Description

@vudaltsov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions