Yeah, you can't just mechanically insert the breaks :) I carefully went through each instance where my rule tripped, looked at the surrounding code, and figured out the right fix. Trying to automate that would indeed have lead to disaster -- and the lack of ability to automate this is why no one had done this in the past, it sounded like too much work. (It wasn't that much work.)
And I agree switch fallthrough can be useful! We just required it be annotated from now on, to convey the intent, as opposed to doing it by accident.
To me, this is the same attitude that leads to safety hazards in other industries. "I don't need safety measures because -I- am not an idiot".
Even the smartest developers make dumb mistakes. If you can eliminate some of those early with minimal friction, it's worth it. The earlier you catch a mistake, the cheaper it is. Linter rules are less of a hassle than bugs in production.
switch ($foo) {
case 123:
// do 1
case 23:
// do 2
default:
// do 3
}
if ($foo == 123) {
do1();
do2();
do3();
}
else if ($foo == 23) {
do2();
do3();
}
else {
do3();
}
Yes, the second one is more verbose and duplicates code, but I think it's also far more clear in terms of intention.
but in a very high-level language like PHP, there’s really no reason for switch to fall through at all
I disagree. Switch fallthrough is very useful because it can reduce code duplication, especially when the logic has a ladder-like structure. Trying to impose increasingly draconian and such arbitrary rules is only going to lead to a self-fulfilling-prophecy where all the intelligent developers will get fed up and leave, and what's left are those which will continue to create tons of bugs some other way instead.