[wp-trac] [WordPress Trac] #28409: switch statements should be formatted consistently

WordPress Trac noreply at wordpress.org
Fri May 30 17:43:14 UTC 2014


#28409: switch statements should be formatted consistently
----------------------------+--------------------
 Reporter:  wonderboymusic  |       Owner:
     Type:  enhancement     |      Status:  new
 Priority:  normal          |   Milestone:  4.0
Component:  General         |     Version:  trunk
 Severity:  normal          |  Resolution:
 Keywords:                  |     Focuses:
----------------------------+--------------------
Description changed by wonderboymusic:

Old description:

> I have been looking at a number of issues over at #27882.
>
> There are a variety of places in core that format `switch` statements
> differently. IMO, `default` should always be at the bottom. It's more
> consistent, and it doesn't confuse static analysis tools (we don't have
> to do everything that is suggested by automated tools).
>
> {{{
> switch ( $var ) {
>     default:
>         break;
>     case 1:
>         $return = 'match';
>         break;
> }
> }}}
>
> is better than:
>
> {{{
> switch ( $var ) {
>     case 1:
>         $return = 'match';
>         break;
>     default:
>         break;
> }
> }}}

New description:

 I have been looking at a number of issues over at #27882.

 There are a variety of places in core that format `switch` statements
 differently. IMO, `default` should always be at the bottom. It's more
 consistent, and it doesn't confuse static analysis tools (we don't have to
 do everything that is suggested by automated tools).

 {{{
 switch ( $var ) {
     case 1:
         $return = 'match';
         break;
     default:
         break;
 }
 }}}
 is better than:

 {{{
 switch ( $var ) {
     default:
         break;
     case 1:
         $return = 'match';
         break;
 }
 }}}

--

--
Ticket URL: <https://core.trac.wordpress.org/ticket/28409#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list