psalm-plugin-phpunit icon indicating copy to clipboard operation
psalm-plugin-phpunit copied to clipboard

#[Test] Not Suppressing PossiblyUnusedMethod

Open Tigerman55 opened this issue 2 years ago • 4 comments

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

Tigerman55 avatar Dec 21 '23 14:12 Tigerman55

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 avatar May 02 '24 10:05 lotyp

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

lotyp avatar May 04 '24 08:05 lotyp

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

weirdan avatar May 04 '24 13:05 weirdan

@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.

lotyp avatar May 04 '24 15:05 lotyp