You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
False positive missing call to parent when setUp never returns #292
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:
finalclass MyTest extends TestCase
{
protectedfunctionsetUp(): never
{
self::markTestSkipped('Currently broken due to XYZ');
}
}
sorry for leeting this alone without feedback for so long. I just found this issue.
I tried reproducing it but had no luck.
could you provide a small runnable example or provide a small repository which shows the problem?
the problem might only occur in certain phpunit versions or similar.
Activity
staabm commentedon May 25, 2026
sorry for leeting this alone without feedback for so long. I just found this issue.
I tried reproducing it but had no luck.
could you provide a small runnable example or provide a small repository which shows the problem?
the problem might only occur in certain phpunit versions or similar.
thank you
axlon commentedon Jun 17, 2026
@staabm thanks for taking a look at this, to reproduce it seems that the test needs to extend a class that defines a setup method, for example:
For me
FailingTest::setUp()triggers the error, butPassingTest::setUp()does not:About my configuration:
Hope this helps
staabm commentedon Jun 25, 2026
thank you, I can reproduce the problem.
we need to think about expectations for
tearDown,markTestIncomplete,markAsRiskymethods.in addition we need to make sure we also instance method variance of all involved static methods, e.g.
$this->markTestSkipped()