Question

I have found myself in a situation where a switch case fall-through is the best option. By this I mean:

switch($bar)
{
    case 0:
        // do something
    case 1:
        // do more
        break;
    //more cases
}

Currently my IDE (phpStorm) is throwing a warning about the fall-through.

Is there an accepted way in phpDoc to document such intended fall-through?

n.b. I'm aware that some of you will undoubtedly say not to do this but I subscribe to this definition of evil and this is certainly the 'the least bad of the alternatives'.

Was it helpful?

Solution

Although the question explicitly asks about phpDoc, here's an IDE-specific solution for PHPStorm.

For Javascript, comment

//noinspection FallthroughInSwitchStatementJS

above the switch statement.

For PHP, comment

/** @noinspection PhpMissingBreakStatementInspection */

above the offending case statement.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top