Topic on Manual talk:Coding conventions

ESanders (WMF) (talkcontribs)

There are some exceptions, such as switch statements, where the indentation of the cases are optional, so both of the below are fine.

This seems odd:

  1. In JS the indentation is required and enforced by eslint, so this isn't true in that case
  2. in PHP it seems odds to allow no indentation when every other type of braced block requires indentation

I think it would be simpler just to remove this exception.

Anomie (talkcontribs)

In MediaWiki core and deployed extensions there are 486 PHP files with indented cases and 93 with non-indented cases. 20 files have both types, and so are included in both counts.

Huji (talkcontribs)

Not sure how you did the math here, @Anomie:, but how about we change those 93 cases to be indented too, and then remove the exception as suggested by ESanders?

Anomie (talkcontribs)

find . ../wmf/extensions/ \( -name vendor -o -name node_modules -o -name .git \) -prune -o -name \*.php -exec perl -lnwe '$i=$1 if /^(\t+)switch/; if($i && /^${i}case /){ print $ARGV; last; }' {} \; for the non-indented, and the same with /^${i}\tcase / in the middle for indented.

Ed g2s (talkcontribs)
Reply to "Switch statements"