Skip to content

False positive missing call to parent when setUp never returns #292

@axlon

Description

@axlon

When creating a test that has a setup method that never returns (e.g. because the whole test should be skipped), PHPStan will complain that the parent::setUp() should be called.

In this case, we have to choose between either setting up the parent before we skip the test (doing useless work in the process), setting up the parent after the skip, which will trigger an error about dead code, or baselining the original error. All of these solutions seem wrong to me and I think in this PHPStan just shouldn't tell you to call the parent.

Example:

final class MyTest extends TestCase
{
    protected function setUp(): never
    {
        self::markTestSkipped('Currently broken due to XYZ');
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions