No alternative syntax for PHP control structures in Add On's??
Permalink"•PHP's alternative syntax for control structures is not allowed."
I don't have a problem with most everything else in the Coding Guidelines but this?
Is that really not allowed in Add On's?
I'll abide by the lack of such in Add On's if that is absolutely not allowed but I would more wholeheartedly support such a policy if I at least knew of a valid reason to not allow it's use. It does seem to me that the alternative syntax makes code easier to follow and understand.
Any input on this would be appreciated.
Thanks.
Carlos
Well...given the lack of overall input on this thread to my question...I think what I will do is just create the Add On code with the alternative syntax and see whether it gets accepted with it.
If not...I can easily switch back.
Yeah...I think that's what I will do barring any official confirmation that I should do otherwise.
Carlos
Never use short tags in code you will be sharing publicly because a lot of people's servers have that feature disabled (it's disabled by default in PHP). But the alternative syntax for control structures (using colons and ending words instead of curly braces) is totally fine -- I use that all the time in my html templates.
I think the guidelines may be using the wrong term there.
Well...PHP alternative syntax, officially speaking, is writing the constructs out to use if (): / endif as opposed to if () { / }
If that makes sense.
Seehttp://php.net/manual/en/control-structures.alternative-syntax.php...
Carlos
I didn't write those guidelines, I was just was answering your question (specifically, the part about how I use the alternative syntax all the time and never had a problem).
I just re-read your previous response and yes...you did say you use that syntax and never had a problem.
I focused exclusively an answering the first question you asked and completely missed the rest of what you said :). My bad.
Carlos
I think it reads much better in a view. Never in a script though.
I'd be amazed if your addon got knocked back for using it though. I've seen some shockingly bad code in some addons that have made it through the process just fine...
I also hate the way you can't stick to Zend coding guidelines in some places. Zend have such excellent coding guidelines that I reckon it would make sense to have just followed them fully. However, I'm guessing that by the time the guidelines were introduced and Zend's guidelines were considered, there was too much code and it was too late to go back...
Jon