Are inline control structures prohibited?

2,088 views
Skip to first unread message

s...@samwilson.id.au

unread,
Apr 25, 2013, 7:51:38 PM4/25/13
to php-f...@googlegroups.com
PSR2 states that "the body of each structure MUST be enclosed by braces", but does this mean that inline control structures are not allowed?

For example: echo ($test) ? 'yes' : 'no';

I raised an issue for this: https://github.com/php-fig/fig-standards/issues/54

Thanks,
Sam.



Dmitrii Chekaliuk

unread,
Apr 25, 2013, 9:18:52 PM4/25/13
to php-f...@googlegroups.com
Conditional operator is not a control structure, so it's beyond the scope of PSR-2.

s...@samwilson.id.au

unread,
Apr 25, 2013, 9:40:29 PM4/25/13
to php-f...@googlegroups.com
Good point.

The PSR2 code sniffer standard reports that "Inline control structures are not allowed" when it finds a ternary operator.

I take it that this should be changed?

Thanks,
Sam.

Dmitrii Chekaliuk

unread,
Apr 26, 2013, 8:30:20 AM4/26/13
to php-f...@googlegroups.com
I can't reproduce this. Are you sure it's caused by the ternary operator?
Reply all
Reply to author
Forward
0 new messages