No alternative syntax for PHP control structures in Add On's??

I am completing some work on some Add On's that I may want to make available here and out of a desire to make Add On's just the way Concrete5 wants them, I was reviewing some documentation on Coding Guidelines ( and noticed at the very bottom this...

"•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.



View Replies:
jbx replied on at Permalink Reply
Must confess, I always use alternative syntax in my views.

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...

carlos123 replied on at Permalink Reply
Thanks for the input jbx.

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.

jordanlev replied on at Permalink Reply
By "alternative syntax" do you mean using "short tags" (like <? and <?= instead of <?php and <?php echo), or do you mean using <?php if (...): ?> and <?php endif; ?> style tags?

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.
carlos123 replied on at Permalink Reply
Hi Jordan,

Well...PHP alternative syntax, officially speaking, is writing the constructs out to use if (): / endif as opposed to if () { / }

If that makes sense.


jordanlev replied on at Permalink Reply
Isn't that what I just said? :)

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).
carlos123 replied on at Permalink Reply
Oops. Sorry Jordan.

I just re-read your previous response and 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.

Mnkras replied on at Permalink Reply
Yea, in the PRB we don't really check/enforce that...