awesomemotive / wpforms-phpcs

PHP Coding Standards used by the WPForms team.
https://wpforms.com
GNU General Public License v2.0
12 stars 1 forks source link

Suggestion: remove requirement for a new line before break statement inside the switch #20

Closed slaFFik closed 2 years ago

slaFFik commented 2 years ago

Expected Behavior

The switch statement is already nicely formatted by default, break; is on the last line inside the case section most of the time. I would like to be able to save some space and not bloat the easily readable code with an extra new line requirement we currently have in effect. So I propose to allow this:

switch( $foo ) {
    case 'foo':
        $bar = 1;
        break;

    case 'bar':
        $bar = 2;
        break;

    case 'baz':
        $bar = 3;
        break;

    case 'krya':
    default:
        $bar = 4;
}

Current Behavior

Right now wpforms-phpcs insists on having a new line before break, which looks like this:

switch( $foo ) {
    case 'foo':
        $bar = 1;

        break;

    case 'bar':
        $bar = 2;

        break;

    case 'baz':
        $bar = 3;

        break;

    case 'krya':
    default:
        $bar = 4;
}

It has been mentioned here #8, but not implemented.