Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best way to document intentional switch fall-through?

Tags:

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

like image 269
Rob Forrest Avatar asked Jul 03 '13 10:07

Rob Forrest


1 Answers

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.

like image 137
Hackenslacker Avatar answered Dec 11 '22 08:12

Hackenslacker