When Laravel 5.1 is upon us, PSR-2 will be enforced.
I'm a big fan of PHP-FIG, unfortunately for me I got really used to and comfortable with control structures in a new line.
Consider this current piece of code, already adhering to PSR-2:
foreach($items as $item) {
Cart::update($item, Input::get('qty_' .$item));
}
I understand the following is not PSR-2:
foreach($items as $item)
{
Cart::update($item, Input::get('qty_' .$item));
}
But, how about these variations?
foreach($items as $item) Cart::update($item, Input::get('qty_' .$item));
foreach($items as $item)
Cart::update($item, Input::get('qty_' .$item));
foreach($items as $item):
Cart::update($item, Input::get('qty_' .$item));
endforeach;
As you can see, I got addicted to the white space resulting from the lead curly brace when going into a new line.
Can any of the variations mentioned be considered properly PSR-2?
No, none of those variations are PSR-2 compliant either. A control structure needs to have braces and there should be a space following the control structure name. These rules are defined rather explicitly here:
Control Structure Guidelines