Even though the Coding standards state that control structures should go according to:
if (condition1 || condition2) {
action1;
}
elseif (condition3 && condition4) {
action2;
}
else {
defaultaction;
}
There are 211 instances of 'else if' in core, as compared to 87 instances of 'elseif'
Here is a patch that replaces all 'elseif's with 'else if's. This is a pretty silly thing, but it does make code quality higher when everything's consistent. :)
Should this get in, I'll add this change to the coding standards page as well, so there are no further discrepancies.
Comments
Comment #1
webchickComment #2
heine commentedSee also this documentation issue: http://drupal.org/node/47379
Comment #3
chx commentedwebchick, what about the reverse?? replace "else if" with elseif
Comment #4
webchickSure, I can do that too.
Just FYI though, it looks like 'else if' is the de-facto standard... from a search of contrib/modules:
Found 867 occurrences in 268 files for the word: elseif
Found 957 occurrences in 252 files for the word: else if
I don't really care though which way it goes, as long as there is a standard. :)
Comment #5
Cvbge commentedOh please, let's not be so strict on this (and other style guide things), there is no difference whether you use
elseiforelse if. If it waselse ifvs
or similar, I'd understand, but not this!
And yes, I expect applying this patch will invalidate many existing patches and will make comparing different versions harder.
And last thing: the patches might be doing something wrong with encoding, they contain changes to some non-english strings (language names) which are displayed differently in FF.
Comment #6
drummI'm not even going to attempt to apply this. It is going to fail.
Comment #7
webchickYes, indeed. ;)
I'll re-roll it at the start of the next release cycle.
Comment #8
webchickComment #9
RobRoy commentedI vote for 'elseif' instead of 'else if'. When using some PHP code style formatters, 'else if' gets split into two lines. Also, 'elseif' is just more compact and nicer. :)
Comment #10
webchickYes you're right... that's what the coding guidelines say too.
Comment #11
Paul Natsuo Kishimoto commentedSubscribing.
I guess this will be jumped on again as soon as 5.0 is released?
Comment #12
webchickThat's the plan, yes. No point in re-rolling the patch until then.
Comment #13
webchickhttp://drupal.org/node/282405