While it's too late in D7 to do this, I enjoy starting off new releases with a bang. ;)
Because...
1. Core doesn't conform to the current standard itself more than half the time. :P
2. 'elseif' is not a valid construct in JavaScript, so you have to remember two different things.
3. We have a rule that wedon'tcramletterstogether in variable/function names and so on. Makes sense we wouldn't do it in our control structures either.
4. "else if" has 109 million results in Google, 'elseif' doesn't rank. Further indicating this is a weird PHPism, making it more difficult for people coming from other languages to get started.
I'll mark this active once D8 opens for contributions and we can have a nice bikeshedding party. ;)
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | elseif-party.patch | 214.55 KB | franz |
Comments
Comment #1
franzI stumbled on this now. In 8x, there are very few places where "else if" is used in PHP code, while D7 have a little more. I agree "else if" is more readable than "elseif" and I specially agree with conforming to other languages. Also, conforming to other projects, since Symfony itself has no occurrance of elseif as well. Party can begin with a patch too =).
Comment #2
webchickTagging!
Comment #3
attiks commentedpatch looks clean, only thing i noticed is that the symfony files are also patched, since i don't know if this is needed leaving this as NR
Comment #4
jhodgdonWell, besides OK'ing the patch, we have to get some agreement from the dev community that we want to adopt this as a standard. :)
By the way, I'll just say that in my experience with programming in ... well let's just say a LOT of languages, there are three "standard" conventions I've seen:
- elseif
- elsif (no e)
- else if
PHP apparently supports two of them... when switching back and forth between languages, you just have to incur the syntax errors or try to remember.
Hmm:
http://us.php.net/manual/en/control-structures.elseif.php
says:
So, that's something to think about. elseif and else if are not actually exactly the same.
Comment #5
franzMmm, funny, I didn't notice that as well (symfony), this puts a big question mark on it, since it's the actual opposite of what I mentioned earlier: Symfony uses "elseif" consistently.
Also, a search on google for "elseif" does return good results (webchick research is from 2009).
Regarding the note about colon-followed structures, I haven't found a usage of elseif on that, but standards affect more than core (like themes).
I guess we have enough arguments to keep the standard to elseif and enforce it where it's not used.
Comment #6
webchickAh, if Symfony uses it I'm fine with won't fix. This was just a minor task when I had a hair up my butt about something or other. :)
Comment #7
droplet commentedsymfony - elseif
zend framework - elseif
codeIgniter - elseif
..
and more frameworks are elseif..
Comment #8
webchickWell that pretty well settles it then. Thanks for the patch anyway, franz! :)
Comment #9
franzCreated a new issue to enforce the standard: #1509838: Enforce "elseif" standard
Comment #10
franzCreated a new issue to enforce the standard rather than changing: #1509838: Enforce "elseif" standard