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'.

Était-ce utile?

La 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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top