Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upmarkTestIncomplete and markTestSkipped as earlyTerminatingMethodCalls #52
Comments
|
It's currently hard to have the one advantage (to correctly find undefined variables) and not the other (finding unreachable code). When I first ran this analysis on codebase at my dayjob, it found some useful cases - like having a redundant I usually use markTestSkipped conditionally in tests, so this problem does not apply to my usage. But I'm gonna leave this open - it's theoretically possible to solve this by introducing some kind of option to NodeScopeResolver in PHPStan core. |
|
Until then, it's easy for users to ignore this with |
|
Hello We found this problem annoying too. Unreachable code analysis should not inspect code below public function testService(): void
{
$this->markTestSkipped('Skipped due temporary unavailable service');
// ..... unreachable test code here ....
}Our dirty temporary solution is to rename the test method: // Skipped due temporary unavailable service
public function skipTestService(): void
{
// ..... unreachable test code here ....
}It is not the same of course. Phpunit cannot recognize and report skipped test in this way. |
|
If i write static::markTestSkipped then i expected that code below will be unreachable. |
The extension marks
markTestIncompleteandmarkTestSkippedasearlyTerminatingMethodCalls. The effect is that PHPStan will emit aUnreachable statement - code above always terminates.error for any code after them.I found that this is not necessary useful. I mean, this error is useful for detecting unexpectedly unreachable statements, but the goal of
markTestIncompleteormarkTestSkipped, is to make some code unreachable/unexecuted without actually removing it.