Skip to content

Report malformed PHPUnit annotations in the class docblocks of used traits - #234

Merged
alies-dev merged 36 commits into
psalm:masterfrom
alies-dev:feat/220-trait-docblock-annotations
Nov 9, 2026
Merged

alies-dev merged 36 commits into
psalm:masterfrom
alies-dev:feat/220-trait-docblock-annotations

Conversation

@alies-dev

@alies-dev alies-dev commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

A malformed PHPUnit annotation in the class docblock of a trait used by a test case is not reported, although PHPUnit 11 merges that docblock into the test class and ignores the annotation.

Before

<?php
/**
 * @group                          // no issue
 */
trait HelperTrait
{
}

final class MyTestCase extends TestCase
{
    use HelperTrait;

    public function testSomething(): void {
        $this->expectNotToPerformAssertions();
    }
}

After

 * @group                          // InvalidPhpUnitAnnotation: Annotation "@group" has no value

Only traits the test case uses directly are checked, like PHPUnit does.

Fixes #220

@alies-dev alies-dev self-assigned this Nov 9, 2026
@alies-dev
alies-dev force-pushed the feat/220-trait-docblock-annotations branch from f5bccfd to e1ff3d4 Compare November 9, 2026 21:46
@alies-dev
alies-dev marked this pull request as ready for review November 9, 2026 22:09
@alies-dev
alies-dev merged commit 98b5327 into psalm:master Nov 9, 2026
8 checks passed
@alies-dev
alies-dev deleted the feat/220-trait-docblock-annotations branch November 9, 2026 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check class docblocks of traits used by a test case for malformed PHPUnit annotations

1 participant