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.

CommentFileSizeAuthor
#4 elseif_0.patch61.94 KBwebchick
elseif.patch40.29 KBwebchick

Comments

webchick’s picture

Status: Active » Needs review
heine’s picture

See also this documentation issue: http://drupal.org/node/47379

chx’s picture

webchick, what about the reverse?? replace "else if" with elseif

webchick’s picture

StatusFileSize
new61.94 KB

Sure, 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. :)

Cvbge’s picture

Oh please, let's not be so strict on this (and other style guide things), there is no difference whether you use elseif or else if. If it was
else if
vs

else
if

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.

drumm’s picture

Version: x.y.z » 6.x-dev
Status: Needs review » Needs work

I'm not even going to attempt to apply this. It is going to fail.

webchick’s picture

Yes, indeed. ;)

I'll re-roll it at the start of the next release cycle.

webchick’s picture

Status: Needs work » Postponed
RobRoy’s picture

I 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. :)

webchick’s picture

Title: Minor consistency thing: elseif -> else if » Minor consistency thing: else if -> elseif

Yes you're right... that's what the coding guidelines say too.

Paul Natsuo Kishimoto’s picture

Subscribing.

I guess this will be jumped on again as soon as 5.0 is released?

webchick’s picture

That's the plan, yes. No point in re-rolling the patch until then.

webchick’s picture

Status: Postponed » Closed (duplicate)