PSR-12: what about alternative control structures syntax?

314 views
Skip to first unread message

Anatoly Pashin

unread,
Mar 28, 2016, 9:14:29 PM3/28/16
to PHP Framework Interoperability Group
http://php.net/manual/en/control-structures.alternative-syntax.php

This thing is totally forgotten in PSR-1, PSR-2 and PSR-12.
Alternative syntax is very neat to write templates.

Joe Meyer

unread,
Mar 28, 2016, 10:28:04 PM3/28/16
to PHP Framework Interoperability Group
Personally, I find no need for the alternative syntax structures with proper indentation and in fact find it much easier to rely on my IDE to help me match up the opening / closing braces. Additionally, I think that as soon as you end up with nested control structures, you want proper indentation to keep things straight anyway at which point why not just use the curly braces. In the case of templating, if I have something that's fairly nested in logic, usually I take that as a sign that it's time to break up my template files, which also helps with readability.

Korvin Szanto

unread,
Mar 29, 2016, 12:46:22 PM3/29/16
to PHP Framework Interoperability Group
I'm with Joe on this one. I don't necessarily want to get into the mess of recommending style for mixed PHP and HTML. If there is a real demand for this, perhaps we should require exactly "if (true):" just to set the colon placement in stone.

Thanks,
Korvin

--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/134bb959-0e74-49e5-8f6d-9e4a6f78d1b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alexander Makarov

unread,
Mar 29, 2016, 6:08:05 PM3/29/16
to PHP Framework Interoperability Group
Agree with Joe more or less mainly because there are multiple styles of aligning HTML tags. We have an example in Yii though: https://github.com/yiisoft/yii2/blob/master/docs/internals/view-code-style.md
Reply all
Reply to author
Forward
0 new messages