psalm / psalm-plugin-phpunit

A PHPUnit plugin for Psalm
77 stars 33 forks source link

#[Test] Not Suppressing PossiblyUnusedMethod #144

Open Tigerman55 opened 11 months ago

Tigerman55 commented 11 months ago

If I use the attribute #[Test] instead of testSomething(), the error PossiblyUnusedMethod is not suppressed.

lotyp commented 7 months ago

I have same issue:

Examples

throws PossiblyUnusedMethod:

    #[Test]
    public function it_gets_orm_from_facade_when_container_has_orm(): void
    {
        ...
    }

works:

    /**
     * @test
     */
    #[Test]
    public function it_gets_orm_from_facade_when_container_has_orm(): void
    {

    }
lotyp commented 7 months ago

Duplicate issue: https://github.com/psalm/psalm-plugin-phpunit/issues/131

weirdan commented 7 months ago

The fix would be somewhere near these lines: https://github.com/psalm/psalm-plugin-phpunit/blob/e344eaaa27871e79c6cb97b9efe52a735f9d1966/src/Hooks/TestCaseHandler.php#L155-L160

lotyp commented 7 months ago

@weirdan Thanks for this tip! I have created PR: https://github.com/psalm/psalm-plugin-phpunit/pull/145

I have tested it manually, on my code.

Please give suggestions, what do I need to change/add to get this merged.